solar.service.transport
Class BaseTransportService

java.lang.Object
  |
  +--solar.service.BaseService
        |
        +--solar.service.transport.BaseTransportService
All Implemented Interfaces:
EventHandler, RequestHandler, Service, TransportListener, TransportService
Direct Known Subclasses:
PastryTransportService, TcpTransportService, UdpTransportService

public class BaseTransportService
extends BaseService
implements TransportService, TransportListener

The base implementation of transport service. Subclass must use init() method to instantiate an actual transport.

Version:
$Id: BaseTransportService.java,v 1.2 2003/10/05 18:51:01 glchen Exp $
Author:
Guanling Chen

Field Summary
protected  AduFactory _aduFactory
          The factory parses received packets.
protected  java.util.List _listeners
           
protected  org.apache.log4j.Logger _log
          The logger for Pastry transport service.
protected  RoutingService _routing
          The routing service has the routing/forwarding table.
protected  Transport _transport
          The actual transport layer.
 
Fields inherited from class solar.service.BaseService
_inited, _manager, _name
 
Constructor Summary
BaseTransportService()
           
 
Method Summary
 void addTransportListener(TransportListener listener)
          Add a transport listener.
 void connectionClosed(Address peer)
          Called when an connection closed.
 void connectionOpened(Address peer)
          Called when an connection opened.
 void dataReceived(Adu adu, Header header)
          Called when new data is received.
private  void doSend(Adu adu, Address dest, Id multiplex)
           
 Address getAddressByKey(java.lang.String key)
          Return a peer address based on the specified key.
 Address getLocalAddress()
          Return local address for this transport service.
 Transport getTransport()
          Return the transport module (dealing with individual protocol).
protected  void notifyDataReceived(Adu adu, Header header)
           
 void removeTransportListener(TransportListener listener)
          Remove a transport listener.
 void send(Adu adu, Address dest)
          Send an application data unit to destination address.
 void send(Adu adu, Address dest, Id multiplex)
          Send an application data unit to destination address.
 
Methods inherited from class solar.service.BaseService
assertInited, getDependentService, getName, getServiceManager, handleDispatchUnit, handleEvent, handleEvent, handleRequest, hasInited, init, init, initDependents, setInited, setName, setServiceManager, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface solar.service.Service
getName, getServiceManager, handleDispatchUnit, hasInited, init, initDependents, setName, setServiceManager, start, stop
 
Methods inherited from interface solar.api.EventHandler
handleEvent
 
Methods inherited from interface solar.api.RequestHandler
handleRequest
 

Field Detail

_log

protected org.apache.log4j.Logger _log
The logger for Pastry transport service.


_transport

protected Transport _transport
The actual transport layer.


_routing

protected RoutingService _routing
The routing service has the routing/forwarding table.


_aduFactory

protected AduFactory _aduFactory
The factory parses received packets.


_listeners

protected java.util.List _listeners
Constructor Detail

BaseTransportService

public BaseTransportService()
Method Detail

addTransportListener

public void addTransportListener(TransportListener listener)
Description copied from interface: TransportService
Add a transport listener.

Specified by:
addTransportListener in interface TransportService

removeTransportListener

public void removeTransportListener(TransportListener listener)
Description copied from interface: TransportService
Remove a transport listener.

Specified by:
removeTransportListener in interface TransportService

dataReceived

public void dataReceived(Adu adu,
                         Header header)
Description copied from interface: TransportListener
Called when new data is received.

Specified by:
dataReceived in interface TransportListener

connectionOpened

public void connectionOpened(Address peer)
Description copied from interface: TransportListener
Called when an connection opened.

Specified by:
connectionOpened in interface TransportListener

connectionClosed

public void connectionClosed(Address peer)
Description copied from interface: TransportListener
Called when an connection closed.

Specified by:
connectionClosed in interface TransportListener

notifyDataReceived

protected void notifyDataReceived(Adu adu,
                                  Header header)

doSend

private void doSend(Adu adu,
                    Address dest,
                    Id multiplex)
             throws TransportException
TransportException

getLocalAddress

public Address getLocalAddress()
Description copied from interface: TransportService
Return local address for this transport service.

Specified by:
getLocalAddress in interface TransportService

getAddressByKey

public Address getAddressByKey(java.lang.String key)
                        throws TransportException
Description copied from interface: TransportService
Return a peer address based on the specified key.

Specified by:
getAddressByKey in interface TransportService
TransportException

getTransport

public Transport getTransport()
Description copied from interface: TransportService
Return the transport module (dealing with individual protocol).

Specified by:
getTransport in interface TransportService

send

public void send(Adu adu,
                 Address dest)
          throws TransportException
Description copied from interface: TransportService
Send an application data unit to destination address.

Specified by:
send in interface TransportService
TransportException

send

public void send(Adu adu,
                 Address dest,
                 Id multiplex)
          throws TransportException
Description copied from interface: TransportService
Send an application data unit to destination address.

Specified by:
send in interface TransportService
TransportException