|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neeve.root.RootObject
com.neeve.link.LnkObject
com.neeve.link.LnkContinuousAcceptor
public class LnkContinuousAcceptor
Class that continuously retries link acceptance until a failure or stopped.
This class continuously attempts to accept link connections until a failure
is encountered or it is stopped by the user. The user provides the link
descriptor and associated information needed for link acceptance at creation
time. The user then starts the acceptor via start(com.neeve.emx.IEmxDispatcher)
. Accepted links
are dispatched to the user via a provided event handler until either
the accept operation encounters an error or the user stops the acceptor.
An event dispatched to the user indicating an unsuccessful accept (whether
that be due to an error or due to stoppage by the user) indicates that
the acceptor has stopped accepting additional links.
LnkContinuousAcceptor.State
enumerates the various states that a acceptor can be in.
The user can use the getState()
method to query the state of an
acceptor. Refer to the method documentation for the states in which
the methods can be invoked.
Nested Class Summary | |
---|---|
static class |
LnkContinuousAcceptor.State
States of a acceptor. |
Method Summary | |
---|---|
static LnkContinuousAcceptor |
create(RootConfig.ObjectConfig config,
String descriptor,
ILnkEventHandler userHandler)
Create a continuous link acceptor. |
static LnkContinuousAcceptor |
create(RootConfig.ObjectConfig config,
com.neeve.util.UtlAddressDescriptor descriptor,
ILnkEventHandler userHandler)
Create a continuous link acceptor. |
LnkContinuousAcceptor.State |
getState()
Get the current state of the acceptor. |
void |
start(IEmxDispatcher dispatcher)
Start the acceptor. |
void |
stop()
Stop the acceptor. |
Methods inherited from class com.neeve.root.RootObject |
---|
getChecked, getThreaded, getTracer, setChecked, setTracer |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static LnkContinuousAcceptor create(RootConfig.ObjectConfig config, com.neeve.util.UtlAddressDescriptor descriptor, ILnkEventHandler userHandler)
config
- The package configuration object to use in the creation
of this object. The allows the parameters used to configure the package
that is using this class to be automatically applied to this object
too.descriptor
- The descriptor to use to accept incoming links.userHandler
- The handler to which the completion events will be
dispatched.
public static LnkContinuousAcceptor create(RootConfig.ObjectConfig config, String descriptor, ILnkEventHandler userHandler)
config
- The package configuration object to use in the creation
of this object. The allows the parameters used to configure the package
that is using this class to be automatically applied to this object
too.descriptor
- The descriptor to use to accept incoming links.userHandler
- The handler to which the completion events will be
dispatched.
public final void start(IEmxDispatcher dispatcher) throws ELnkInvalidStateException, ELnkNotOwnerException, ELnkOpFailedException
dispatcher
- The dispatcher in whose context the accept should
be run. The caller is responsible for driving this dispatcher upon
return from this method until the completion event is dispatched.
ELnkInvalidStateException
- Thrown in case the acceptor is not
in the LnkContinuousAcceptor.State.STOPPED
state.
ELnkNotOwnerException
- Thrown in case the calling thread is not
the owner of the provided dispatcher.
ELnkOpFailedException
- Thrown in case the acceptor could not
be started.
This method kicks off the link acceptance. The user will be dispatched
an LnkEvents.EVENT_CONTINUOUS_ACCEPT_COMPLETE
event for each
link successfully accepted by the acceptor. This will continue till
an error occurs or the user issues a stop()
call at which point
the user will be dispatched one last event containing an exception. That
event is the indication that the acceptor has stopped accepting any
more links.
public final LnkContinuousAcceptor.State getState()
public final void stop() throws ELnkInvalidStateException, ELnkOpFailedException
ELnkInvalidStateException
- Thrown in case the acceptor is not
in the LnkContinuousAcceptor.State.STARTED
state.
ELnkOpFailedException
- Thrown in case the a stop could not be
scheduled on the acceptor.
This method schedules a stop on a started acceptor. It does so by
setting the state of the acceptor to LnkContinuousAcceptor.State.STOPPING
. At the
time this method is invoked, the acceptor has an accept pending with
a timeout. When the accept completes (either due to a successful
accept or timeout), the state will indicate that the accept should
not be reposted and the user be dispatched a cancellation event i.e.
LnkEvents.EVENT_CONTINUOUS_ACCEPT_COMPLETE
with the event data
containing a ELnkOpCancelledException
. The user should note
that, in case a link is accepted between the time this method was
invoked and the scheduled timeout of the accept call, the user will
receive the accepted link followed by a cancellation event.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |