Class AmqpWSTransport
- java.lang.Object
-
- org.apache.activemq.util.ServiceSupport
-
- org.apache.activemq.transport.TransportSupport
-
- org.apache.activemq.transport.amqp.AmqpWSTransport
-
- All Implemented Interfaces:
Service
,AmqpFrameParser.AMQPFrameSink
,Transport
,WSTransport
public class AmqpWSTransport extends TransportSupport implements WSTransport, AmqpFrameParser.AMQPFrameSink
An AMQP based WebSocket transport implementation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.activemq.transport.ws.WSTransport
WSTransport.WSTransportSink
-
-
Constructor Summary
Constructors Constructor Description AmqpWSTransport(URI location, WireFormat wireFormat)
Create a new Transport instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doStart()
protected void
doStop(ServiceStopper stopper)
int
getMaxFrameSize()
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
onFrame(Object frame)
void
onWebSocketBinary(ByteBuffer data)
Called from the WebSocket framework when new incoming Binary data is received.void
onWebSocketClosed()
Called from the WebSocket framework when the socket has been closed unexpectedly.void
onWebSocketText(String data)
Called from the WebSocket framework when new incoming String data is received.void
setPeerCertificates(X509Certificate[] certificates)
Sets the certificates provided by the connected peer.void
setTransportSink(WSTransport.WSTransportSink outputSink)
Called to provide the WS with the output data sink.-
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
-
AmqpWSTransport
public AmqpWSTransport(URI location, WireFormat wireFormat)
Create a new Transport instance.- Parameters:
location
- the remote location where the client connection is from.wireFormat
- the WireFormat instance that configures this Transport.
-
-
Method Detail
-
setTransportSink
public void setTransportSink(WSTransport.WSTransportSink outputSink)
Description copied from interface:WSTransport
Called to provide the WS with the output data sink.- Specified by:
setTransportSink
in interfaceWSTransport
-
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
-
getRemoteAddress
public String getRemoteAddress()
- Specified by:
getRemoteAddress
in interfaceTransport
- Returns:
- the remote address for this connection
-
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.
-
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.
-
getSubProtocol
public String getSubProtocol()
- Specified by:
getSubProtocol
in interfaceWSTransport
- Returns:
- the WS sub-protocol that this transport is supplying.
-
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.
-
getMaxFrameSize
public int getMaxFrameSize()
- Specified by:
getMaxFrameSize
in interfaceWSTransport
- Returns:
- the maximum frame size allowed for this WS 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
-
onWebSocketText
public void onWebSocketText(String data) throws IOException
Description copied from interface:WSTransport
Called from the WebSocket framework when new incoming String data is received.- Specified by:
onWebSocketText
in interfaceWSTransport
- Parameters:
data
- The newly received incoming data.- Throws:
IOException
- if an error occurs or the socket doesn't support text data.
-
onWebSocketBinary
public void onWebSocketBinary(ByteBuffer data) throws IOException
Description copied from interface:WSTransport
Called from the WebSocket framework when new incoming Binary data is received.- Specified by:
onWebSocketBinary
in interfaceWSTransport
- Parameters:
data
- The newly received incoming data.- Throws:
IOException
- if an error occurs or the socket doesn't support binary data.
-
onWebSocketClosed
public void onWebSocketClosed() throws IOException
Description copied from interface:WSTransport
Called from the WebSocket framework when the socket has been closed unexpectedly.- Specified by:
onWebSocketClosed
in interfaceWSTransport
- Throws:
IOException
- if an error while processing the close.
-
onFrame
public void onFrame(Object frame)
- Specified by:
onFrame
in interfaceAmqpFrameParser.AMQPFrameSink
-
-