public abstract class AbstractTransportConnector extends Object implements TransportConnector
| Modifier and Type | Class and Description |
|---|---|
static interface |
AbstractTransportConnector.AuthenticationConsumer
Consumes token authentication data.
|
| Modifier and Type | Field and Description |
|---|---|
private Map<String,List<ReceptionCallback<?>>> |
callbacks |
private TransportParameter |
params |
EMPTY_PARENT| Constructor and Description |
|---|
AbstractTransportConnector() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
applyAuthenticationKey(String authenticationKey,
AbstractTransportConnector.AuthenticationConsumer consumer)
Tries to apply the given authentication key to the given consumer.
|
void |
connect(TransportParameter params)
Connects the underlying connections.
|
void |
detachReceptionCallback(String stream,
ReceptionCallback<?> callback)
Detaches a reception
callback to stream. |
void |
disconnect()
Disconnects the underlying connections.
|
protected int |
getActionTimeout()
Returns the timeout for individual send/receive actions.
|
protected String |
getApplicationId()
The unique application/client identifier.
|
static String |
getApplicationId(String applicationId,
String infix,
boolean makeUnique)
Creates a unique application/client identifier.
|
protected List<ReceptionCallback<?>> |
getCallback(String stream)
The callback for a certain stream.
|
protected TransportParameter.CloseAction |
getCloseAction()
Returns the close action.
|
static String |
getKeystorePassword(String keystorePassword)
Tries to resolve
keystorePassword as key in IdentityStore using
token data of a username token if found or keystorePassword as fallback. |
static String |
getKeystorePassword(TransportParameter params)
Tries to resolve
TransportParameter.getKeystorePassword() as key in IdentityStore using
token data of a username token if found or TransportParameter.getKeystorePassword() as fallback. |
protected TransportParameter |
getTransportParameter()
Returns the transport parameters.
|
protected boolean |
isStreamKnown(String stream)
Returns whether a
stream name exists, irrespective of a registered callback. |
protected <T> void |
notifyCallback(String stream,
byte[] data)
Notifies the callback in
stream based on received serialized
data. |
protected void |
registerStream(String stream)
Registers a
stream name without callback. |
protected <T> byte[] |
serialize(String stream,
T data)
Serializes
data to stream. |
void |
setReceptionCallback(String stream,
ReceptionCallback<?> callback)
Attaches a reception
callback to stream. |
void |
unsubscribe(String stream,
boolean delete)
Unsubscribes from a channel implicitly subscribed with
TransportConnector.setReceptionCallback(String, ReceptionCallback). |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitasyncSend, composeStreamName, enabledEncryption, getName, supportedEncryption, syncSendprivate Map<String,List<ReceptionCallback<?>>> callbacks
private TransportParameter params
public static String getKeystorePassword(TransportParameter params)
TransportParameter.getKeystorePassword() as key in IdentityStore using
token data of a username token if found or TransportParameter.getKeystorePassword() as fallback.params - the transport parameter to return the keystore password forIdentityStore or as fallback from paramspublic static String getKeystorePassword(String keystorePassword)
keystorePassword as key in IdentityStore using
token data of a username token if found or keystorePassword as fallback.keystorePassword - the transport parameter to return the keystore password forIdentityStore or as fallback from paramspublic static boolean applyAuthenticationKey(String authenticationKey, AbstractTransportConnector.AuthenticationConsumer consumer)
authenticationKey - the authentication keyconsumer - the consumertrue for applied, false for ignored/failedpublic void setReceptionCallback(String stream, ReceptionCallback<?> callback) throws IOException
TransportConnectorcallback to stream. The callback
is called upon a reception. Implicitly subscribes to channel.setReceptionCallback in interface TransportConnectorstream - the stream to attach the reception tocallback - the callback to attachIOException - in case that problems during registering the callback
(e.g., during subscription) happenspublic void detachReceptionCallback(String stream, ReceptionCallback<?> callback) throws IOException
TransportConnectorcallback to stream.detachReceptionCallback in interface TransportConnectorstream - the stream to detach the reception callback fromcallback - the callback to detachIOException - in case that problems during detaching the callbackpublic void connect(TransportParameter params) throws IOException
TransportConnectorconnect in interface TransportConnectorparams - the parameters to start the underlying connectionIOException - in case that problems during the connection happenspublic void unsubscribe(String stream, boolean delete) throws IOException
TransportConnectorTransportConnector.setReceptionCallback(String, ReceptionCallback).unsubscribe in interface TransportConnectorstream - the stream to unsubscribe fromdelete - if true, try to delete/clean up the communication side on the server (may not be supported
by the implementing connector, is ignored then)IOException - if the action fails for some reasonpublic void disconnect()
throws IOException
TransportConnectorUnsubscribes on all known
subscribed depending on
TransportParameter.getCloseAction().disconnect in interface TransportConnectorIOException - in case that problems during the disconnect happensprotected TransportParameter getTransportParameter()
protected int getActionTimeout()
protected TransportParameter.CloseAction getCloseAction()
protected String getApplicationId()
TransportParameter.getApplicationId() and
TransportParameter.getAutoApplicationId().public static String getApplicationId(String applicationId, String infix, boolean makeUnique)
applicationId - the basic application id (may be null, turned to an empty string then)infix - an optional infix to be appended to applicationId (may be null,
turned to an empty string then)makeUnique - make unique or just compose given informationprotected List<ReceptionCallback<?>> getCallback(String stream)
stream - the stream to return the callback forprotected void registerStream(String stream)
stream name without callback. A callback may be registered later.stream - the name of the streamprotected boolean isStreamKnown(String stream)
stream name exists, irrespective of a registered callback.stream - the stream name to look fortrue if the stream is known, false elseprotected <T> void notifyCallback(String stream, byte[] data)
stream based on received serialized
data.T - the type of datastream - the stream to notify the callback fordata - the received serialized dataprotected <T> byte[] serialize(String stream, T data) throws IOException
data to stream. [helper]T - the type of the datastream - the stream to serialize todata - the data to serializeIOException - in case that problems occur during serializationCopyright © 2022. All rights reserved.