EventEvaluator.Resource
Class ResourceEventLocatorImpl

java.lang.Object
  |
  +--org.omg.PortableServer.Servant
        |
        +--org.omg.PortableServer.ServantLocatorPOA
              |
              +--EventEvaluator.Resource.ResourceEventLocatorImpl
All Implemented Interfaces:
org.omg.CORBA.portable.InvokeHandler, org.omg.PortableServer.ServantLocatorOperations, org.omg.PortableServer.ServantManagerOperations

public class ResourceEventLocatorImpl
extends org.omg.PortableServer.ServantLocatorPOA

Implements the servant locator for resource event objects. This class implements the servant locator for the resource event objects. It uses the Evictor pattern described at:

Advanced CORBA Programming with C++

  • Michi Henning, Steve Vinoski
  • The Addison-Wesley Professional Computing Series

    This pattern controls the amount of resource event objects resident on the main memory. It maintains an active object map that holds a list of all resource event objects currently on memory and an evictor queue that is updated when there is a reference for an resource event object. The object referenced is placed at the end of the evictor queue. The max limit of elements for this queue determines how many resource event objects can reside at the same time on memory. If the limit is reached and there is a new reference for an resource event not on memory, the first resource event of the evictor queue is removed from there.


    Constructor Summary
    ResourceEventLocatorImpl(org.omg.CORBA.ORB orb, Persistence pobj)
              Creates the active object map and the evictor queue.
     
    Method Summary
     void free(java.lang.String eid)
              Remove from memory the servant of resource event identified by eid.
     void postinvoke(byte[] oid, org.omg.PortableServer.POA adapter, java.lang.String operation, java.lang.Object cookie, org.omg.PortableServer.Servant servant)
              Does nothing.
     org.omg.PortableServer.Servant preinvoke(byte[] oid, org.omg.PortableServer.POA adapter, java.lang.String operation, org.omg.PortableServer.ServantLocatorPackage.CookieHolder cookie)
              Activate the resource event being requested.
     
    Methods inherited from class org.omg.PortableServer.ServantLocatorPOA
    _all_interfaces, _invoke, _this, _this
     
    Methods inherited from class org.omg.PortableServer.Servant
    _default_POA, _get_delegate, _get_interface, _is_a, _non_existent, _object_id, _orb, _poa, _set_delegate, _this_object, _this_object
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    ResourceEventLocatorImpl

    public ResourceEventLocatorImpl(org.omg.CORBA.ORB orb,
                                    Persistence pobj)
    Creates the active object map and the evictor queue.
    Parameters:
    orb - reference to the orb
    pobj - reference to the Persistence object
    Method Detail

    preinvoke

    public org.omg.PortableServer.Servant preinvoke(byte[] oid,
                                                    org.omg.PortableServer.POA adapter,
                                                    java.lang.String operation,
                                                    org.omg.PortableServer.ServantLocatorPackage.CookieHolder cookie)
                                             throws org.omg.PortableServer.ForwardRequest
    Activate the resource event being requested. This method activates the resource event requested by the user based on the evictor pattern. It receives the key for the resource event that represents the eid (event identification). It then checks if this object exist by calling the method REExist of the Persistence object. If the object exists it checks if it is already on memory by searching the active object map. If it is not on memory it instantiates a new servant for the resource event.
    Overrides:
    preinvoke in class org.omg.PortableServer.ServantLocatorPOA
    Parameters:
    oid - the identification of the resource event being requested
    adapter -  
    operation - the operation on the resource event being requested
    cookie -  

    postinvoke

    public void postinvoke(byte[] oid,
                           org.omg.PortableServer.POA adapter,
                           java.lang.String operation,
                           java.lang.Object cookie,
                           org.omg.PortableServer.Servant servant)
    Does nothing.
    Overrides:
    postinvoke in class org.omg.PortableServer.ServantLocatorPOA

    free

    public void free(java.lang.String eid)
    Remove from memory the servant of resource event identified by eid.
    Parameters:
    eid - the identity of the resource event servant to be removed from memory