solar.service.rmtobj
Class SolarRemoteObjectService

java.lang.Object
  |
  +--solar.service.BaseService
        |
        +--solar.service.rmtobj.SolarRemoteObjectService
All Implemented Interfaces:
Cache.CacheListener, EventHandler, RemoteObjectConstants, RemoteObjectService, RequestHandler, RpcConstants, Service

public class SolarRemoteObjectService
extends BaseService
implements RemoteObjectService, RemoteObjectConstants, RpcConstants, Cache.CacheListener

This RemoteObjectService uses a softstate protocol to monitoring remote object and uses RPC service to invoke request. Current implementation only allows one monitor for a single remote object.

Version:
$Id: SolarRemoteObjectService.java,v 1.7 2003/10/05 18:51:00 glchen Exp $
Author:
Guanling Chen

Nested Class Summary
(package private)  class SolarRemoteObjectService.PingTask
          The task periodically notifies remote monitors about local objects.
 
Field Summary
protected  Cache _cache
           
protected  DispatchService _dispatch
           
protected  long _interval
           
protected  java.util.Hashtable _local
           
protected  org.apache.log4j.Logger _log
           
protected  java.util.Hashtable _registered
           
protected  java.util.Hashtable _remote
           
protected  java.lang.String _rmtobjName
           
protected  RpcService _rpc
           
protected  java.util.Timer _timer
           
protected  Address _transportAddress
           
protected  java.lang.String _transportName
           
 
Fields inherited from class solar.service.BaseService
_inited, _manager, _name
 
Fields inherited from interface solar.service.rmtobj.RemoteObjectConstants
RMTOBJ_ADDRESS, RMTOBJ_CAPACITY, RMTOBJ_IDS, RMTOBJ_INTERVAL, RMTOBJ_TTL
 
Fields inherited from interface solar.service.rpc.RpcConstants
RPC_BLOCK, RPC_HANDLER, RPC_REPLY, RPC_REQUEST, RPC_TIMEOUT
 
Constructor Summary
SolarRemoteObjectService()
           
 
Method Summary
private  java.lang.Object callRpc(Address address, Request request)
           
 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.
 void notifyObjectExpired(CachedObject co)
          Notify when an object has expired from the cache.
 void register(Id id)
          Register a local object for remote monitoring.
 void register(Id id, RequestHandler handler)
          Register a local object for remote monitoring.
 void register(RemoteObject rmtobj, RemoteObjectListener listener)
          Register a remote object to monitor.
 java.lang.Object request(RemoteObject rmtobj, Request req)
          Invoke a request on the remote object.
 void unregister(Id id)
          Unregister a local object.
 void unregister(RemoteObject rmtobj)
          Unregister a remote object.
 
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
 

Field Detail

_log

protected org.apache.log4j.Logger _log

_rmtobjName

protected java.lang.String _rmtobjName

_transportName

protected java.lang.String _transportName

_transportAddress

protected Address _transportAddress

_rpc

protected RpcService _rpc

_dispatch

protected DispatchService _dispatch

_cache

protected Cache _cache

_interval

protected long _interval

_timer

protected java.util.Timer _timer

_local

protected java.util.Hashtable _local

_remote

protected java.util.Hashtable _remote

_registered

protected java.util.Hashtable _registered
Constructor Detail

SolarRemoteObjectService

public SolarRemoteObjectService()
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

notifyObjectExpired

public void notifyObjectExpired(CachedObject co)
Description copied from interface: Cache.CacheListener
Notify when an object has expired from the cache.

Specified by:
notifyObjectExpired in interface Cache.CacheListener

register

public void register(RemoteObject rmtobj,
                     RemoteObjectListener listener)
              throws RemoteObjectException
Description copied from interface: RemoteObjectService
Register a remote object to monitor.

Specified by:
register in interface RemoteObjectService
RemoteObjectException

unregister

public void unregister(RemoteObject rmtobj)
                throws RemoteObjectException
Description copied from interface: RemoteObjectService
Unregister a remote object.

Specified by:
unregister in interface RemoteObjectService
RemoteObjectException

register

public void register(Id id,
                     RequestHandler handler)
Description copied from interface: RemoteObjectService
Register a local object for remote monitoring.

Specified by:
register in interface RemoteObjectService

register

public void register(Id id)
Description copied from interface: RemoteObjectService
Register a local object for remote monitoring.

Specified by:
register in interface RemoteObjectService

unregister

public void unregister(Id id)
Description copied from interface: RemoteObjectService
Unregister a local object.

Specified by:
unregister in interface RemoteObjectService

request

public java.lang.Object request(RemoteObject rmtobj,
                                Request req)
                         throws RemoteObjectException
Description copied from interface: RemoteObjectService
Invoke a request on the remote object.

Specified by:
request in interface RemoteObjectService
RemoteObjectException

callRpc

private java.lang.Object callRpc(Address address,
                                 Request request)
                          throws RpcException
RpcException