|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
A client's active network connection to its Message Service Provider.
A Connection object encapsulates an open connection
with a MessageServiceProvider. The open connection is designed to
be protocol independent however, typically it is a TCP/IP socket.
In addition, the Connection object is a factory for creating
both MessageSender and MessageReceiver
objects. The Connection object is responsible for authenticating
itself with the server that it is connecting to.
The Connection object has a finite state attached to it.
State Chart:
Connection object has been created and
several objects required by the Connection have been
instantiated
Connection object has created and initiated
all of its threads that are required for operation.
Connection object has been
authenticated by the "Authenticating Authority"
Connection object has been
checked and approved by the "Access Control Authority"
Connection object has sent to the other side
a KILL packet to initiate the closure of the Connection
Connection object's threads have all been
stopped and destroyed.
Connection object's recycle method has
been called and all objects have been cleaned up and readied for the garbage
collector
State Transitions Allowed:
| Method Summary | |
void |
addConnectionEventListener(ConnectionEventListener listener)
Add a ConnectionEventListener to this connection. |
void |
authenticate(String type,
Object principal,
Object credential,
int timeout)
Authenticate the Connection This method will send a Packet message to the Server side to authenticate the usage of this Connection with the system. |
void |
checkAccess(int timeout)
Check the Connection's access This method will send a Packet message to the Server side to check access on the Connection with the system.
|
void |
close()
Closes the Connection. |
MessageReceiver |
createMessageReceiver(String contentType)
Create a generic MessageReceiver on the Connection. |
MessageSender |
createMessageSender(String contentType)
Create a MessageSender on the Connection. |
void |
destroy()
Destroy the Connection This method will recycle the Connection |
ConnectionMetaData |
getConnectionMetaData()
Get the ConnectionMetaData object This object will contain all pertinant meta data about the Connection Object |
ConnectionStatus |
getStatus()
Get the status of the Connection |
void |
removeConnectionEventListener(ConnectionEventListener listener)
Remove a ConnectionEventListener from this connection. |
void |
sendMessageToReceiver(Message message)
Sends a message to a remote MessageReceiver. |
void |
sendMessageToReceiver(Message message,
RemoteEndPoint receiver)
Sends a message to the specified remote MessageReceiver EndPoint. |
void |
start()
Start the Connection. |
| Methods inherited from interface com.cafesoft.core.lifecycle.LifecycleListener |
lifecycleEvent |
| Methods inherited from interface com.cafesoft.core.util.Recyclable |
recycle |
| Method Detail |
public void start()
throws MessageServiceException,
IllegalConnectionStateException
Once started the Connection object can be used to send "low" level messages to the connecting side. No "high" level Message Framework objects such as MessageSenders and MessageReceivers can be created or used.
MessageServiceException - thrown if Connection
unable to connect with the message server
IllegalConnectionStateException - thrown if the
Connection object is in ANY state other than the CREATED
state.
public void close()
throws MessageServiceException,
IllegalConnectionStateException
This method signifies the "graceful" closure of a Connection
object. It gives the Connection object a chance to
instantiate a shutdown protocol. In addition, this method will change the
state of the Connection to that of CLOSED. This will make
the usage of MessageSenders and MessageReceivers useless.
MessageServiceException - if the Message Provider fails to
close the connection due to some internal error. For example, a failure
to release resources or to close the socket associated with the
Connection.
IllegalConnectionStateException - thrown if the
Connection object is in any state other than the STARTED
or READY state.
public void destroy()
throws IllegalConnectionStateException
This method will recycle the
Connection object and will
invoke recycle on all objects used by the Connection
object
IllegalConnectionStateException - thrown if the
Connection object is in any state other than the CREATED
or STOPPED.
public void authenticate(String type,
Object principal,
Object credential,
int timeout)
throws MessageServiceException,
IllegalConnectionStateException,
ConnectionAuthenticationException
This method will send a Packet message to the Server side to authenticate
the usage of this Connection with the system. This method
can only be called once and is a one-time try. If authentication fails
the Connection will be closed.
type - the type of authentication the server side should performprincipal - the Principal objectcredential - the Credential objecttimeout - the length in seconds to wait before declaring
authentication failed
IllegalConnectionStateException - thrown if the
Connection object is in any state other than STARTED
MessageServiceException - thrown if there is an error trying
to use the Message Framework to send the Authentication packet
ConnectionAuthenticationException - thrown if the client
trying to authenticate does not get a response back from the server
within the given timeout period
public void checkAccess(int timeout)
throws MessageServiceException,
IllegalConnectionStateException,
ConnectionAccessException
This method will send a Packet message to the Server side to
check access on the Connection with the system.
This method can only be called once and is a one-time try. If
access fails the Connection will be closed.
timeout - the length of time for which the Connection
object should wait before timing out and abort checking
access on the Connection
MessageServiceException - thrown if an error occurs with the Message Framework
that prevents the access check from being performed.
IllegalConnectionStateException - thrown if the Connection Object is not in
the proper state to perform an access check
ConnectionAccessException - thrown if the client does not receive a response from
the server within the given timeout periodpublic ConnectionStatus getStatus()
Connectionpublic ConnectionMetaData getConnectionMetaData()
This object will contain all pertinant meta data about the Connection Object
public void addConnectionEventListener(ConnectionEventListener listener)
listener - The listener to addpublic void removeConnectionEventListener(ConnectionEventListener listener)
listener - The listener to remove
public MessageSender createMessageSender(String contentType)
throws MessageServiceException,
IllegalConnectionStateException
contentType - the content type for the messages that the
MessageSender will send.
MessageServiceException - if an error while attempting to
create the MessageSender
IllegalConnectionStateException - thrown if the
Connection object is in any state other than READY
public MessageReceiver createMessageReceiver(String contentType)
throws MessageServiceException,
IllegalConnectionStateException
contentType - the content type for the messages that the
MessageReceiver will receive
MessageServiceException - if an error while attempting to
create the MessageReceiver
IllegalConnectionStateException - thrown if the
Connection object is in any state other than READY
public void sendMessageToReceiver(Message message)
throws MessageServiceException,
IllegalConnectionStateException
The message is asynchronously sent to a MessageReceiver specified by setting the receiver id message header.
message - the message to send
MessageServiceException - if the Connection fails to send the
message due to some internal error or if an invalid Message or receiver
id is specified
IllegalConnectionStateException - thrown if the
Connection object is in any state other than READY
public void sendMessageToReceiver(Message message,
RemoteEndPoint receiver)
throws MessageServiceException,
IllegalConnectionStateException
The message is asynchronously sent to a MessageReceiver specified by the RemoteEndPoint.
message - the message to sendreceiver - the remote MessageReceiver endpoint
MessageServiceException - the Connection fails to send the
message due to some internal error or if an invalid Message or receiver
id is specified
IllegalConnectionStateException - thrown if the
Connection object is in any state other than READY
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||