📄 peerprovider.java
字号:
}
}
HandleDialogueReq handleDialogueReq = new HandleDialogueReq(event);
handleDialogueReq.start();
}
/**
* Adds a <a href="JainTcapListener.html">JainTcapListener</a>
* to the list of registered event listeners of this Provider.
* @param <var>listener</var> the JAIN TCAP Listener to be added.
* @param <var>userAddressList</var> the list of user address used supported by the
* JainTcapListener
* @exception TooManyListenersException thrown if a limit is placed on the allowable
* number of registered listeners, and this limit is exceeded.
* @exception ListenerAlreadyRegisteredException thrown if a JainTcapListener attempts
* to register as an Event Listener, but is already registered with this Provider.
* @exception InvalidAddressException thrown if the user address
* supplied is not a valid address
*/
public void addJainTcapListener(JainTcapListener listener, SccpUserAddress userAddress)
throws TooManyListenersException, ListenerAlreadyRegisteredException, InvalidAddressException {
System.out.println("PeerProvider : addJainTcapListener : at start ");
/*
* first check if another listener is allowed
* TC_users limited to 255
*/
if (numListeners >= MAX_LISTENERS) {
throw new TooManyListenersException("PeerProvider : addJainTcapListener : There are already " +MAX_LISTENERS +" registered.");
} else {
// check if the listener is already registered for that UserAddress
try{
if (listeners.contains(listener) && listener.getUserAddressList().equals(userAddress)) {
String errMsg = "PeerProvider : addJainTcapListener : Listener already registered";
System.out.println(errMsg);
throw new ListenerAlreadyRegisteredException(errMsg);
} else {
// none of the Exception categories apply => register the Listener
listeners.addElement(listener);
System.out.println("PeerProvider : addJainTcapListener : The supplied Listener has been registered with this Provider");
}
} catch(UserAddressEmptyException e){
String errMsg = "PeerProvider : addJainTcapListener : User Address list is empty";
System.out.println(errMsg);
}
}
}
/**
* Deprecated as of JAIN TCAP V1.1
*/
public void addJainTcapListener(JainTcapListener listener, TcapUserAddress userAddress)
throws TooManyListenersException, ListenerAlreadyRegisteredException {
}
/**
* Removes a <a href="JainTcapListener.html">JainTcapListener</a>
* from the list of registered listeners of an object implementing this interface.
* @param <var>listener</var> the TCAP listener to be removed.
* @exception ListenerNotRegisteredException thrown if the JainTcapListener to be
* removed is not registered as an Event Listener of this JainTcapProvider.
*/
public void removeJainTcapListener(JainTcapListener listener)
throws ListenerNotRegisteredException {
System.out.println("PeerProvider : removeJainTcapListener : removing Listener");
if (!listeners.contains(listener)){
throw new ListenerNotRegisteredException();
} else {
listeners.removeElement(listener);
}
}
/**
* Returns the JainTcapStack that this JainTcapProvider is attached to.
* @return the attached JainTcapStack.
* @exception ProviderNotAttachedException thrown if this method is invoked and this JainTcapProvider
* is not attached to the Stack.
* @ deprecated since 1.1
*/
public JainTcapStack getAttachedStack() {
return null;
}
/**
* Returns the JainTcapStack that this JainTcapProvider is attached to.
* @return the attached JainTcapStack.
* @exception ProviderNotAttachedException thrown if this method is invoked and this JainTcapProvider
* is not attached to the Stack.
*/
public JainTcapStack getStack() {
System.out.println("PeerProvider : getStack : getting Attached Stack");
if (this.attached = false) {
String errMsg = "PeerProvider : getStack : the provider is not currently attached";
System.out.println(errMsg);
}
return(this.attachedStack);
}
/**
* Indicates if this JainTcapProvider is attached to a JainTcapStack.
* @return <UL>
* <LI><B>true</B> - this JainTcapProvider <B>is</B> attached to a JainTcapStack
* <LI><B>false</B> - this JainTcapProvider is <B>not</B> attached to any JainTcapStack
* </UL>
*/
public boolean isAttached(){
//Attach is done implicitly
return true;
}
/*
* The following methods are not defined in the JainTcapProvider interface
*/
/**
* Collects all components and stores at appropriate key of the receivedComponentTable(Hash table)
*/
protected static void fireComponentIndEvent(ComponentIndEvent component){
System.out.println("PeerProvider : fireComponentIndEvent : at start");
// integer value used for received component ID value
int cId = 0;
try {
cId = component.getDialogueId();
} catch (ParameterNotSetException e) {
System.out.println("PeerProvider : fireComponentReqEvent : could not get Dialogue Id");
}
Integer cIdObj = new Integer(cId);
/*
* Adds received component to the receivedComponentTable, which is a Hashtable.
* The keys of the hashtable are the DialogueIDs of the received components.
* If no key corresponding to the received component's DialogueID exists a vector is created
* to store the component and any other components with the same DialogueID and added to the hashtable.
*/
if ((!receivedComponentTable.isEmpty()) && (receivedComponentTable.containsKey(cIdObj))) {
Vector compTemp = (Vector)receivedComponentTable.get(cIdObj);
System.out.println("PeerProvider : fireComponentReqEvent : Adding received Component to receivedComponentTable");
compTemp.addElement(component);
receivedComponentTable.put(cIdObj,compTemp);
} else {
Vector compTemp = new Vector();
compTemp.addElement(component);
receivedComponentTable.put(cIdObj,compTemp);
}
}
/**
* Gets the address of the registered Listener. Sends to Listener Dialogues Indication Events
* and any associated Component Indicatiopn Events.
*/
protected static void fireDialogueIndEvent(DialogueIndEvent dialogue) {
System.out.println("PeerProvider : fireDialogueIndEvent : at start");
/*
* find the registered listener. Check the destination address against the list of registered listeners.
* TCK v 1.0a has a listener:provider 1:1 therefore the address of destination
* is that of the first element and only listener registered.
*/
JainTcapListener registeredListener = (JainTcapListener)listeners.elementAt(0);
SccpUserAddress[] userAddressList = new SccpUserAddress[10];
try{
userAddressList = registeredListener.getUserAddressList();
} catch(UserAddressEmptyException e){}
// Send the Dialogue Ind to the registered Listener.
registeredListener.processDialogueIndEvent(dialogue);
//POD: Bug fix added to handle the sending of components associated with a
//UNI to the listener even though a UNI Ind doesn't have a dialogue ID. The RI
//is limited in scope and associates components using only the dialogue ID.
//As we can use the dialogueId for UNI Inds we must utilize an internal variable
//for the sending of the UNI Ind components - this can be achieved as we know
//the messages format i.e. only two UNI Ind sent in the complete TCK.
if(dialogue.getPrimitiveType() == jain.protocol.ss7.tcap.TcapConstants.PRIMITIVE_UNIDIRECTIONAL){
uniIndCounter++;
if (uniIndCounter == 1) {
dIdObj = new Integer(1);
} else if (uniIndCounter == 2) {
dIdObj = new Integer(5);
}
} else {
try {
dIdObj = new Integer(dialogue.getDialogueId());
} catch(ParameterNotSetException notSet) {
System.out.println("PeerProvider : fireDialogueIndEvent : Exception : " +notSet);
}
}
// Checking component table for elements with same Dialogue Id
if (receivedComponentTable.containsKey(dIdObj)) {
System.out.println("PeerProvider : fireDialogueIndEvent : receivedComponentTable.containsKey(dIdObj) ");
Vector compTempy = (Vector)receivedComponentTable.get(dIdObj);
for(int i = 0 ; i < compTempy.size();i++) {
tempCompInd = (ComponentIndEvent)compTempy.elementAt(i);
// invoking the processComp method of registered Listener
System.out.println("PeerProvider : fireDialogueIndEvent : invoking the processComp method of registered Listener");
if (tempCompInd != null){
registeredListener.processComponentIndEvent(tempCompInd);
}
}
// Clear the components after they have ALL been sent to registered Listener
receivedComponentTable.remove(dIdObj);
} else {
System.out.println("PeerProvider : fireDialogueIndEvent : No components for this dialogue");
}
}
/**
* Method for adding received components to the ComponentTable
*/
protected synchronized static void addComponentTable(Integer dIdObj, Vector newList) {
System.out.println("PeerProvider : addComponentTable : Adding components to table");
componentTable.put(dIdObj,newList);
}
/**
* checks if a passed index value exists in ComponentTable
*/
protected synchronized static boolean checkComponentTable(Integer dIdObj) {
System.out.println("PeerProvider : checkComponentTable : Checking components to table");
return (componentTable.containsKey(dIdObj));
}
/**
* returns Objects from ComponentTable at Index.
*/
protected synchronized static Object getItemsComponentTable(Integer dIdObj) {
System.out.println("PeerProvider : getItemsComponentTable : returning components");
return (componentTable.get(dIdObj));
}
/**
* removes Objects from ComponentTable at Index.
*/
protected synchronized static void removeComponentTableItems(Integer dIdObj) {
System.out.println("PeerProvider : removeComponentTableItems : removing components");
componentTable.remove(dIdObj);
}
private int currentDialogueId = 0;
private int numListeners = 0;
/**
* Vectored List of registered Listeneres
*/
private static Vector listeners = new Vector();
/**
* This hashtable contains Dialogue Ids stored in Integer objects as keys
* to a Vector containing the Invoke Ids used in this dialogue
*/
private Hashtable dialogueIdTable = new Hashtable();
/**
* This hashtable stores uses a DialogueId as a key to a Vector containing
* all the request components received for that dialogueId
*/
private static Hashtable componentTable = new Hashtable();
/**
* This hashtable stores all received Components. The DialogueId
* of the Components is used as a key to a Vector containing
* all the request components received for that dialogueId from the Support object.
*/
public static Hashtable receivedComponentTable = new Hashtable();
// PeerProvider constants
private static int MAX_DIALOGUE_IDS = 1000000;
private static int MIN_DIALOGUE_ID = 1;
private static int MIN_INVOKE_ID = 1;
private static int MAX_INVOKE_IDS_PER_DIALOGUE = 255;
private static int MAX_LISTENERS = 255;
protected boolean attached = false;
protected JainTcapStack attachedStack = null;
private static ComponentIndEvent tempCompInd = null;
private SccpUserAddress destinationAddress = null;
private static Integer dIdObj = null;
private static Integer uniObj = null;
private static int uniIndCounter = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -