|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.epfl.lsr.apex.APEXManager
The APEXManager
is the general class for the two
APEX managers and offers various functionalities to their
subclasses.
Field Summary | |
protected APEXProcess |
application
The application associated to this process |
protected Hashtable |
lockedIdentifiers
Set of identifiers (b)locked for in the semaphore when getting an element of the messageTable. |
protected Hashtable |
messageTable
Hash table for multiple use (e.g. storage for static classes) |
protected int |
port
Default port number to connect to (edge and mesh respectively) |
static int |
PROCESSTYPE_ENDPOINT
Endpoint process type |
static int |
PROCESSTYPE_RELAY
Relay process type |
static int |
SERVICEPRIORITIES
Service properties identifier in service array |
protected Hashtable[] |
services
Service array containing on SERVICETABLE a table of
all services mapped by their option identifer and on SERVICEPRIORITIES
a vector of the priority of their processing. |
static int |
SERVICETABLE
Service table identifier in service array |
protected Hashtable |
transactionTable
Table containing all sets of transactions, mapped by the channelID |
Constructor Summary | |
APEXManager()
|
Method Summary | |
boolean |
addTransaction(Object channelID,
int transID,
Object operation)
Adds a transaction identified by a transID number associated to an APEX endpoint / relay (entity) to the internal transactionTable. |
void |
debug(String debugMessage)
Accepts and passes messages to the application's debug method. |
APEXProcess |
getApplication()
Returns the application ( APEXProcess ) associated
to this manager. |
Object |
getFromTable(Object key)
Returns an object associated to the key or null if the
key is not mapped in the message hash table.
|
Object |
getFromTableAndLock(Object key,
Object lockIdentifier)
Offers the possibility to any class (mainly static classes to read arbitrary content identified by a unique key and lock while reading and updating an element for a special group. |
Object |
getTransaction(Object channelID,
int transID)
Returns the operation identifier for a specified transaction identifier of an associated channel. |
abstract void |
handleIncomingMessage(APEXMessage am,
Object receivingChannelID)
When a message has been received on a connection it calls its manager's ' handleIncomingMessage ' method. |
abstract void |
messageDiscarded(APEXDataMessage am,
int code,
String reason)
This mesthod is called when a connection wasn't able to send an ' APEXMessage ', say a
(where x ! |
abstract void |
messageSent(APEXDataMessage am,
APEXReply reply)
This mesthod is called when an ' APEXMessage ' is
successfully sent on a connection, say an
element has been received. |
void |
notification(int code,
Object specification)
Accepts and passes messages to the application's notification method. |
protected int |
parsePort(String p)
Parses a String port number, e.g. from an XML attribute
and returns the port number as an int if it is valid
(between 1 and 65535).
|
void |
putToTable(Object key,
Object value)
Offers the possibility to any class (mainly static classes to store arbitrary content identified by a unique key. |
void |
putToTableAndUnlock(Object key,
Object value,
Object unlockIdentifier)
Puts a value to the message tabe and afterwards unlocks the table. |
void |
removeAllTransactions(Object channelID)
Removes completely the transaction table for the associated channel. |
Object |
removeFromTable(Object key)
Removes a key and its associated content from the message hash table. |
Object |
removeTransaction(Object channelID,
int transID)
Removes and returns the operation identifier for a specified transaction identifier of an associated channel. |
abstract int |
sendAPEXDataMessage(APEXDataMessage adm)
Sends an APEXDataMessage to the recipients specified
within the object.
|
protected APEXOption[] |
sortOptions(APEXOption[] ao)
Returns an array of sorted ' APEXOptions ' as they are
specified in the configuration file for the services by the attribute
priority . |
abstract int |
terminate(APEXTerminateMessage atm,
Object receivingChannelID)
Is called when an terminate element is received a status
code (for the reply is returned). |
void |
unlockTable(Object key,
Object unlockIdentifier)
Unlocks the message table for the specified key and the identifier. |
protected boolean |
validatePort(int port)
Validates a given port number (between 1 and 65535). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int PROCESSTYPE_RELAY
public static final int PROCESSTYPE_ENDPOINT
public static final int SERVICETABLE
public static final int SERVICEPRIORITIES
protected int port
protected Hashtable messageTable
protected Hashtable transactionTable
protected Hashtable lockedIdentifiers
protected Hashtable[] services
SERVICETABLE
a table of
all services mapped by their option identifer and on SERVICEPRIORITIES
a vector of the priority of their processing.
protected APEXProcess application
Constructor Detail |
public APEXManager()
Method Detail |
public abstract int sendAPEXDataMessage(APEXDataMessage adm)
Sends an APEXDataMessage
to the recipients specified
within the object.
adm
- Data message to be sent. If no recipients are specified,
no action is taken.
public abstract void handleIncomingMessage(APEXMessage am, Object receivingChannelID) throws APEXException
handleIncomingMessage
' method.
am
- The incoming messagereceivingChannelID
- The channel identifier of the channel which received the
message
APEXException
- Is thrown on an error in processingpublic abstract void messageDiscarded(APEXDataMessage am, int code, String reason)
APEXMessage
', say a
(where x != 250) is received or the next hop is not responding.
All applicable services are called by there method
'handleDiscarded
'.
am
- The message which wasn't sentcode
- The error code of this messagereason
- A textual reasonpublic abstract void messageSent(APEXDataMessage am, APEXReply reply)
APEXMessage
' is
successfully sent on a connection, say an
element has been received. All applicable services are called
by there method 'handleSent
'
am
- The message which has successfully been sentreply
- The reply object received of the next hoppublic abstract int terminate(APEXTerminateMessage atm, Object receivingChannelID)
terminate
element is received a status
code (for the reply is returned). This method terminates the transaction
if it exists
atm
- Associated APEXTerminateMessage
for operation
to terminate.receivingChannelID
- A channel identifier for the channel which received the
operation
public APEXProcess getApplication()
APEXProcess
) associated
to this manager.
public void debug(String debugMessage)
debugMessage
- the debug messagepublic void notification(int code, Object specification)
code
- A three digit codespecification
- An Object specifying the notificationAPEX
,
APEXProcess.notification(int, Object)
public void putToTable(Object key, Object value)
Offers the possibility to any class (mainly static classes to store arbitrary content identified by a unique key.
Please note that when using this table, the key must be completely unique, you are strongly asked to identify the key with the application or service you are setting up.
This method is synchronized but is not a semaphore - please refer putToTableAndUnlock
.
key
- unique key for message tablevalue
- the contentpublic Object getFromTable(Object key)
Returns an object associated to the key or null
if the
key is not mapped in the message hash table.
This method is synchronized but is not a semaphore - please refer
getFromTableAndLock
.
key
- a unique key in the message table
null
if the key is null
or not mappedpublic Object getFromTableAndLock(Object key, Object lockIdentifier)
Offers the possibility to any class (mainly static classes to read arbitrary content identified by a unique key and lock while reading and updating an element for a special group.
Please note that when using this table, the key must be completely unique, you are strongly asked to identify the key with the application or service you are setting up.
This method is synchronized and blocks if another process tries to read the same key which is locked.
key
- A key to read and locklockIdentifier
- a special identifier for the reading process
null
if the key does not
exist - the key is not locked then.public void unlockTable(Object key, Object unlockIdentifier)
key
- A key to be unlockedunlockIdentifier
- An associated identifierpublic void putToTableAndUnlock(Object key, Object value, Object unlockIdentifier)
key
- a key for the contentvalue
- the content to be addedunlockIdentifier
- the asscoiated identifier to the blockpublic Object removeFromTable(Object key)
key
- the key of the element to be removed
public boolean addTransaction(Object channelID, int transID, Object operation)
channelID
- A channel identifier associated to the transIDtransID
- The transaction identifieroperation
- An operation identifier (@see APEX)
public Object getTransaction(Object channelID, int transID)
channelID
- A channel identifier associated to the transIDtransID
- The transaction identifier
null
if the entity/transID
combination does not existpublic Object removeTransaction(Object channelID, int transID)
channelID
- A channel identifier associated to the transIDtransID
- The transaction identifier
null
if the channel/transID
combination does not existpublic void removeAllTransactions(Object channelID)
channelID
- A channel identifier associated to be removedprotected APEXOption[] sortOptions(APEXOption[] ao)
APEXOptions
' as they are
specified in the configuration file for the services by the attribute
priority
.
ao
- An unsorted array
protected int parsePort(String p) throws APEXException
Parses a String
port number, e.g. from an XML attribute
and returns the port number as an int
if it is valid
(between 1 and 65535).
Otherwise, an 'APEXException
' is thrown.
p
- A String
port number
APEXException
- thrown if the port is not validprotected boolean validatePort(int port)
port
- The sample port number
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |