org.refcodes.component.Closable
, org.refcodes.component.Closable.CloseAutomaton
, org.refcodes.component.ClosedAccessor
, org.refcodes.component.Component
, org.refcodes.component.ConnectableComponent
, org.refcodes.component.ConnectableComponent.ConnectableAutomaton
, org.refcodes.component.ConnectionComponent<org.refcodes.io.DatagramTransceiver<Serializable>>
, org.refcodes.component.ConnectionComponent.ConnectionAutomaton<org.refcodes.io.DatagramTransceiver<Serializable>>
, org.refcodes.component.ConnectionOpenable<org.refcodes.io.DatagramTransceiver<Serializable>>
, org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton<org.refcodes.io.DatagramTransceiver<Serializable>>
, org.refcodes.component.ConnectionStatusAccessor
, org.refcodes.component.Destroyable
, org.refcodes.component.OpenedAccessor
, org.refcodes.mixin.BusyAccessor
, org.refcodes.mixin.Clearable
, Remote
, RemoteServer
, org.refcodes.struct.Containable
public class RemoteServerImpl extends org.refcodes.component.AbstractConnectableAutomaton implements RemoteServer
RemoteServer
's base functionality.org.refcodes.mixin.BusyAccessor.BusyMutator, org.refcodes.mixin.BusyAccessor.BusyProperty
org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
org.refcodes.component.ClosedAccessor.ClosedMutator, org.refcodes.component.ClosedAccessor.ClosedProperty
org.refcodes.component.ConnectableComponent.ConnectableAutomaton
org.refcodes.component.ConnectionComponent.ConnectionAutomaton<CON extends Object>, org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<CON extends Object,B extends org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<CON,B>>
org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton<CON extends Object>, org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<CON extends Object,B extends org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<CON,B>>
org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty
Constructor | Description |
---|---|
RemoteServerImpl() |
Instantiates a new remote server impl.
|
RemoteServerImpl(ExecutorService aExecutorService) |
Instantiates a new remote server impl.
|
Modifier and Type | Method | Description |
---|---|---|
void |
clear() |
|
void |
close() |
|
protected void |
close(CloseConnectionMessage aJob) |
Closes the
Remote upon a received CloseConnectionMessage . |
void |
destroy() |
|
void |
digest(Message aJob) |
The
digest(Message) method is invoked in order to trigger
processing of the provided Message , e.g. start execution
depending on the Message instance being provided from the
outside. |
protected void |
doSendJob(Message aJob) |
For testing purposes, any job can be manually pushed into the job process
to the receiver.
|
protected void |
fromSender(Message aJob) |
Provides an
Message from another sender to this receiver. |
protected ExecutorService |
getExecutorService() |
Hook method for retrieving the
ExecutorService . |
boolean |
hasSubject(Object obj) |
Returns true if the provided subject is contained inside this
RemoteServer . |
boolean |
isBusy() |
|
protected boolean |
isDestroyed() |
Hook to support the
Destroyable interface, determines the
destroyed status property; set to true when destroy() is called. |
boolean |
isEmpty() |
|
boolean |
isOpenable(org.refcodes.io.DatagramTransceiver<Serializable> aConnection) |
|
protected void |
onClosed() |
Hook when the connection has been closed.
|
protected void |
onOpened() |
Hook when the connection has been opened.
|
protected void |
onSubjectPublished(Object aSubject) |
Hook when a subject has been published.
|
protected void |
onSubjectSignedOff(Object aSubject) |
Hook when a subject has been signed-off.
|
void |
open(org.refcodes.io.DatagramTransceiver<Serializable> aTransceiver) |
|
boolean |
publishSubject(Object aSubject) |
Publishes an object to any
RemoteClient connected to the
RemoteServer . |
boolean |
signOffSubject(Object aSubject) |
Tries to sign off the (previously published) subject, this can be vetoed
in case the subject is still in use by a
RemoteClient . |
boolean |
signOffSubject(Object aSubject,
int aTimeoutInMs) |
Signs off the (previously published) subject, this be vetoed even in case
the subject is still in use by a
RemoteClient , but the veto will
only delay the sign off by the given timeout. |
int |
size() |
|
Iterator<Object> |
subjects() |
Returns an (immutable) iterator containing all the proxy objects
previously being published.
|
protected void |
toReceiver(Message aJob) |
Forwards an
Message from this sender to another receiver. |
getConnectionStatus, isClosable, isClosed, isOpenable, isOpened, open, setConnectionStatus
closeIn, closeQuietly, closeUnchecked
isOpenable
public RemoteServerImpl()
public RemoteServerImpl(ExecutorService aExecutorService)
aExecutorService
- the executor servicepublic void clear()
clear
in interface org.refcodes.mixin.Clearable
public void close() throws IOException
close
in interface org.refcodes.component.Closable
IOException
public boolean isBusy()
isBusy
in interface org.refcodes.mixin.BusyAccessor
public boolean hasSubject(Object obj)
RemoteServer
.hasSubject
in interface RemoteServer
obj
- The subject to be tested if it is contained inside the
RemoteServer
.RemoteServer
.public Iterator<Object> subjects()
RemoteServer.signOffSubject(Object)
method in order to remove a published subject.subjects
in interface RemoteServer
public boolean isEmpty()
isEmpty
in interface org.refcodes.struct.Containable
public boolean publishSubject(Object aSubject) throws IOException
RemoteClient
connected to the
RemoteServer
.publishSubject
in interface RemoteServer
aSubject
- A subject being published for inter-process communication
such as remote procedure calls or remote method invocations.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public boolean signOffSubject(Object aSubject) throws IOException, org.refcodes.exception.VetoException
RemoteClient
.signOffSubject
in interface RemoteServer
aSubject
- Description is currently not available!RemoteClient
threw a VetoException
then the
sign-off is aborted.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.org.refcodes.exception.VetoException
- the veto exceptionpublic boolean signOffSubject(Object aSubject, int aTimeoutInMs) throws IOException
RemoteClient
, but the veto will
only delay the sign off by the given timeout.signOffSubject
in interface RemoteServer
aSubject
- The subject to be signed off.aTimeoutInMs
- The timeout to be granted in case the sign-off has
been vetoed, nevertheless the subject will be signed off after the
timeout elapsed.RemoteClient
threw a VetoException
then the
sign-off is aborted.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public int size()
size
in interface org.refcodes.struct.Containable
public void destroy()
destroy
in interface org.refcodes.component.Destroyable
protected void doSendJob(Message aJob) throws IOException
aJob
- The job to be pushed to the receiver.IOException
- Thrown in case the operation failed due to an I/O
malfunction such as the input- or output-connection (of an input-
and output-connection pair) is not available or being
disconnected.public void digest(Message aJob) throws org.refcodes.component.DigestException
digest(Message)
method is invoked in order to trigger
processing of the provided Message
, e.g. start execution
depending on the Message
instance being provided from the
outside. A RemoteClient
digests such a Message
different
than a RemoteServer
. This method is inspired by the
Digester.digest(Object)
method.protected void close(CloseConnectionMessage aJob)
Remote
upon a received CloseConnectionMessage
.
Some client TID might be considered in order to determine whether to
close all or just one of many connections. This default implementation
calls close()
(setting the ConnectionStatus
to be
ConnectionStatus.CLOSED
); advanced implementations just closing
dedicated connections may keep the Remote
itself open (and skip
calling close()
and close only a dedicated connection identified
by the Meta-Data of the CloseConnectionMessage
.aJob
- The CloseConnectionMessage
being received for closing
the connection.protected void onSubjectPublished(Object aSubject)
aSubject
- The subject being published.protected void onSubjectSignedOff(Object aSubject)
aSubject
- The subject which has been signed-off.public boolean isOpenable(org.refcodes.io.DatagramTransceiver<Serializable> aConnection)
isOpenable
in interface org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton<org.refcodes.io.DatagramTransceiver<Serializable>>
public void open(org.refcodes.io.DatagramTransceiver<Serializable> aTransceiver) throws IOException
open
in interface org.refcodes.component.ConnectionOpenable<org.refcodes.io.DatagramTransceiver<Serializable>>
IOException
protected void toReceiver(Message aJob) throws IOException
Message
from this sender to another receiver. A
sub-class invokes this method when it sends an Message
to the
receiver counterpart. The communication path is to be implemented by the
sub-class.aJob
- the Message
to be forwarded to this receiver from the
sender counterpart.IOException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.protected void fromSender(Message aJob)
Message
from another sender to this receiver. A
sub-class invokes this method when it receives an Message
from a
sender counterpart. The communication path is to be implemented by the
sub-class.aJob
- the Message
to be forwarded to this receiver from the
sender counterpart.protected ExecutorService getExecutorService()
ExecutorService
.ExecutorService
as used by this implementation.protected boolean isDestroyed()
Destroyable
interface, determines the
destroyed status property; set to true when destroy()
is called.protected void onOpened()
protected void onClosed()
Copyright © 2021. All rights reserved.