next up previous contents
Next: Examples Up: Library usage Previous: MessageListener interface   Contents

Connector object

Figure 3.3: Connector object
\includegraphics{images/java_connector.eps}

Connector object is a singletone class used for the connection between the application (client) and the OPENMAIA server. The object must be instantiated once and than it is accessible application wide via its static methods.

The list of public method is reported here:

-static Connector creatInstance(String host, int port)
throws Exception
Create a new instance of Connector that will connect to the server on host:port. A reference to the created instance is retured by the method. If an instance alread exists an Exception is thrown.


-static Connector getInstance()
Return the instance of Connector or null if the object has not been yet instantiated with createInstance.


-static destroyInstance()
Destroy the current instance of Connector object.


-static sendMessage(Message m)
throws Excepiton
Send the message m to the OPENMAIA server. An Exception is thrown if the connection with the server has not been established.


-connect()
throws UnknownHostException, IOException
Connect to the OPENMAIA server. Throws UnknownHostException if hostname is unknown or IOException if there are problems in communication.


-isConnected()
Return true if the Connector object is connected to the OPENMAIA server, false if not.


-disconnect()
throws Exception, IOException
Disconnect from the OPENMAIA server. Throws an Exception if the connection has already been closed, IOException if there are problems in communication.


-setListener(MessageListener l, Object o)
Set the listener that will receive incoming messages. Connector will listen for incoming messages only if the listener thread is started with startListener() metohd. The generic object o is a user-defined object that will be passed to the MessageListener when an incoming message is arrived. The parameter o is not mandatory, it can be null.


-startListener()
Start the listener thread.


-stopListener()
Stop the listener thread.



Subsections
next up previous contents
Next: Examples Up: Library usage Previous: MessageListener interface   Contents
2005-07-12