Package org.apache.activemq.transport.ws
Class WSTransportProxy
- java.lang.Object
-
- org.apache.activemq.util.ServiceSupport
-
- org.apache.activemq.transport.TransportSupport
-
- org.apache.activemq.transport.ws.WSTransportProxy
-
- All Implemented Interfaces:
BrokerServiceAware
,Service
,Transport
,WSTransport.WSTransportSink
,org.eclipse.jetty.websocket.api.WebSocketConnectionListener
,org.eclipse.jetty.websocket.api.WebSocketListener
public final class WSTransportProxy extends TransportSupport implements Transport, org.eclipse.jetty.websocket.api.WebSocketListener, BrokerServiceAware, WSTransport.WSTransportSink
A proxy class that manages sending WebSocket events to the wrapped protocol level WebSocket Transport.
-
-
Constructor Summary
Constructors Constructor Description WSTransportProxy(String remoteAddress, Transport transport)
Create a WebSocket Transport Proxy instance that will pass along WebSocket event to the underlying protocol level transport.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doStart()
protected void
doStop(ServiceStopper stopper)
X509Certificate[]
getPeerCertificates()
int
getReceiveCounter()
Returns a counter which gets incremented as data is read from the transport.String
getRemoteAddress()
String
getSubProtocol()
WireFormat
getWireFormat()
Retrieves the WireFormat instance associated with this Transport instance.void
oneway(Object command)
A one way asynchronous sendvoid
onSocketOutboundBinary(ByteBuffer data)
Called from the Transport when new outgoing String data is ready.void
onSocketOutboundText(String data)
Called from the Transport when new outgoing String data is ready.void
onWebSocketBinary(byte[] payload, int offset, int length)
void
onWebSocketClose(int statusCode, String reason)
void
onWebSocketConnect(org.eclipse.jetty.websocket.api.Session session)
void
onWebSocketError(Throwable cause)
void
onWebSocketText(String data)
void
setBrokerService(BrokerService brokerService)
void
setPeerCertificates(X509Certificate[] certificates)
Sets the certificates provided by the connected peer.void
setTransportOptions(Map<String,Object> options)
Apply any configure Transport options on the wrapped Transport and its contained wireFormat instance.-
Methods inherited from class org.apache.activemq.transport.TransportSupport
asyncRequest, checkStarted, doConsume, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, narrow, onException, reconnect, request, request, setTransportListener, updateURIs
-
Methods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, preStart, removeServiceListener, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.transport.Transport
asyncRequest, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, narrow, reconnect, request, request, setTransportListener, updateURIs
-
-
-
-
Constructor Detail
-
WSTransportProxy
public WSTransportProxy(String remoteAddress, Transport transport)
Create a WebSocket Transport Proxy instance that will pass along WebSocket event to the underlying protocol level transport.- Parameters:
remoteAddress
- the provided remote address to report being connected to.transport
- The protocol level WebSocket Transport
-
-
Method Detail
-
getSubProtocol
public String getSubProtocol()
- Returns:
- the sub-protocol of the proxied transport.
-
setTransportOptions
public void setTransportOptions(Map<String,Object> options)
Apply any configure Transport options on the wrapped Transport and its contained wireFormat instance.
-
setBrokerService
public void setBrokerService(BrokerService brokerService)
- Specified by:
setBrokerService
in interfaceBrokerServiceAware
-
oneway
public void oneway(Object command) throws IOException
Description copied from interface:Transport
A one way asynchronous send- Specified by:
oneway
in interfaceTransport
- Throws:
IOException
-
getPeerCertificates
public X509Certificate[] getPeerCertificates()
- Specified by:
getPeerCertificates
in interfaceTransport
- Returns:
- the Certificates provided by the peer, or null if not a secure channel.
-
setPeerCertificates
public void setPeerCertificates(X509Certificate[] certificates)
Description copied from interface:Transport
Sets the certificates provided by the connected peer.- Specified by:
setPeerCertificates
in interfaceTransport
- Parameters:
certificates
- the Certificates provided by the peer.
-
getRemoteAddress
public String getRemoteAddress()
- Specified by:
getRemoteAddress
in interfaceTransport
- Returns:
- the remote address for this connection
-
getWireFormat
public WireFormat getWireFormat()
Description copied from interface:Transport
Retrieves the WireFormat instance associated with this Transport instance.- Specified by:
getWireFormat
in interfaceTransport
- Returns:
- the WireFormat in use.
-
getReceiveCounter
public int getReceiveCounter()
Description copied from interface:Transport
Returns a counter which gets incremented as data is read from the transport. It should only be used to determine if there is progress being made in reading the next command from the transport. The value may wrap into the negative numbers.- Specified by:
getReceiveCounter
in interfaceTransport
- Returns:
- a counter which gets incremented as data is read from the transport.
-
doStop
protected void doStop(ServiceStopper stopper) throws Exception
- Specified by:
doStop
in classServiceSupport
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Specified by:
doStart
in classServiceSupport
- Throws:
Exception
-
onWebSocketBinary
public void onWebSocketBinary(byte[] payload, int offset, int length)
- Specified by:
onWebSocketBinary
in interfaceorg.eclipse.jetty.websocket.api.WebSocketListener
-
onWebSocketText
public void onWebSocketText(String data)
- Specified by:
onWebSocketText
in interfaceorg.eclipse.jetty.websocket.api.WebSocketListener
-
onWebSocketClose
public void onWebSocketClose(int statusCode, String reason)
- Specified by:
onWebSocketClose
in interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-
onWebSocketConnect
public void onWebSocketConnect(org.eclipse.jetty.websocket.api.Session session)
- Specified by:
onWebSocketConnect
in interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-
onWebSocketError
public void onWebSocketError(Throwable cause)
- Specified by:
onWebSocketError
in interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-
onSocketOutboundText
public void onSocketOutboundText(String data) throws IOException
Description copied from interface:WSTransport.WSTransportSink
Called from the Transport when new outgoing String data is ready.- Specified by:
onSocketOutboundText
in interfaceWSTransport.WSTransportSink
- Parameters:
data
- The newly prepared outgoing string data.- Throws:
IOException
- if an error occurs or the socket doesn't support text data.
-
onSocketOutboundBinary
public void onSocketOutboundBinary(ByteBuffer data) throws IOException
Description copied from interface:WSTransport.WSTransportSink
Called from the Transport when new outgoing String data is ready.- Specified by:
onSocketOutboundBinary
in interfaceWSTransport.WSTransportSink
- Parameters:
data
- The newly prepared outgoing string data.- Throws:
IOException
- if an error occurs or the socket doesn't support text data.
-
-