org.apache.activemq.transport.vm
Class VMTransport

java.lang.Object
  extended by org.apache.activemq.transport.vm.VMTransport
All Implemented Interfaces:
Service, Task, Transport

public class VMTransport
extends Object
implements Transport, Task

A Transport implementation that uses direct method invocations.


Field Summary
protected  boolean async
           
protected  int asyncQueueDepth
           
protected  AtomicBoolean disposed
           
protected  long id
           
protected  URI location
           
protected  boolean marshal
           
protected  boolean network
           
protected  VMTransport peer
           
protected  AtomicBoolean started
           
protected  TransportListener transportListener
           
 
Constructor Summary
VMTransport(URI location)
           
 
Method Summary
 FutureResponse asyncRequest(Object command, ResponseCallback responseCallback)
          An asynchronous request response where the Receipt will be returned in the future.
 void dispatch(VMTransport transport, BlockingQueue<Object> pending, Object command)
           
 void doDispatch(VMTransport transport, TransportListener transportListener, Object command)
           
 int getAsyncQueueDepth()
           
 LinkedBlockingQueue<Object> getMessageQueue()
           
 int getReceiveCounter()
          Returns a counter which gets incremented as data is read from the transport.
 String getRemoteAddress()
           
protected  TaskRunner getTaskRunner()
           
 TransportListener getTransportListener()
          Returns the current transport listener
 boolean isAsync()
           
 boolean isConnected()
           
 boolean isDisposed()
           
 boolean isFaultTolerant()
          Indicates if the transport can handle faults
 boolean isMarshal()
           
 boolean isNetwork()
           
 boolean isReconnectSupported()
           
 boolean isUpdateURIsSupported()
           
 boolean iterate()
           
<T> T
narrow(Class<T> target)
           
 void oneway(Object command)
          A one way asynchronous send
 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 setAsync(boolean async)
           
 void setAsyncQueueDepth(int asyncQueueDepth)
           
 void setMarshal(boolean marshal)
           
 void setMessageQueue(LinkedBlockingQueue<Object> asyncQueue)
           
 void setNetwork(boolean network)
           
 void setPeer(VMTransport peer)
           
 void setTransportListener(TransportListener commandListener)
          Registers an inbound command listener
 void start()
           
 void stop()
           
 String toString()
           
 void updateURIs(boolean reblance, URI[] uris)
          Provide a list of available alternative locations
protected  void wakeup()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

peer

protected VMTransport peer

transportListener

protected TransportListener transportListener

marshal

protected boolean marshal

network

protected boolean network

async

protected boolean async

asyncQueueDepth

protected int asyncQueueDepth

location

protected final URI location

id

protected final long id

started

protected final AtomicBoolean started

disposed

protected final AtomicBoolean disposed
Constructor Detail

VMTransport

public VMTransport(URI location)
Method Detail

setPeer

public void setPeer(VMTransport peer)

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

dispatch

public void dispatch(VMTransport transport,
                     BlockingQueue<Object> pending,
                     Object command)

doDispatch

public void doDispatch(VMTransport transport,
                       TransportListener transportListener,
                       Object command)

start

public void start()
           throws Exception
Specified by:
start in interface Service
Throws:
Exception

stop

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

wakeup

protected void wakeup()

iterate

public boolean iterate()
Specified by:
iterate in interface Task
See Also:
Task.iterate()

setTransportListener

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

Specified by:
setTransportListener in interface Transport

setMessageQueue

public void setMessageQueue(LinkedBlockingQueue<Object> asyncQueue)

getMessageQueue

public LinkedBlockingQueue<Object> getMessageQueue()
                                            throws TransportDisposedIOException
Throws:
TransportDisposedIOException

getTaskRunner

protected TaskRunner getTaskRunner()
                            throws TransportDisposedIOException
Throws:
TransportDisposedIOException

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

getTransportListener

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

Specified by:
getTransportListener in interface Transport
Returns:

narrow

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

isMarshal

public boolean isMarshal()

setMarshal

public void setMarshal(boolean marshal)

isNetwork

public boolean isNetwork()

setNetwork

public void setNetwork(boolean network)

toString

public String toString()
Overrides:
toString in class Object

getRemoteAddress

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

isAsync

public boolean isAsync()
Returns:
the async

setAsync

public void setAsync(boolean async)
Parameters:
async - the async to set

getAsyncQueueDepth

public int getAsyncQueueDepth()
Returns:
the asyncQueueDepth

setAsyncQueueDepth

public void setAsyncQueueDepth(int asyncQueueDepth)
Parameters:
asyncQueueDepth - the asyncQueueDepth to set

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

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

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

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.


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