📄 corbaserver.java
字号:
package net.sourceforge.gjtapi.raw.remote;
/*
Copyright (c) 2002 8x8 Inc. (www.8x8.com)
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
*/
import net.sourceforge.gjtapi.media.*;
import javax.telephony.media.RTC;
import javax.telephony.media.MediaResourceException;
import javax.telephony.*;
import net.sourceforge.gjtapi.raw.remote.corba.*;
import net.sourceforge.gjtapi.*;
import net.sourceforge.gjtapi.raw.*;
import java.util.*;
import javax.telephony.media.Symbol;
import net.sourceforge.gjtapi.raw.remote.corba.LongEntry;
/**
* This is a server class for that translates the CORBA skeleton's calls to a TelephonyProvider.
* Creation date: (2000-08-18 14:39:05)
* @author: Richard Deadman
*/
public class CorbaServer extends _CorbaProviderImplBase {
private CallMapper refMapper = new CallMapper();
private RawListenerMux callbackMux = new RawListenerMux();
private TelephonyProvider real;
private org.omg.CORBA.ORB orb;
/**
* Create a server-side wrapper for a real TelephonyProvider
* Creation date: (2000-08-24 15:29:45)
* @author: Richard Deadman
* @param tl net.sourceforge.gjtapi.TelephonyProvider
*/
public CorbaServer(TelephonyProvider tp, org.omg.CORBA.ORB orb) {
super();
if (tp == null)
throw new NullPointerException();
else
this.setReal(tp);
// register my listener (wrappedd in a event dispatch pool)
tp.addListener(this.getCallbackMux());
// Note the ORB I'm going through
this.setOrb(orb);
}
/**
* addListener method comment.
*/
public void addListener(net.sourceforge.gjtapi.raw.remote.corba.CorbaListener cl) {
this.getCallbackMux().addListener(new CorbaListenerWrapper(cl, this.getRefMapper(), this.getOrb()));
}
/**
* allocateMedia method comment.
*/
public boolean allocateMedia(String term, int type, net.sourceforge.gjtapi.raw.remote.corba.LongEntry[] parameters) {
return this.getReal().allocateMedia(term, type, this.toSymbolDictionary(parameters));
}
/**
* answerCall method comment.
*/
public void answerCall(int callId, String address, String terminal) throws ResourceUnavailableEx, PrivilegeViolationEx, RawStateEx, MethodNotSupportedEx {
try {
this.getReal().answerCall(this.getRefMapper().intToCall(callId), address, terminal);
} catch (javax.telephony.ResourceUnavailableException rue) {
throw this.createResourceUnavailableEx(rue);
} catch (PrivilegeViolationException pve) {
throw createPrivilegeViolationEx(pve);
} catch (RawStateException rse) {
throw createRawStateEx(rse);
} catch (MethodNotSupportedException nse) {
throw createMethodNotSupportedEx(nse);
}
}
/**
* attachMedia method comment.
*/
public boolean attachMedia(int call, java.lang.String address, boolean onFlag) {
return this.getReal().attachMedia(this.getRefMapper().intToCall(call), address, onFlag);
}
/**
* beep method comment.
*/
public void beep(int call) {
this.getReal().beep(this.getRefMapper().intToCall(call));
}
/**
* Convert a Generic JTAPI CallData array to a CORBA CallData array.
* Creation date: (2000-08-23 16:14:19)
* @author: Richard Deadman
* @return net.sourceforge.gjtapi.raw.remote.corba.CallData[]
* @param ca net.sourceforge.gjtapi.CallData[]
*/
private net.sourceforge.gjtapi.raw.remote.corba.CallData[] convertCallArray(net.sourceforge.gjtapi.CallData[] ca) {
int size = ca.length;
net.sourceforge.gjtapi.raw.remote.corba.CallData[] cda = new net.sourceforge.gjtapi.raw.remote.corba.CallData[size];
for (int i = 0; i < size; i++) {
cda[i] = this.toCallData(ca[i]);
}
return cda;
}
/**
* Convert a Generic JTAPI TermData array to a CORBA TermData array.
* Creation date: (2000-08-23 16:14:19)
* @author: Richard Deadman
* @return net.sourceforge.gjtapi.raw.remote.corba.TermData[]
* @param ca net.sourceforge.gjtapi.TermData[]
*/
private net.sourceforge.gjtapi.raw.remote.corba.TermData[] convertTermDataArray(net.sourceforge.gjtapi.TermData[] td) {
int size = td.length;
net.sourceforge.gjtapi.raw.remote.corba.TermData[] tda = new net.sourceforge.gjtapi.raw.remote.corba.TermData[size];
for (int i = 0; i < size; i++) {
tda[i] = this.toTermData(td[i]);
}
return tda;
}
/**
* createCall method comment.
*/
public int createCall(int callId, String address, String terminal, String destination) throws net.sourceforge.gjtapi.raw.remote.corba.ResourceUnavailableEx, net.sourceforge.gjtapi.raw.remote.corba.InvalidArgumentEx, net.sourceforge.gjtapi.raw.remote.corba.InvalidPartyEx, net.sourceforge.gjtapi.raw.remote.corba.PrivilegeViolationEx, net.sourceforge.gjtapi.raw.remote.corba.RawStateEx, net.sourceforge.gjtapi.raw.remote.corba.MethodNotSupportedEx {
CallMapper cm = this.getRefMapper();
try {
return cm.callToInt(this.getReal().createCall(cm.intToCall(callId), address, terminal, destination));
} catch (javax.telephony.ResourceUnavailableException rue) {
throw this.createResourceUnavailableEx(rue);
} catch (PrivilegeViolationException pve) {
throw createPrivilegeViolationEx(pve);
} catch (RawStateException rse) {
throw createRawStateEx(rse);
} catch (MethodNotSupportedException nse) {
throw createMethodNotSupportedEx(nse);
} catch (InvalidPartyException ipe) {
throw createInvalidPartyEx(ipe);
} catch (InvalidArgumentException iae) {
throw createInvalidArgumentEx(iae);
}
}
/**
* Factory to create the appropriate ResourceEvent based on the CORBA resource event enumeration
*/
private net.sourceforge.gjtapi.raw.remote.corba.ResourceEvent createEvent(javax.telephony.media.ResourceEvent re) {
net.sourceforge.gjtapi.raw.remote.corba.ResourceUnion ru = new ResourceUnion();
if (re instanceof GenericPlayerEvent) {
GenericPlayerEvent pe = (GenericPlayerEvent)re;
ru.playEv(new PlayerEvent((int)pe.getChangeType().hashCode(),
pe.getIndex(),
pe.getOffset()));
}
if (re instanceof GenericRecorderEvent) {
GenericRecorderEvent ev = (GenericRecorderEvent)re;
ru.recEv(new RecorderEvent(ev.getDuration()));
}
if (re instanceof GenericSignalDetectorEvent) {
GenericSignalDetectorEvent ev = (GenericSignalDetectorEvent)re;
ru.sdEv(new SigDetectorEvent(ev.getPatternIndex(),
CorbaProvider.toLongArray(ev.getSignalBuffer())));
}
return new ResourceEvent((int)re.getError().hashCode(),
(int)re.getEventID().hashCode(),
re.getMediaService().getTerminal().getName(),
(int)re.getQualifier().hashCode(),
(int)re.getRTCTrigger().hashCode(),
ru);
}
/**
* Create a Corba InvalidArgumentEx from its pair
* Creation date: (2000-08-24 18:34:19)
* @author: Richard Deadman
* @return net.sourceforge.gjtapi.raw.remote.corba.InvalidArgumentEx
* @param rue javax.telephony.InvalidArgumentException
*/
private InvalidArgumentEx createInvalidArgumentEx(javax.telephony.InvalidArgumentException iae) {
return new InvalidArgumentEx(iae.getMessage());
}
/**
* Create a Corba InvalidPartyEx from its pair
* Creation date: (2000-08-24 18:34:19)
* @author: Richard Deadman
* @return net.sourceforge.gjtapi.raw.remote.corba.InvalidPartyEx
* @param rue javax.telephony.InvalidPartyException
*/
private InvalidPartyEx createInvalidPartyEx(javax.telephony.InvalidPartyException ipe) {
return new InvalidPartyEx(ipe.getType(), ipe.getMessage());
}
/**
* Create a Corba MethodNotSupportedEx from its pair
* Creation date: (2000-08-24 18:34:19)
* @author: Richard Deadman
* @return net.sourceforge.gjtapi.raw.remote.corba.MethodNotSupportedEx
* @param rue javax.telephony.MethodNotSupportedException
*/
private MethodNotSupportedEx createMethodNotSupportedEx(javax.telephony.MethodNotSupportedException nse) {
return new MethodNotSupportedEx(nse.getMessage());
}
/**
* Create a Corba PrivilegeViolationEx from its pair
* Creation date: (2000-08-24 18:34:19)
* @author: Richard Deadman
* @return net.sourceforge.gjtapi.raw.remote.corba.ResourceUnavailableEx
* @param rue javax.telephony.ResourceUnavailableException
*/
private PrivilegeViolationEx createPrivilegeViolationEx(javax.telephony.PrivilegeViolationException pve) {
return new PrivilegeViolationEx(pve.getType(), pve.getMessage());
}
/**
* Create a Corba RawStateEx from its pair
* Creation date: (2000-08-24 18:34:19)
* @author: Richard Deadman
* @return net.sourceforge.gjtapi.raw.remote.corba.ResourceUnavailableEx
* @param rue javax.telephony.ResourceUnavailableException
*/
private RawStateEx createRawStateEx(RawStateException rse) {
RawStateEx re = new RawStateEx();
re.type = rse.getObjectType();
re.info = rse.getMessage();
re.state = rse.getState();
Object o = rse.getObject();
if (o instanceof Address) {
re.address = ((Address)o).getName();
}
if (o instanceof Terminal) {
re.terminal = ((Terminal)o).getName();
}
if (o instanceof Call) {
re.callId = (int)((SerializableCallId)((FreeCall)o).getCallID()).getId();
}
if (o instanceof Connection) {
re.callId = (int)((SerializableCallId)((FreeCall)((Connection)o).getCall()).getCallID()).getId();
re.address = ((Connection)o).getAddress().getName();
}
if (o instanceof TerminalConnection) {
Connection conn = ((TerminalConnection)o).getConnection();
re.callId = (int)((SerializableCallId)((FreeCall)conn.getCall()).getCallID()).getId();
re.address = conn.getAddress().getName();
re.terminal = ((TerminalConnection)o).getTerminal().getName();
}
return re;
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -