org.jboss.ejb.plugins
Class PerTxEntityInstanceCache

java.lang.Object
  extended byorg.jboss.ejb.plugins.PerTxEntityInstanceCache
All Implemented Interfaces:
AllowedOperationsFlags (src) , ContainerPlugin (src) , EntityCache (src) , InstanceCache (src) , Service (src)

public class PerTxEntityInstanceCache
extends java.lang.Object
implements EntityCache (src)

Per transaction instance cache.


Field Summary
 
Fields inherited from interface org.jboss.ejb.AllowedOperationsFlags (src)
IN_AFTER_BEGIN, IN_AFTER_COMPLETION, IN_BEFORE_COMPLETION, IN_BUSINESS_METHOD, IN_EJB_ACTIVATE, IN_EJB_CREATE, IN_EJB_FIND, IN_EJB_HOME, IN_EJB_LOAD, IN_EJB_PASSIVATE, IN_EJB_POST_CREATE, IN_EJB_REMOVE, IN_EJB_STORE, IN_EJB_TIMEOUT, IN_INTERCEPTOR_METHOD, IN_SERVICE_ENDPOINT_METHOD, IN_SET_ENTITY_CONTEXT, IN_SET_MESSAGE_DRIVEN_CONTEXT, IN_SET_SESSION_CONTEXT, IN_UNSET_ENTITY_CONTEXT, NOT_ALLOWED
 
Constructor Summary
PerTxEntityInstanceCache()
           
 
Method Summary
protected  boolean canPassivate(EnterpriseContext (src)  ctx)
           
 void create()
          create the service, do expensive operations etc
 java.lang.Object createCacheKey(java.lang.Object id)
          Returns the key used to cache the context
 void destroy()
          destroy the service, tear down
 void flush()
          Flush the cache.
 EnterpriseContext (src) get(java.lang.Object id)
          Gets a bean instance from this cache given the identity.
 long getCacheSize()
          Get the current cache size
 void insert(EnterpriseContext (src)  instance)
          Inserts an active bean instance after creation or activation.
 boolean isActive(java.lang.Object id)
          Checks whether an instance corresponding to a particular id is active.
 void release(EnterpriseContext (src)  instance)
          Releases the given bean instance from this cache.
 void remove(java.lang.Object id)
          Removes a bean instance from this cache given the identity.
 void setContainer(Container (src)  con)
          This callback is set by the container so that the plugin may access it
 void start()
          start the service, create is already called
 void stop()
          stop the service
protected  void tryToPassivate(EnterpriseContext (src)  instance)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerTxEntityInstanceCache

public PerTxEntityInstanceCache()
Method Detail

createCacheKey

public java.lang.Object createCacheKey(java.lang.Object id)
Description copied from interface: EntityCache (src)
Returns the key used to cache the context

Specified by:
createCacheKey in interface EntityCache (src)
Parameters:
id - Object id / primary key
Returns:
Cache key

get

public EnterpriseContext (src)  get(java.lang.Object id)
                      throws java.rmi.RemoteException,
                             java.rmi.NoSuchObjectException
Description copied from interface: InstanceCache (src)
Gets a bean instance from this cache given the identity. This method may involve activation if the instance is not in the cache.

Implementation should have O(1) complexity.

This method is never called for stateless session beans.

Specified by:
get in interface InstanceCache (src)
Parameters:
id - The primary key of the bean .
Returns:
The EnterpriseContext related to the given id.
Throws:
java.rmi.NoSuchObjectException - if the bean cannot be found.
java.rmi.RemoteException - In case of illegal calls (concurrent / reentrant)
See Also:
InstanceCache.release(org.jboss.ejb.EnterpriseContext)

insert

public void insert(EnterpriseContext (src)  instance)
Description copied from interface: InstanceCache (src)
Inserts an active bean instance after creation or activation.

Implementation should guarantee proper locking and O(1) complexity.

Specified by:
insert in interface InstanceCache (src)
Parameters:
instance - The EnterpriseContext to insert in the cache
See Also:
InstanceCache.remove(java.lang.Object)

release

public void release(EnterpriseContext (src)  instance)
Description copied from interface: InstanceCache (src)
Releases the given bean instance from this cache. This method may passivate the bean to get it out of the cache. Implementation should return almost immediately leaving the passivation to be executed by another thread.

Specified by:
release in interface InstanceCache (src)
Parameters:
instance - The EnterpriseContext to release
See Also:
InstanceCache.get(java.lang.Object)

remove

public void remove(java.lang.Object id)
Description copied from interface: InstanceCache (src)
Removes a bean instance from this cache given the identity. Implementation should have O(1) complexity and guarantee proper locking.

Specified by:
remove in interface InstanceCache (src)
Parameters:
id - The pimary key of the bean.
See Also:
InstanceCache.insert(org.jboss.ejb.EnterpriseContext)

isActive

public boolean isActive(java.lang.Object id)
Description copied from interface: InstanceCache (src)
Checks whether an instance corresponding to a particular id is active.

Specified by:
isActive in interface InstanceCache (src)
Parameters:
id - The pimary key of the bean.
See Also:
InstanceCache.insert(org.jboss.ejb.EnterpriseContext)

getCacheSize

public long getCacheSize()
Description copied from interface: InstanceCache (src)
Get the current cache size

Specified by:
getCacheSize in interface InstanceCache (src)
Returns:
the size of the cache

flush

public void flush()
Description copied from interface: InstanceCache (src)
Flush the cache.

Specified by:
flush in interface InstanceCache (src)

setContainer

public void setContainer(Container (src)  con)
Description copied from interface: ContainerPlugin (src)
This callback is set by the container so that the plugin may access it

Specified by:
setContainer in interface ContainerPlugin (src)
Parameters:
con - The container using this plugin. This may be null if the plugin is being disassociated from a container.

create

public void create()
            throws java.lang.Exception
Description copied from interface: Service (src)
create the service, do expensive operations etc

Specified by:
create in interface Service (src)
Throws:
java.lang.Exception

start

public void start()
           throws java.lang.Exception
Description copied from interface: Service (src)
start the service, create is already called

Specified by:
start in interface Service (src)
Throws:
java.lang.Exception

stop

public void stop()
Description copied from interface: Service (src)
stop the service

Specified by:
stop in interface Service (src)

destroy

public void destroy()
Description copied from interface: Service (src)
destroy the service, tear down

Specified by:
destroy in interface Service (src)

tryToPassivate

protected void tryToPassivate(EnterpriseContext (src)  instance)

canPassivate

protected boolean canPassivate(EnterpriseContext (src)  ctx)