@StampyLibrary(libraryName="stampy-client-server") public abstract class AbstractStampyMessageGateway extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Queue<StampyOutgoingMessageInterceptor> |
interceptors
The interceptors.
|
protected java.util.Queue<StampyOutgoingTextInterceptor> |
textInterceptors
The text interceptors.
|
| Constructor and Description |
|---|
AbstractStampyMessageGateway() |
| Modifier and Type | Method and Description |
|---|---|
void |
addMessageListener(StampyMessageListener listener)
Adds the message listener.
|
void |
addMessageListener(StampyMessageListener listener,
int idx) |
void |
addOutgoingMessageInterceptor(StampyOutgoingMessageInterceptor interceptor)
Adds the specified outgoing message interceptor.
|
void |
addOutgoingTextInterceptor(StampyOutgoingTextInterceptor interceptor)
Adds the specified outgoing message interceptor.
|
void |
broadcastMessage(StampyMessage<?> message)
Broadcasts a
StampyMessage to all connected clients from the server
or to the server from a client. |
abstract void |
broadcastMessage(java.lang.String stompMessage)
Broadcasts the specified String to all connections.
|
void |
clearMessageListeners()
Clear message listeners.
|
abstract void |
closeConnection(HostPort hostPort)
Closes the connection to the STOMP server or client.
|
abstract void |
connect()
Connects to a STOMP server or client as specified by configuration.
|
abstract java.util.Set<HostPort> |
getConnectedHostPorts()
Gets the connected host ports.
|
int |
getHeartbeat()
Gets the heartbeat.
|
int |
getMaxMessageSize() |
int |
getPort() |
UnparseableMessageHandler |
getUnparseableMessageHandler()
Returns the
UnparseableMessageHandler, defaults to. |
protected void |
interceptOutgoingMessage(StampyMessage<?> message)
Intercept outgoing message.
|
protected void |
interceptOutgoingMessage(StampyMessage<?> message,
HostPort hostPort)
Intercept outgoing message.
|
protected void |
interceptOutgoingMessage(java.lang.String message)
Intercept outgoing message.
|
boolean |
isAutoShutdown()
If true the gateway will shut down when all sessions are terminated.
|
abstract boolean |
isConnected(HostPort hostPort)
Returns true if a connection exists and is active.
|
protected boolean |
isForType(StompMessageType[] messageTypes,
StompMessageType messageType)
Checks if is for type.
|
void |
notifyMessageListeners(StampyMessage<?> sm,
HostPort hostPort)
Notify listeners of received
StampyMessages. |
void |
removeMessageListener(StampyMessageListener listener)
Removes the message listener.
|
void |
removeOutgoingMessageInterceptor(StampyOutgoingMessageInterceptor interceptor)
Removes the specified outgoing message interceptor.
|
void |
removeOutgoingTextInterceptor(StampyOutgoingTextInterceptor interceptor)
Removes the specified outgoing message interceptor.
|
void |
sendMessage(StampyMessage<?> message,
HostPort hostPort)
Sends a
StampyMessage to the specified HostPort. |
abstract void |
sendMessage(java.lang.String stompMessage,
HostPort hostPort)
Sends the specified String to the specified
HostPort. |
void |
setAutoShutdown(boolean autoShutdown)
Sets the auto shutdown.
|
void |
setHeartbeat(int heartbeat)
Sets the heartbeat.
|
void |
setListeners(java.util.Collection<StampyMessageListener> listeners)
Sets the listeners.
|
void |
setMaxMessageSize(int maxMessageSize) |
void |
setOutgoingMessageInterceptors(java.util.Collection<StampyOutgoingMessageInterceptor> interceptors)
Adds the specified outgoing message interceptors.
|
void |
setOutgoingTextInterceptors(java.util.Collection<StampyOutgoingTextInterceptor> interceptors)
Adds the specified outgoing message interceptors.
|
void |
setPort(int port) |
void |
setUnparseableMessageHandler(UnparseableMessageHandler unparseableMessageHandler)
Inject the appropriate
UnparseableMessageHandler on system startup. |
abstract void |
shutdown()
Shuts down the underlying connection technology.
|
protected java.util.Queue<StampyOutgoingMessageInterceptor> interceptors
protected java.util.Queue<StampyOutgoingTextInterceptor> textInterceptors
public void broadcastMessage(StampyMessage<?> message) throws InterceptException
StampyMessage to all connected clients from the server
or to the server from a client. Use this method for all STOMP messages.message - the messageInterceptException - the intercept exceptionpublic void addOutgoingMessageInterceptor(StampyOutgoingMessageInterceptor interceptor)
interceptor - the interceptorStampyOutgoingMessageInterceptorpublic void removeOutgoingMessageInterceptor(StampyOutgoingMessageInterceptor interceptor)
interceptor - the interceptorStampyOutgoingMessageInterceptorpublic void setOutgoingMessageInterceptors(java.util.Collection<StampyOutgoingMessageInterceptor> interceptors)
interceptors - the new outgoing message interceptorsStampyOutgoingMessageInterceptorpublic void addOutgoingTextInterceptor(StampyOutgoingTextInterceptor interceptor)
interceptor - the interceptorStampyOutgoingMessageInterceptorpublic void removeOutgoingTextInterceptor(StampyOutgoingTextInterceptor interceptor)
interceptor - the interceptorStampyOutgoingMessageInterceptorpublic void setOutgoingTextInterceptors(java.util.Collection<StampyOutgoingTextInterceptor> interceptors)
interceptors - the new outgoing text interceptorsStampyOutgoingMessageInterceptorpublic void sendMessage(StampyMessage<?> message, HostPort hostPort) throws InterceptException
StampyMessage to the specified HostPort. Use this
method for all STOMP messages.message - the messagehostPort - the host portInterceptException - the intercept exceptionprotected final void interceptOutgoingMessage(StampyMessage<?> message) throws InterceptException
message - the messageInterceptException - the intercept exceptionprotected final void interceptOutgoingMessage(StampyMessage<?> message, HostPort hostPort) throws InterceptException
message - the messagehostPort - the host portInterceptException - the intercept exceptionprotected final void interceptOutgoingMessage(java.lang.String message)
throws InterceptException
message - the messageInterceptException - the intercept exceptionprotected boolean isForType(StompMessageType[] messageTypes, StompMessageType messageType)
messageTypes - the message typesmessageType - the message typepublic void notifyMessageListeners(StampyMessage<?> sm, HostPort hostPort) throws java.lang.Exception
StampyMessages.sm - the smhostPort - the host portjava.lang.Exception - the exceptionpublic final void addMessageListener(StampyMessageListener listener)
listener - the listenerpublic final void addMessageListener(StampyMessageListener listener, int idx)
public void removeMessageListener(StampyMessageListener listener)
listener - the listenerpublic void clearMessageListeners()
public void setListeners(java.util.Collection<StampyMessageListener> listeners)
listeners - the new listenerspublic abstract void broadcastMessage(java.lang.String stompMessage)
throws InterceptException
stompMessage - the stomp messageInterceptException - the intercept exceptionpublic abstract void sendMessage(java.lang.String stompMessage,
HostPort hostPort)
throws InterceptException
HostPort. Included for
STOMP implementations which accept custom message types. Use for all
non-STOMP messages.stompMessage - the stomp messagehostPort - the host portInterceptException - the intercept exceptionpublic abstract void closeConnection(HostPort hostPort)
hostPort - the host portpublic abstract void connect()
throws java.lang.Exception
java.lang.Exception - the exceptionpublic abstract void shutdown()
throws java.lang.Exception
java.lang.Exception - the exceptionpublic abstract boolean isConnected(HostPort hostPort)
hostPort - the host portpublic abstract java.util.Set<HostPort> getConnectedHostPorts()
public boolean isAutoShutdown()
public void setAutoShutdown(boolean autoShutdown)
autoShutdown - the new auto shutdownpublic int getHeartbeat()
public void setHeartbeat(int heartbeat)
heartbeat - the new heartbeatpublic UnparseableMessageHandler getUnparseableMessageHandler()
UnparseableMessageHandler, defaults to.DefaultUnparseableMessageHandler.public void setUnparseableMessageHandler(UnparseableMessageHandler unparseableMessageHandler)
UnparseableMessageHandler on system startup.unparseableMessageHandler - the new unparseable message handlerpublic int getPort()
public void setPort(int port)
public int getMaxMessageSize()
public void setMaxMessageSize(int maxMessageSize)