com.neeve.link
Class LnkServerEndpoint

java.lang.Object
  extended by com.neeve.root.RootObject
      extended by com.neeve.link.LnkObject
          extended by com.neeve.link.LnkServerEndpoint
All Implemented Interfaces:
ILnkEndpoint, ILnkServerEndpoint

public final class LnkServerEndpoint
extends LnkObject
implements ILnkServerEndpoint

Server endpoint class.

This class implements the ILnkServerEndpoint interface. Internally, this class implements a portion that is common to all server endpoint implementations and a portion that is link type specific. The class abstracts link type specific implementations via the ILnkServerEndpointCore interface. At endpoint creation time, link type specific implementations wrap an instance of this class around the actual implementation and return the wrapped class to the user as ILnkServerEndpoint.


Field Summary
 
Fields inherited from interface com.neeve.link.ILnkEndpoint
IOFLAG_FLUSH_FORCE, IOFLAG_FLUSH_SUPPRESS, IOFLAG_IMMEDIATE_DISPATCH, IOFLAG_NO_ASYNC, LVFLAG_ALLOW_FLUSH_PENDING, LVFLAG_SUPPRESS_IMPLICT_CLOSE
 
Method Summary
 void acceptCancel(int flags)
          Implementation of ILnkServerEndpoint.acceptCancel(int)
 void acceptPost(IEmxDispatcher dispatcher, ILnkEventHandler handler, int timeout, int flags)
          Implementation of ILnkServerEndpoint.acceptPost(com.neeve.emx.IEmxDispatcher, com.neeve.link.ILnkEventHandler, int, int)
 void close()
          Implementation of ILnkServerEndpoint.close()
static ILnkServerEndpoint create(RootConfig.ObjectConfig config, ILnkServerEndpointCore sep)
          Create a link server endpoint
 
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

create

public static ILnkServerEndpoint create(RootConfig.ObjectConfig config,
                                        ILnkServerEndpointCore sep)
Create a link server endpoint

Parameters:
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.
sep - The link server endpoint implementation to wrap around.

acceptPost

public final void acceptPost(IEmxDispatcher dispatcher,
                             ILnkEventHandler handler,
                             int timeout,
                             int flags)
                      throws ELnkInvalidStateException,
                             ELnkNotOwnerException,
                             ELnkOpFailedException
Implementation of ILnkServerEndpoint.acceptPost(com.neeve.emx.IEmxDispatcher, com.neeve.link.ILnkEventHandler, int, int)

Specified by:
acceptPost in interface ILnkServerEndpoint
Parameters:
dispatcher - The dispatcher in whose context the accept completion event will be dispatched. It is required that the invoking thread be the owner of this dispatcher.
handler - The event handler that will receive the completion event.
timeout - The maximum time (in milliseconds) to wait for an incoming link connection establishment request. If no connection request is received within the specified time, the connection acceptance is aborted and a completion event is dispatched with an exception indicating a timeout. A value of 0 indicates that there is no time limit in accepting connection requests.
flags - Flags that qualify the accept operation. The following flags are permitted for use in this method:
- ILnkEndpoint.IOFLAG_IMMEDIATE_DISPATCH
- ILnkEndpoint.IOFLAG_NO_ASYNC
Throws:
ELnkInvalidStateException - This exception is thrown in case there is an accept is currently in progress.
ELnkNotOwnerException - Thrown in case this method is invoked by a thread that is not the owner of the specified dispatcher.
ELnkOpFailedException - This exception is thrown in case the listening for incoming connection requests could not be successfully initiated.

This method initiates the acceptance of an incoming link connection request. A successful return from this method indicates that the accept operation has been successfully initiated. The operation will continue asynchronously in the background driven by the specified dispatcher. It is the responsibility of the caller to drive the dispatcher subsequent to return from this method. Upon completion of the accept, the completion status will be notified to the caller via the an accept completion event (LnkEvents.EVENT_ACCEPT_COMPLETE) dispatched to the specified handler. The handler will always be invoked by the owner thread of the specified dispatcher. A failure (i.e. an exception thrown by the method) indicates that the accept operation could not be successfully initiated. A completion event is not dispatched if this method returns with an exception.

Upon completion of the accept operation, the user can repost the accept in case additional connection requests are to be accepted. It is permissible to repost from within the completion event handler.

The execution of this method can be qualified through the specification of certain flags in the flags parameter. Refer to the documentation of the permissible flags for a description of how those flags qualify the behaviour of this method.

In case the user has requested for immediate dispatch of the completion event, it is possible for the completion handler to be invoked with a completion event indicating a failure before this method returns.

See Also:
ILnkServerEndpoint.acceptCancel(int)

acceptCancel

public final void acceptCancel(int flags)
                        throws ELnkInvalidStateException,
                               ELnkNotOwnerException
Implementation of ILnkServerEndpoint.acceptCancel(int)

Specified by:
acceptCancel in interface ILnkServerEndpoint
Parameters:
flags - Flags that qualify the accept cancellation operation. Currently, there are no supported flags for use. This parameter is present for future use. The user should specify a value of 0 in this parameter.
Throws:
ELnkInvalidStateException - This exception is thrown in case the user is attempting a cancellation of an accept that was not initiated.
ELnkNotOwnerException - Thrown in case this method is invoked by a thread that is not the owner of the dispatcher specified in the earlier call to ILnkServerEndpoint.acceptPost(com.neeve.emx.IEmxDispatcher, com.neeve.link.ILnkEventHandler, int, int).

This method cancels a previously posted accept operation. A successful return from this method indicates that the accept operation has been cancelled. The user will be dispatched an accept completion event containing an exception indicating that the accept operation was cancelled by the user.

See Also:
ILnkServerEndpoint.acceptPost(com.neeve.emx.IEmxDispatcher, com.neeve.link.ILnkEventHandler, int, int)

close

public final void close()
                 throws ELnkInvalidStateException,
                        ELnkNotOwnerException,
                        ELnkOpFailedException
Implementation of ILnkServerEndpoint.close()

Specified by:
close in interface ILnkServerEndpoint
Throws:
ELnkInvalidStateException - This exception is thrown in case the user is attempting to close an endpoint that has an accept currently in progress in the background.
ELnkNotOwnerException - Thrown in case an accept is currently in progress and this method is invoked by a thread that is not the owner of the dispatcher that is driving the accept operation.
ELnkOpFailedException - This exception is thrown in case an error was encountered while closing the server endpoint.

This method is used to close a server endpoint and release all underlying system resources allocated to the server endpoint. A user would invoke this method upon being done with accepting incoming connect requests and prior to releasing the endpoint for garbage collection. It is illegal to post an accept on a closed endpoint.



Copyright © 2015 Neeve Research, LLC. All Rights Reserved.