org.apache.activemq.transport.mock
Class MockTransport

java.lang.Object
  extended by org.apache.activemq.transport.DefaultTransportListener
      extended by org.apache.activemq.transport.mock.MockTransport
All Implemented Interfaces:
Service, Transport, TransportListener

public class MockTransport
extends DefaultTransportListener
implements Transport


Field Summary
protected  Transport next
           
protected  TransportListener transportListener
           
 
Constructor Summary
MockTransport(Transport next)
           
 
Method Summary
 FutureResponse asyncRequest(Object command, ResponseCallback responseCallback)
          An asynchronous request response where the Receipt will be returned in the future.
 Transport getNext()
           
 int getReceiveCounter()
          Returns a counter which gets incremented as data is read from the transport.
 String getRemoteAddress()
           
 TransportListener getTransportListener()
          Returns the current transport listener
 void install(TransportFilter filter)
           
 boolean isConnected()
           
 boolean isDisposed()
           
 boolean isFaultTolerant()
          Indicates if the transport can handle faults
 boolean isReconnectSupported()
           
 boolean isUpdateURIsSupported()
           
<T> T
narrow(Class<T> target)
           
 void onCommand(Object command)
          called to process a command
 void oneway(Object command)
          A one way asynchronous send
 void onException(IOException error)
          An unrecoverable exception has occured on the transport
 void reconnect(URI uri)
          reconnect to another location
 Object request(Object command)
          A synchronous request response
 Object request(Object command, int timeout)
          A synchronous request response
 void setNext(Transport next)
           
 void setTransportListener(TransportListener channelListener)
          Registers an inbound command listener
 void start()
           
 void stop()
           
 String toString()
           
 void updateURIs(boolean reblance, URI[] uris)
          Provide a list of available alternative locations
 
Methods inherited from class org.apache.activemq.transport.DefaultTransportListener
transportInterupted, transportResumed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

next

protected Transport next

transportListener

protected TransportListener transportListener
Constructor Detail

MockTransport

public MockTransport(Transport next)
Method Detail

setTransportListener

public void setTransportListener(TransportListener channelListener)
Description copied from interface: Transport
Registers an inbound command listener

Specified by:
setTransportListener in interface Transport

start

public void start()
           throws Exception
Specified by:
start in interface Service
Throws:
IOException - if the next channel has not been set.
Exception
See Also:
Service.start()

stop

public void stop()
          throws Exception
Specified by:
stop in interface Service
Throws:
Exception
See Also:
Service.stop()

onCommand

public void onCommand(Object command)
Description copied from class: DefaultTransportListener
called to process a command

Specified by:
onCommand in interface TransportListener
Overrides:
onCommand in class DefaultTransportListener

getNext

public Transport getNext()
Returns:
Returns the getNext().

getTransportListener

public TransportListener getTransportListener()
Description copied from interface: Transport
Returns the current transport listener

Specified by:
getTransportListener in interface Transport
Returns:
Returns the packetListener.

toString

public String toString()
Overrides:
toString in class Object

oneway

public void oneway(Object command)
            throws IOException
Description copied from interface: Transport
A one way asynchronous send

Specified by:
oneway in interface Transport
Throws:
IOException

asyncRequest

public FutureResponse asyncRequest(Object command,
                                   ResponseCallback responseCallback)
                            throws IOException
Description copied from interface: Transport
An asynchronous request response where the Receipt will be returned in the future. If responseCallback is not null, then it will be called when the response has been completed.

Specified by:
asyncRequest in interface Transport
responseCallback - TODO
Returns:
the FutureResponse
Throws:
IOException

request

public Object request(Object command)
               throws IOException
Description copied from interface: Transport
A synchronous request response

Specified by:
request in interface Transport
Returns:
the response
Throws:
IOException

request

public Object request(Object command,
                      int timeout)
               throws IOException
Description copied from interface: Transport
A synchronous request response

Specified by:
request in interface Transport
Returns:
the repsonse or null if timeout
Throws:
IOException

onException

public void onException(IOException error)
Description copied from class: DefaultTransportListener
An unrecoverable exception has occured on the transport

Specified by:
onException in interface TransportListener
Overrides:
onException in class DefaultTransportListener

narrow

public <T> T narrow(Class<T> target)
Specified by:
narrow in interface Transport
Returns:
the target

setNext

public void setNext(Transport next)

install

public void install(TransportFilter filter)

getRemoteAddress

public String getRemoteAddress()
Specified by:
getRemoteAddress in interface Transport
Returns:
the remote address for this connection

isFaultTolerant

public boolean isFaultTolerant()
Description copied from interface: Transport
Indicates if the transport can handle faults

Specified by:
isFaultTolerant in interface Transport
Returns:
true if fault tolerant
See Also:
Transport.isFaultTolerant()

isDisposed

public boolean isDisposed()
Specified by:
isDisposed in interface Transport
Returns:
true if the transport is disposed

isConnected

public boolean isConnected()
Specified by:
isConnected in interface Transport
Returns:
true if the transport is connected

reconnect

public void reconnect(URI uri)
               throws IOException
Description copied from interface: Transport
reconnect to another location

Specified by:
reconnect in interface Transport
Throws:
IOException - on failure of if not supported

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 interface Transport
Returns:
a counter which gets incremented as data is read from the transport.

isReconnectSupported

public boolean isReconnectSupported()
Specified by:
isReconnectSupported in interface Transport
Returns:
true if reconnect is supported

isUpdateURIsSupported

public boolean isUpdateURIsSupported()
Specified by:
isUpdateURIsSupported in interface Transport
Returns:
true if updating uris is supported

updateURIs

public void updateURIs(boolean reblance,
                       URI[] uris)
                throws IOException
Description copied from interface: Transport
Provide a list of available alternative locations

Specified by:
updateURIs in interface Transport
Throws:
IOException


Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.