|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfulmine.AbstractLifeCycle
fulmine.distribution.connection.tcp.TcpConnectionParameters
fulmine.distribution.connection.tcp.AbstractSocketChannelConnection
public abstract class AbstractSocketChannelConnection
A SocketChannel connection to a remote IFrameworkContext
instance. This uses the Java NIO framework.
| Field Summary | |
|---|---|
protected boolean |
destroyWhenMessagesProcessed
A flag to inform the MessageConsumedEventHandler that the
connection should be destroyed when all messages have been consumed. |
protected IEventSource |
eventSourceDelegate
The delegate for the IEventSource operations of this |
protected int |
messagesToProcess
Tracks the number of messages received and not yet processed. |
| Constructor Summary | |
|---|---|
AbstractSocketChannelConnection(IFrameworkContext context,
String identity,
String address,
int port,
int connectionHashCode)
Standard constructor for the parameters of the connection. |
|
| Method Summary | |
|---|---|
void |
addEvent(IEvent event)
Add the event to the source and notify any registered IEventListener instances with the event. |
boolean |
addListener(IEventListener listener)
Add the listener to the end of the list of listeners registered against this. |
protected void |
connectionHandshakeComplete()
This method is called when all relevant details of the connection have been established. |
protected void |
doComponentDestroy()
|
protected void |
doDestroy()
Destroy the internal TCP I/O components. |
protected void |
doStart()
Overridden in subclasses to perform custom logic on activation. |
protected IFrameworkContext |
getContext()
|
byte |
getEventSourceGroupId()
A byte identifying the event source group id. |
List<IEventListener> |
getListeners()
Get the list of IEventListener instances observing this. |
protected SocketChannel |
getSocketChannel()
|
boolean |
isConnected()
|
protected boolean |
isConnectionHandshakeComplete()
Determine if the application level connection handshake has been established. |
boolean |
isOutbound()
Indicates the connecting direction. |
boolean |
removeListener(IEventListener listener)
Remove the listener from the list of listeners registered against this. |
List<IEventListener> |
removeListeners()
Remove all listeners registered for receiving IEvent events
originating from this. |
String |
toDetailedString()
Provides a formatted string describing this object in detail. |
String |
toIdentityString()
Get a string that provides the identification for this object. |
String |
toString()
|
| Methods inherited from class fulmine.distribution.connection.tcp.TcpConnectionParameters |
|---|
equals, getAddress, getDomain, getIdentity, getRemoteContextHashCode, getRemoteContextIdentity, getRemoteHostAddress, getRemoteHostTcpPort, getType, hashCode, isEqual, setIdentity, setRemoteContextHashCode |
| Methods inherited from class fulmine.AbstractLifeCycle |
|---|
checkActive, destroy, finalize, getLog, isActive, start |
| Methods inherited from class java.lang.Object |
|---|
clone, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface fulmine.distribution.connection.IConnection |
|---|
send |
| Methods inherited from interface fulmine.ILifeCycle |
|---|
isActive, start |
| Methods inherited from interface fulmine.IDestroyable |
|---|
destroy |
| Methods inherited from interface fulmine.IAddressable |
|---|
getAddress, getDomain, getIdentity, getType |
| Methods inherited from interface fulmine.distribution.connection.IConnectionParameters |
|---|
getRemoteContextHashCode, getRemoteContextIdentity, isEqual |
| Field Detail |
|---|
protected IEventSource eventSourceDelegate
IEventSource operations of this
protected volatile boolean destroyWhenMessagesProcessed
MessageConsumedEventHandler that the
connection should be destroyed when all messages have been consumed.
messagesToProcessprotected int messagesToProcess
MessageConsumedEvent is raised that is
intercepted by the MessageConsumedEventHandler which decrements
this.
Access must be synchronized on the
AbstractSocketChannelConnection instance.
| Constructor Detail |
|---|
public AbstractSocketChannelConnection(IFrameworkContext context,
String identity,
String address,
int port,
int connectionHashCode)
context - the context this connection servicesidentity - the connection identityaddress - the IP address or resolvable host name of the remote contextport - the port for the socket connection to the remote contextconnectionHashCode - the hashcode of the connection to the remote context
IllegalStateException - if the socket could not be constructed| Method Detail |
|---|
protected void doComponentDestroy()
protected IFrameworkContext getContext()
protected void doStart()
AbstractLifeCycleRuntimeException or subclass
thereof. When this method is called, the AbstractLifeCycle.isActive() method will
return true.
doStart in class TcpConnectionParameterspublic boolean isConnected()
public boolean isOutbound()
isOutbound in interface IConnectiontrue if this socket connects to a server socket,
false if it was an inbound connection from another
contextprotected void doDestroy()
doDestroy in class TcpConnectionParameterspublic void addEvent(IEvent event)
IEventSourceIEventListener instances with the event. The manner of activating
listeners with the event may be synchronous or asynchronous; it is the
implementation that decides this.
addEvent in interface IEventSourceevent - the event to pass on to the registered listenerspublic boolean addListener(IEventListener listener)
IEventSourceIPriorityEventListener, it is added
to the beginning of the list.
Listeners are reference counted. Adding the same listener multiple times simply increments a reference count of the listener instance; if a listener is added twice, it must be removed twice for the listener instance reference to be removed from the internal list.
addListener in interface IEventSourcelistener - the listener to add
true if the listener instance was added (there were
no reference counts for it), false if it already
existed (the reference count was incremented)public byte getEventSourceGroupId()
IEventSourceEventProcessor that will distribute the events from this source.
getEventSourceGroupId in interface IEventSourceEventProcessor servicing this.public List<IEventListener> getListeners()
IEventSourceIEventListener instances observing this. The list
is the order of registration and the notification order for any
IEvent raised by this event source.
The list is not modifiable.
getListeners in interface IEventSourcenull if
there are no listenerspublic boolean removeListener(IEventListener listener)
IEventSourcenull.
Listeners are reference counted. When removing a listener, this method decrements the reference count until there are no more references, at which point the listener instance reference is actually removed.
removeListener in interface IEventSourcelistener - the listener to remove
true if the listener was found and the reference
count was 0 and it was removed, false otherwisepublic List<IEventListener> removeListeners()
IEventSourceIEvent events
originating from this.
removeListeners in interface IEventSourcepublic String toDetailedString()
IDescriptorObject.toString()
method.
toDetailedString in interface IDescriptorpublic String toIdentityString()
IDescriptorObject.toString() method.
toIdentityString in interface IDescriptorprotected SocketChannel getSocketChannel()
protected boolean isConnectionHandshakeComplete()
Each context marks its end of the connection as established as per the following;
true if the connection handshake has been completed
and the details about the remote context are known.protected void connectionHandshakeComplete()
isConnectionHandshakeComplete()public String toString()
toString in class TcpConnectionParameters
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||