solar.service.pubsub
Class ScribePubSubService

java.lang.Object
  |
  +--solar.service.BaseService
        |
        +--solar.service.pubsub.ScribePubSubService
All Implemented Interfaces:
EventHandler, PubSubService, RequestHandler, RpcConstants, ScribeManager.ScribeListener, Service

public class ScribePubSubService
extends BaseService
implements PubSubService, ScribeManager.ScribeListener, RpcConstants

The Pub/Sub service that runs at the server side and is built on top of Scribe.

Version:
$Id: ScribePubSubService.java,v 1.4 2003/10/05 19:42:45 glchen Exp $
Author:
Guanling Chen

Field Summary
protected  RpcService _coreRpc
           
protected  TransportService _coreTransport
           
protected  Address _coreTransportAddress
           
protected  java.lang.String _coreTransportName
           
protected  DispatchService _dispatch
           
protected  java.lang.String _edgeTransportName
           
protected  EndPointManager _epman
           
protected static org.apache.log4j.Logger _log
          Logging facility.
protected  java.lang.String _pubsubName
           
protected  ScribeManager _scribeman
           
protected  java.util.Hashtable _submap
           
 
Fields inherited from class solar.service.BaseService
_inited, _manager, _name
 
Fields inherited from interface solar.service.rpc.RpcConstants
RPC_BLOCK, RPC_HANDLER, RPC_REPLY, RPC_REQUEST, RPC_TIMEOUT
 
Constructor Summary
ScribePubSubService()
           
 
Method Summary
 void addPublisher(Id pubId, Publisher publisher)
          Register a publisher with the service.
 void addSubscriber(Id subId, Subscriber subscriber)
          Register a subscriber with the service.
private  void assertNotRegistered(Id id)
           
private  void assertRegistered(Id id)
           
protected  void doPublish(Id pubId, Event evt)
           
protected  void doPubRegister(Id pubId, Id session, Address address, Publisher publisher)
           
protected  void doSubRegister(Id subId, Id session, Address address, Subscriber subscriber)
           
protected  void doSubscribe(Id pubId, Id subId, java.lang.Object extra)
           
 void eventReceived(Event evt)
           
 void handleEvent(Event evt)
          Processing an event.
 java.lang.Object handleRequest(Request request)
          Processing a request.
 void init()
          Initiate the service, do not try to init dependent services here.
 void initDependents()
          Initialize dependent services here.
private  Guid makeGuid(Id id)
           
private  Id makeSession()
           
 void publish(Id pubId, Event evt)
          Publish an event to all subscribers.
 void subscribe(Id pubId, Id subId, java.lang.Object extra)
          Make a subscription to a publisher.
 
Methods inherited from class solar.service.BaseService
assertInited, getDependentService, getName, getServiceManager, handleDispatchUnit, handleEvent, hasInited, init, 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, setName, setServiceManager, start, stop
 

Field Detail

_log

protected static org.apache.log4j.Logger _log
Logging facility.


_pubsubName

protected java.lang.String _pubsubName

_coreTransportName

protected java.lang.String _coreTransportName

_edgeTransportName

protected java.lang.String _edgeTransportName

_coreTransportAddress

protected Address _coreTransportAddress

_coreRpc

protected RpcService _coreRpc

_dispatch

protected DispatchService _dispatch

_coreTransport

protected TransportService _coreTransport

_scribeman

protected ScribeManager _scribeman

_submap

protected java.util.Hashtable _submap

_epman

protected EndPointManager _epman
Constructor Detail

ScribePubSubService

public ScribePubSubService()
Method Detail

init

public void init()
          throws ServiceException
Description copied from interface: Service
Initiate the service, do not try to init dependent services here.

Specified by:
init in interface Service
Overrides:
init in class BaseService
ServiceException

initDependents

public void initDependents()
                    throws ServiceException
Description copied from interface: Service
Initialize dependent services here.

Specified by:
initDependents in interface Service
Overrides:
initDependents in class BaseService
ServiceException

handleRequest

public java.lang.Object handleRequest(Request request)
                               throws java.lang.Exception
Description copied from interface: RequestHandler
Processing a request.

Specified by:
handleRequest in interface RequestHandler
Overrides:
handleRequest in class BaseService
java.lang.Exception

handleEvent

public void handleEvent(Event evt)
                 throws java.lang.Exception
Description copied from interface: EventHandler
Processing an event.

Specified by:
handleEvent in interface EventHandler
Overrides:
handleEvent in class BaseService
java.lang.Exception

addPublisher

public void addPublisher(Id pubId,
                         Publisher publisher)
                  throws PubSubException
Description copied from interface: PubSubService
Register a publisher with the service.

Specified by:
addPublisher in interface PubSubService
PubSubException

addSubscriber

public void addSubscriber(Id subId,
                          Subscriber subscriber)
                   throws PubSubException
Description copied from interface: PubSubService
Register a subscriber with the service.

Specified by:
addSubscriber in interface PubSubService
PubSubException

subscribe

public void subscribe(Id pubId,
                      Id subId,
                      java.lang.Object extra)
               throws PubSubException
Description copied from interface: PubSubService
Make a subscription to a publisher.

Specified by:
subscribe in interface PubSubService
PubSubException

publish

public void publish(Id pubId,
                    Event evt)
             throws PubSubException
Description copied from interface: PubSubService
Publish an event to all subscribers.

Specified by:
publish in interface PubSubService
PubSubException

doPubRegister

protected void doPubRegister(Id pubId,
                             Id session,
                             Address address,
                             Publisher publisher)
                      throws PubSubException
PubSubException

doSubRegister

protected void doSubRegister(Id subId,
                             Id session,
                             Address address,
                             Subscriber subscriber)

doSubscribe

protected void doSubscribe(Id pubId,
                           Id subId,
                           java.lang.Object extra)
                    throws PubSubException
PubSubException

doPublish

protected void doPublish(Id pubId,
                         Event evt)
                  throws PubSubException
PubSubException

eventReceived

public void eventReceived(Event evt)
Specified by:
eventReceived in interface ScribeManager.ScribeListener

makeSession

private Id makeSession()

makeGuid

private Guid makeGuid(Id id)

assertRegistered

private void assertRegistered(Id id)
                       throws PubSubException
PubSubException

assertNotRegistered

private void assertNotRegistered(Id id)
                          throws PubSubException
PubSubException