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 voiddoStart()protected voiddoStop(ServiceStopper stopper)X509Certificate[]getPeerCertificates()intgetReceiveCounter()Returns a counter which gets incremented as data is read from the transport.StringgetRemoteAddress()StringgetSubProtocol()WireFormatgetWireFormat()Retrieves the WireFormat instance associated with this Transport instance.voidoneway(Object command)A one way asynchronous sendvoidonSocketOutboundBinary(ByteBuffer data)Called from the Transport when new outgoing String data is ready.voidonSocketOutboundText(String data)Called from the Transport when new outgoing String data is ready.voidonWebSocketBinary(byte[] payload, int offset, int length)voidonWebSocketClose(int statusCode, String reason)voidonWebSocketConnect(org.eclipse.jetty.websocket.api.Session session)voidonWebSocketError(Throwable cause)voidonWebSocketText(String data)voidsetBrokerService(BrokerService brokerService)voidsetPeerCertificates(X509Certificate[] certificates)Sets the certificates provided by the connected peer.voidsetTransportOptions(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:
setBrokerServicein interfaceBrokerServiceAware
-
oneway
public void oneway(Object command) throws IOException
Description copied from interface:TransportA one way asynchronous send- Specified by:
onewayin interfaceTransport- Throws:
IOException
-
getPeerCertificates
public X509Certificate[] getPeerCertificates()
- Specified by:
getPeerCertificatesin 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:TransportSets the certificates provided by the connected peer.- Specified by:
setPeerCertificatesin interfaceTransport- Parameters:
certificates- the Certificates provided by the peer.
-
getRemoteAddress
public String getRemoteAddress()
- Specified by:
getRemoteAddressin interfaceTransport- Returns:
- the remote address for this connection
-
getWireFormat
public WireFormat getWireFormat()
Description copied from interface:TransportRetrieves the WireFormat instance associated with this Transport instance.- Specified by:
getWireFormatin interfaceTransport- Returns:
- the WireFormat in use.
-
getReceiveCounter
public int getReceiveCounter()
Description copied from interface:TransportReturns 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:
getReceiveCounterin interfaceTransport- Returns:
- a counter which gets incremented as data is read from the transport.
-
doStop
protected void doStop(ServiceStopper stopper) throws Exception
- Specified by:
doStopin classServiceSupport- Throws:
Exception
-
doStart
protected void doStart() throws Exception- Specified by:
doStartin classServiceSupport- Throws:
Exception
-
onWebSocketBinary
public void onWebSocketBinary(byte[] payload, int offset, int length)- Specified by:
onWebSocketBinaryin interfaceorg.eclipse.jetty.websocket.api.WebSocketListener
-
onWebSocketText
public void onWebSocketText(String data)
- Specified by:
onWebSocketTextin interfaceorg.eclipse.jetty.websocket.api.WebSocketListener
-
onWebSocketClose
public void onWebSocketClose(int statusCode, String reason)- Specified by:
onWebSocketClosein interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-
onWebSocketConnect
public void onWebSocketConnect(org.eclipse.jetty.websocket.api.Session session)
- Specified by:
onWebSocketConnectin interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-
onWebSocketError
public void onWebSocketError(Throwable cause)
- Specified by:
onWebSocketErrorin interfaceorg.eclipse.jetty.websocket.api.WebSocketConnectionListener
-
onSocketOutboundText
public void onSocketOutboundText(String data) throws IOException
Description copied from interface:WSTransport.WSTransportSinkCalled from the Transport when new outgoing String data is ready.- Specified by:
onSocketOutboundTextin 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.WSTransportSinkCalled from the Transport when new outgoing String data is ready.- Specified by:
onSocketOutboundBinaryin interfaceWSTransport.WSTransportSink- Parameters:
data- The newly prepared outgoing string data.- Throws:
IOException- if an error occurs or the socket doesn't support text data.
-
-