public class RemoteClientImpl extends org.refcodes.component.AbstractConnectableAutomaton implements RemoteClient
RemoteClient
's base functionality.RemoteClient.ProxyControl
org.refcodes.component.Destroyable.DestroyAutomaton
org.refcodes.component.ConnectableComponent.ConnectableAutomaton
org.refcodes.component.ConnectionComponent.ConnectionAutomaton<CON>, org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<CON,B extends org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<CON,B>>
org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton<CON>, org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<CON,B extends org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<CON,B>>
org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty
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
Constructor and Description |
---|
RemoteClientImpl()
Instantiates a new remote client impl.
|
RemoteClientImpl(ExecutorService aExecutorService)
Instantiates a new remote client impl.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
close() |
protected void |
close(CloseConnectionMessage aJob)
Closes the
Remote upon a received CloseConnectionMessage . |
void |
destroy() |
protected 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 . |
<T> T |
getProxy(Class<T> aType)
Gets the proxy.
|
boolean |
hasProxy(Class<?> aType)
Returns true if there is at least one proxy of the given type.
|
boolean |
hasProxy(Object proxy)
Returns true if the provided proxy is contained inside the
RemoteClient . |
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 |
onProxyPublished(Object aProxy)
Hook when a proxy has been published.
|
protected void |
onProxySignedOff(Object aProxy)
Hook when a proxy has been signed-off.
|
protected void |
onPublishProxy(Class<?> aType)
Hook when a proxy is about to be published.
|
void |
open(org.refcodes.io.DatagramTransceiver<Serializable> aTransceiver) |
Iterator<Object> |
proxies()
Returns a read-only iterator containing all the proxy objects previously
being published.
|
boolean |
signOffProxy(Object aProxy)
Signs off an instance previously published using the
publishClassDescriptor() method.
|
int |
size() |
protected void |
toReceiver(Message aJob)
Forwards an
Message from this sender to another receiver. |
getConnectionStatus, isClosable, isClosed, isOpenable, isOpened, open, setConnectionStatus
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isOpenable
public RemoteClientImpl()
public RemoteClientImpl(ExecutorService aExecutorService)
aExecutorService
- the a executor servicepublic void clear()
clear
in interface org.refcodes.structure.Clearable
public void close()
close
in interface org.refcodes.component.Closable
public boolean isBusy()
isBusy
in interface org.refcodes.mixin.BusyAccessor
public boolean hasProxy(Object proxy)
RemoteClient
.hasProxy
in interface RemoteClient
proxy
- The proxy to be tested if it is contained inside the
RemoteClient
.RemoteClient
.public <T> T getProxy(Class<T> aType) throws AmbiguousProxyException, NoSuchProxyException
getProxy
in interface RemoteClient
T
- the generic typeaType
- the a typeAmbiguousProxyException
- the ambiguous proxy exceptionNoSuchProxyException
- the no such proxy exceptionpublic boolean hasProxy(Class<?> aType)
hasProxy
in interface RemoteClient
aType
- the a typepublic Iterator<Object> proxies()
proxies
in interface RemoteClient
public boolean isEmpty()
isEmpty
in interface org.refcodes.structure.Containable
public boolean signOffProxy(Object aProxy) throws org.refcodes.component.OpenException
signOffProxy
in interface RemoteClient
aProxy
- An object of type GenericInstanceDescriptor containing the
information needed to sign-off an instance.org.refcodes.component.OpenException
- Thrown in case opening or accessing an open line
(connection, junction, link) caused problems.public int size()
size
in interface org.refcodes.structure.Containable
public void destroy()
destroy
in interface org.refcodes.component.Destroyable
protected void doSendJob(Message aJob) throws org.refcodes.component.OpenException
aJob
- The job to be pushed to the receiver.org.refcodes.component.OpenException
- 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.protected 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 ID 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 onPublishProxy(Class<?> aType) throws org.refcodes.exception.VetoException
aType
- The type to be stored by the property.org.refcodes.exception.VetoException
- Thrown to signal that an operation is being vetoed
by a third party observing the invocation of the given operation.protected void onProxyPublished(Object aProxy)
aProxy
- The proxy to being published.protected void onProxySignedOff(Object aProxy)
aProxy
- The proxy 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 org.refcodes.component.OpenException
open
in interface org.refcodes.component.ConnectionOpenable<org.refcodes.io.DatagramTransceiver<Serializable>>
org.refcodes.component.OpenException
protected void toReceiver(Message aJob) throws org.refcodes.component.OpenException
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.org.refcodes.component.OpenException
- 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()
DatagramTransceiver
is being supported by a sub-class, then the
DatagramTransceiver
's OpenEvent
can be used to trigger
this method.protected void onClosed()
Copyright © 2017. All rights reserved.