public class SocketListenerImpl extends SensitiveResource implements SocketListener, Sensitive
Modifier and Type | Field and Description |
---|---|
private boolean |
connected
Boolean flag to track connection state.
|
private character |
connectProcedure
The name of the procedure to be executed when new clients connect, if any.
|
private handle |
connectProcedureContext
The context of the procedure to be executed when new clients connect, if any.
|
private static java.util.logging.Logger |
LOG
Logger
|
private static ContextLocal<LowLevelSocketListener> |
remoteSocket
Client side network instance for handling sockets.
|
private int |
serverSocketId
The associated server socket id on P2J client side.
|
private boolean |
valid
Flag to track the valid state of this resource.
|
name, nextSibling, prevSibling
instProc
Constructor and Description |
---|
SocketListenerImpl()
Default constructor which initializes SERVER-SOCKET specific settings.
|
Modifier and Type | Method and Description |
---|---|
int |
connectEvent(long clientSocketId)
Called by the P2J client side, it will inform the server that a server event was generated.
|
logical |
disableConnections()
Java implementation for the DISABLE-CONNECTIONS() SERVER-SOCKET method.
|
logical |
enableConnections(character option)
Java implementation for the ENABLE-CONNECTION() method.
|
logical |
enableConnections(java.lang.String option)
Java implementation for the ENABLE-CONNECTION() method.
|
private void |
invokeConnectProcedure(handle socket)
Invoke the
connect procedure , as a new client has connected to
this socket. |
private java.util.Map<java.lang.String,java.lang.String> |
parseOptions(character options)
Utility method for parsing the
enableConnections(java.lang.String) parameters. |
protected boolean |
resourceDelete()
Delete the resource.
|
logical |
setConnectProcedure(character procedureName)
Java implementation for the SET-CONNECT-PROCEDURE() SERVER-SOCKET method.
|
logical |
setConnectProcedure(character procedureName,
handle procHandle)
Java implementation for the SET-CONNECT-PROCEDURE() SERVER-SOCKET method.
|
logical |
setConnectProcedure(java.lang.String procedureName)
Java implementation for the SET-CONNECT-PROCEDURE() SERVER-SOCKET method.
|
logical |
setConnectProcedure(java.lang.String procedureName,
handle procHandle)
Java implementation for the SET-CONNECT-PROCEDURE() SERVER-SOCKET method.
|
boolean |
valid()
Reports if this object is valid for use.
|
isSensitive, setSensitive, setSensitive, setSensitive, setSensitive
delete, firstResource, firstResource, getHead, getNextSibling, getNextSibling, getPrevSibling, getPrevSibling, getPrivateData, getTail, hasName, hasNameReadOnly, hasNextSibling, hasParent, hasPrevSibling, hasPrivateData, interlink, isChained, lastResource, lastResource, name, name, name, readOnlyError, setHead, setNextSibling, setNextSibling, setPrevSibling, setPrevSibling, setPrivateData, setPrivateData, setPrivateData
getResourceType, id, id, implicitDeletion, instantiatingProcedure, invalidAttribute, setInstantiatingProcedure, type, unknown
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getNextSibling, getPrevSibling, getPrivateData, setPrivateData, setPrivateData
getResourceType, readOnlyError
id, id, unknown
isSensitive, setSensitive, setSensitive, setSensitive, setSensitive
private static final java.util.logging.Logger LOG
private static final ContextLocal<LowLevelSocketListener> remoteSocket
private final character connectProcedure
private final handle connectProcedureContext
private boolean connected
private int serverSocketId
private boolean valid
public SocketListenerImpl()
public boolean valid()
valid
in interface WrappedResource
true
if we are valid (can be used).public logical enableConnections(java.lang.String option)
true
if operation succeeded,
or false
otherwise.
The following options can be specified as valid ENABLE-CONNECTIONS() options:
enableConnections
in interface SocketListener
option
- The set of options that define the enable-connections method.true
if operation succeeded, or false
otherwise.public logical enableConnections(character option)
true
if operation succeeded,
or false
otherwise.
The following options can be specified as valid ENABLE-CONNECTIONS() options:
enableConnections
in interface SocketListener
option
- The set of options that define the enable-connections method.true
if operation succeeded, or false
otherwise.public logical disableConnections()
disableConnections
in interface SocketListener
true
if the operation succeeded or false
otherwise.public logical setConnectProcedure(java.lang.String procedureName)
setConnectProcedure
in interface SocketListener
procedureName
- The name of the procedure to be executed on CONNECT event.true
if the operation was successful or false
otherwise.public logical setConnectProcedure(character procedureName)
setConnectProcedure
in interface SocketListener
procedureName
- The name of the procedure to be executed on CONNECT event.true
if the operation was successful or false
otherwise.public logical setConnectProcedure(java.lang.String procedureName, handle procHandle)
setConnectProcedure
in interface SocketListener
procedureName
- The name of the procedure to be executed on CONNECT event.procHandle
- The context where the specified procedure belongs. Validation will be performed
when the CONNECT event is executed.true
if the operation was successful or false
otherwise.public logical setConnectProcedure(character procedureName, handle procHandle)
setConnectProcedure
in interface SocketListener
procedureName
- The name of the procedure to be executed on CONNECT event.procHandle
- The context where the specified procedure belongs. Validation will be performed
when the CONNECT event is executed.true
if the operation was successful or false
otherwise.public int connectEvent(long clientSocketId)
clientSocketId
- The resource ID of the socket created for the new connected accepted by the
server socket.-1
if a event could not be
posted (i.e. the resource is not SENSITIVE).protected boolean resourceDelete()
resourceDelete
in class HandleChain
true
if the resource was deleted.private void invokeConnectProcedure(handle socket)
connect procedure
, as a new client has connected to
this socket. If connectProcedure
is unknown, this is a no-op.socket
- A handle referring the connected client socket
.private java.util.Map<java.lang.String,java.lang.String> parseOptions(character options)
enableConnections(java.lang.String)
parameters.options
- The string to parse.null
if something could not be parsed.