org.objectweb.jonas_ejb.container.JEntitySwitch Class Reference

Inherited by org.objectweb.jonas_ejb.container.JEntitySwitchCRC, org.objectweb.jonas_ejb.container.JEntitySwitchCRU, org.objectweb.jonas_ejb.container.JEntitySwitchCS, org.objectweb.jonas_ejb.container.JEntitySwitchDB, and org.objectweb.jonas_ejb.container.JEntitySwitchRO.

Inheritance diagram for org.objectweb.jonas_ejb.container.JEntitySwitch:

Inheritance graph
[legend]
Collaboration diagram for org.objectweb.jonas_ejb.container.JEntitySwitch:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 JEntitySwitch ()
void init (JEntityFactory bf, Object pk)
JEntityLocal getLocal ()
JEntityRemote getRemote ()
TimerService getEntityTimerService ()
void notifyTimeout (Timer timer)
Object getPrimaryKey ()
void bindICtx (Transaction tx, JEntityContext bctx)
synchronized boolean tryBindICtx (Transaction tx, JEntityContext bctx) throws ObjectNotFoundException
JEntityContext getICtx (Transaction tx, JEntityContext newctx)
JEntityContext getICtx (Transaction tx, boolean checkr)
synchronized boolean terminate (Transaction tx)
synchronized JEntityContext mapICtx (Transaction tx, JEntityContext bctx, boolean forced, boolean holdit, boolean checkreentrance)
synchronized void releaseICtx (Transaction tx)
synchronized void discardICtx (Transaction tx)
synchronized void txCompleted (Transaction tx, boolean committed)
int getPolicy ()
abstract int getState ()
JFactory getBeanFactory ()

Protected Member Functions

void registerCtx (Transaction tx, JEntityContext bctx)
void discardContext (Transaction tx, boolean forgetpk, boolean pool)

Protected Attributes

JEntityFactory bf
Object pk = null
JEntityLocal local = null
JEntityRemote remote = null
long inactivityTimeout
boolean shared
int lockpolicy
boolean txUpdates
TimerService myTimerService = null
int countIH = 0
int countIT = 0
int waiters = 0
boolean inDirtyList = false
boolean mustReload = false
boolean mustStore = false
boolean todiscard = false
Transaction blockedtx = null
long timestamp = System.currentTimeMillis()
boolean lazyregister = false
boolean reentrant

Detailed Description

JEntitySwitch is used internally to synchronize accesses to the entity context and thus to the entity bean instance. All parts common to EJBObject and EJBLocalObject should be here. Different policies can be applied to manage context/instance pairs: - only 1 pair (container manages the transaction isolation) - 1 pair for each transaction (transaction isolation managed by DataBase) - 2 pairs (1 for transactional accesses, 1 for non transaction accesses)
Author:
Philippe Durieux

Philippe Coq

Definition at line 59 of file JEntitySwitch.java.


Constructor & Destructor Documentation

org.objectweb.jonas_ejb.container.JEntitySwitch.JEntitySwitch  ) 
 

empty constructor. Object is initialized via init() because it is implemented differently according to jorm mappers.

Definition at line 213 of file JEntitySwitch.java.


Member Function Documentation

void org.objectweb.jonas_ejb.container.JEntitySwitch.bindICtx Transaction  tx,
JEntityContext  bctx
 

bind a JEntityContext for a create method.

Parameters:
tx - the Transaction object
bctx - the JEntityContext to bind

Definition at line 366 of file JEntitySwitch.java.

void org.objectweb.jonas_ejb.container.JEntitySwitch.discardContext Transaction  tx,
boolean  forgetpk,
boolean  pool
[protected]
 

Discard instance/Context and free all objects.

Parameters:
tx - the Transaction object
forgetpk - true if remove pk from the list
pool - true if instance can be pooled.

Definition at line 744 of file JEntitySwitch.java.

References org.objectweb.jonas_ejb.container.JEntityFactory.releaseJContext(), org.objectweb.jonas_ejb.container.JEntityFactory.removeEJB(), and org.objectweb.jonas_ejb.container.JRemote.unexportObject().

Referenced by org.objectweb.jonas_ejb.container.JEntitySwitchCRU.mapICtx(), org.objectweb.jonas_ejb.container.JEntitySwitchRO.passivateIH(), org.objectweb.jonas_ejb.container.JEntitySwitchCS.passivateIH(), org.objectweb.jonas_ejb.container.JEntitySwitchCRU.passivateIH(), and org.objectweb.jonas_ejb.container.JEntitySwitchCRC.passivateIH().

Here is the call graph for this function:

synchronized void org.objectweb.jonas_ejb.container.JEntitySwitch.discardICtx Transaction  tx  ) 
 

Discard a context/instance at end of request. A problem occured on this insance and it must be discarded.

Parameters:
tx - transaction associated to this context

Definition at line 640 of file JEntitySwitch.java.

Referenced by org.objectweb.jonas_ejb.container.JEntityRemote.postInvoke(), and org.objectweb.jonas_ejb.container.JEntityLocal.postInvoke().

JFactory org.objectweb.jonas_ejb.container.JEntitySwitch.getBeanFactory  ) 
 

Returns:
the JFactory

Definition at line 790 of file JEntitySwitch.java.

Referenced by org.objectweb.jonas_ejb.container.JTimerService.getContainer(), org.objectweb.jonas_ejb.container.JTimerService.getEjbName(), and org.objectweb.jonas_ejb.container.JTimerService.getPK().

TimerService org.objectweb.jonas_ejb.container.JEntitySwitch.getEntityTimerService  ) 
 

Obtains the TimerService associated for this Entity Bean (one / pk)

Returns:
a JTimerService instance.

Definition at line 287 of file JEntitySwitch.java.

Referenced by org.objectweb.jonas_ejb.container.JTimerHandle.getTimer(), and org.objectweb.jonas_ejb.container.JEntityContext.getTimerService().

JEntityContext org.objectweb.jonas_ejb.container.JEntitySwitch.getICtx Transaction  tx,
boolean  checkr
 

Get a context/instance associated with this transaction Called at each request on the bean (including remove)

Parameters:
tx - the Transaction object
Returns:
the BeanContext

Definition at line 422 of file JEntitySwitch.java.

JEntityContext org.objectweb.jonas_ejb.container.JEntitySwitch.getICtx Transaction  tx,
JEntityContext  newctx
 

bind a JEntityContext for a remove method. called in case of remove(pk) or remove(handle)

Parameters:
tx - the Transaction object
newctx - the JEntityContext to bind
Returns:
the BeanContext

Definition at line 412 of file JEntitySwitch.java.

JEntityLocal org.objectweb.jonas_ejb.container.JEntitySwitch.getLocal  ) 
 

Returns:
the underlaying EJBLocalObject

Definition at line 272 of file JEntitySwitch.java.

int org.objectweb.jonas_ejb.container.JEntitySwitch.getPolicy  ) 
 

Returns:
lock policy for this bean

Definition at line 777 of file JEntitySwitch.java.

Referenced by org.objectweb.jonas_ejb.container.JEntityContext.initEntityContext().

Object org.objectweb.jonas_ejb.container.JEntitySwitch.getPrimaryKey  ) 
 

Returns:
the Primary Key Object for this instance.

Definition at line 354 of file JEntitySwitch.java.

Referenced by org.objectweb.jonas_ejb.container.JTimerService.createTimer(), org.objectweb.jonas_ejb.container.JTimerService.getPK(), org.objectweb.jonas_ejb.container.JEntityRemote.getPrimaryKey(), org.objectweb.jonas_ejb.container.JEntityLocal.getPrimaryKey(), org.objectweb.jonas_ejb.container.JEntityContext.getPrimaryKey(), org.objectweb.jonas_ejb.container.JTimerService.getTimers(), and org.objectweb.jonas_ejb.container.JEntityFactory.printAllPks().

JEntityRemote org.objectweb.jonas_ejb.container.JEntitySwitch.getRemote  ) 
 

Returns:
the underlaying EJBObject

Definition at line 279 of file JEntitySwitch.java.

Referenced by org.objectweb.jonas_ejb.container.JEntityContext.getEJBObject().

abstract int org.objectweb.jonas_ejb.container.JEntitySwitch.getState  )  [pure virtual]
 

Returns:
State of this instance. State values are 0=in-tx, 1=out-tx, 2=idle, 3=passive, 4=removed. we don't synchronize this method to avoid jadmin blocks

Implemented in org.objectweb.jonas_ejb.container.JEntitySwitchCRC, org.objectweb.jonas_ejb.container.JEntitySwitchCRU, org.objectweb.jonas_ejb.container.JEntitySwitchCS, org.objectweb.jonas_ejb.container.JEntitySwitchDB, and org.objectweb.jonas_ejb.container.JEntitySwitchRO.

Referenced by org.objectweb.jonas_ejb.container.JEntityFactory.getEntityCounters().

void org.objectweb.jonas_ejb.container.JEntitySwitch.init JEntityFactory  bf,
Object  pk
 

constructor. A new object is build when a new PK is known in the container, either when a new bean is created, or when a find occurs. For create(), PK is not known yet when this object is build.

Parameters:
bf The Entity Factory
pk The Primary Key

Definition at line 223 of file JEntitySwitch.java.

References org.objectweb.jonas_ejb.container.JEntityFactory.getHome(), org.objectweb.jonas_ejb.container.JEntityFactory.getInactivityTimeout(), org.objectweb.jonas_ejb.container.JEntityFactory.getLocalHome(), org.objectweb.jonas_ejb.container.JEntityFactory.isReentrant(), org.objectweb.jonas_ejb.container.JEntityFactory.isShared(), org.objectweb.jonas_ejb.container.JEntityLocal.setEntitySwitch(), and org.objectweb.jonas_ejb.container.JEntityRemote.setEntitySwitch().

Referenced by org.objectweb.jonas_ejb.container.JEntityFactory.bindEJB(), org.objectweb.jonas_ejb.container.JEntityFactory.getEJB(), and org.objectweb.jonas_ejb.container.JEntityFactory.rebindEJB().

Here is the call graph for this function:

synchronized JEntityContext org.objectweb.jonas_ejb.container.JEntitySwitch.mapICtx Transaction  tx,
JEntityContext  bctx,
boolean  forced,
boolean  holdit,
boolean  checkreentrance
 

Map a context and its instance.

Parameters:
tx - the Transaction object
bctx - the JEntityContext to bind if not null
forced - force to take this context. (case of create)
holdit - increment count to hold it, a release will be called later.
Returns:
JEntityContext actually mapped

Reimplemented in org.objectweb.jonas_ejb.container.JEntitySwitchCRU, and org.objectweb.jonas_ejb.container.JEntitySwitchRO.

Definition at line 467 of file JEntitySwitch.java.

References org.objectweb.jonas_ejb.container.JEntityContext.activate(), org.objectweb.jonas_ejb.container.JEntityFactory.getJContext(), org.objectweb.jonas_ejb.container.JEntityContext.initEntityContext(), org.objectweb.jonas_ejb.container.JEntityFactory.registerEJB(), org.objectweb.jonas_ejb.container.JEntityFactory.releaseJContext(), and org.objectweb.jonas_ejb.container.JEntityContext.reuseEntityContext().

Here is the call graph for this function:

void org.objectweb.jonas_ejb.container.JEntitySwitch.notifyTimeout Timer  timer  ) 
 

Notify a timeout for this bean and this Pk

Parameters:
timer timer whose expiration caused this notification.

Definition at line 304 of file JEntitySwitch.java.

References org.objectweb.jonas_ejb.container.JFactory.checkSecurity(), org.objectweb.jonas_ejb.container.RequestCtx.currTx, org.objectweb.jonas_ejb.container.JEntityContext.getInstance(), org.objectweb.jonas_ejb.container.JFactory.getTimerTxAttribute(), org.objectweb.jonas_ejb.container.JFactory.postInvoke(), org.objectweb.jonas_ejb.container.JFactory.preInvoke(), and org.objectweb.jonas_ejb.container.RequestCtx.sysExc.

Referenced by org.objectweb.jonas_ejb.container.JTimerService.notify().

Here is the call graph for this function:

void org.objectweb.jonas_ejb.container.JEntitySwitch.registerCtx Transaction  tx,
JEntityContext  bctx
[protected]
 

register a Context on the transaction, as a Synchronization. this will be used later to store instance state when needed : before a finder, or at beforeCompletion, and to release instance at commit.

Parameters:
tx Transaction object
bctx The Context to be registered

Definition at line 722 of file JEntitySwitch.java.

References org.objectweb.jonas_ejb.container.JEntityFactory.registerContext(), and org.objectweb.jonas_ejb.container.JEntityContext.setRunningTx().

Referenced by org.objectweb.jonas_ejb.container.JEntitySwitchDB.notifyWriting(), and org.objectweb.jonas_ejb.container.JEntitySwitchCRU.notifyWriting().

Here is the call graph for this function:

synchronized void org.objectweb.jonas_ejb.container.JEntitySwitch.releaseICtx Transaction  tx  ) 
 

Release a context/instance at end of request.

Parameters:
tx - transaction associated to this context

Definition at line 595 of file JEntitySwitch.java.

References org.objectweb.jonas_ejb.container.JEntityContext.isMarkedRemoved(), and org.objectweb.jonas_ejb.container.JEntityContext.storeIfModified().

Referenced by org.objectweb.jonas_ejb.container.JEntityRemote.postInvoke(), and org.objectweb.jonas_ejb.container.JEntityLocal.postInvoke().

Here is the call graph for this function:

synchronized boolean org.objectweb.jonas_ejb.container.JEntitySwitch.terminate Transaction  tx  ) 
 

Release completely this object, since another one will be used. this occurs in case of create, when another EntitySwitch exist already.

Parameters:
tx - the Transaction object

Definition at line 432 of file JEntitySwitch.java.

References org.objectweb.jonas_ejb.container.JEntityContext.isMarkedRemoved(), org.objectweb.jonas_ejb.container.JEntityContext.passivate(), and org.objectweb.jonas_ejb.container.JEntityContext.storeIfModified().

Referenced by org.objectweb.jonas_ejb.container.JEntityFactory.rebindEJB().

Here is the call graph for this function:

synchronized boolean org.objectweb.jonas_ejb.container.JEntitySwitch.tryBindICtx Transaction  tx,
JEntityContext  bctx
throws ObjectNotFoundException
 

Try to bind a JEntityContext if none already bound. Called by finder methods

Parameters:
tx - the Transaction object
bctx The Entity Context
Returns:
true if context has been bound to this EntitySwitch.

Definition at line 377 of file JEntitySwitch.java.

synchronized void org.objectweb.jonas_ejb.container.JEntitySwitch.txCompleted Transaction  tx,
boolean  committed
 

This transaction is now over. We can dispose of the instance for another transaction or discard it.

Parameters:
tx the transaction object
committed true if transaction was committed.

Definition at line 664 of file JEntitySwitch.java.

References org.objectweb.jonas_ejb.container.JEntityContext.detachTx(), org.objectweb.jonas_ejb.container.JEntityContext.isMarkedRemoved(), org.objectweb.jonas_ejb.container.JEntityContext.isNewInstance(), org.objectweb.jonas_ejb.container.JEntityContext.passivate(), and org.objectweb.jonas_ejb.container.JEntityFactory.releaseJContext().

Referenced by org.objectweb.jonas_ejb.container.JEntityContext.afterCompletion().

Here is the call graph for this function:


Member Data Documentation

JEntityFactory org.objectweb.jonas_ejb.container.JEntitySwitch.bf [protected]
 

The Factory for this bean

Definition at line 64 of file JEntitySwitch.java.

Transaction org.objectweb.jonas_ejb.container.JEntitySwitch.blockedtx = null [protected]
 

last transaction blocked by synchronization. this is to do a very basic deadlock detection.

Definition at line 166 of file JEntitySwitch.java.

int org.objectweb.jonas_ejb.container.JEntitySwitch.countIH = 0 [protected]
 

nb of non transacted requests running

Definition at line 117 of file JEntitySwitch.java.

int org.objectweb.jonas_ejb.container.JEntitySwitch.countIT = 0 [protected]
 

nb of transacted requests running

Definition at line 122 of file JEntitySwitch.java.

long org.objectweb.jonas_ejb.container.JEntitySwitch.inactivityTimeout [protected]
 

time in millisec. to keep objects in memory when not used.

Definition at line 84 of file JEntitySwitch.java.

boolean org.objectweb.jonas_ejb.container.JEntitySwitch.inDirtyList = false [protected]
 

True if this instance may have been modified outside transactions. Avoids to put it twice in dirty list.

Definition at line 133 of file JEntitySwitch.java.

boolean org.objectweb.jonas_ejb.container.JEntitySwitch.lazyregister = false [protected]
 

true if we can differ the registration at first write.

Definition at line 187 of file JEntitySwitch.java.

JEntityLocal org.objectweb.jonas_ejb.container.JEntitySwitch.local = null [protected]
 

The EJBLocalObject, or null if bean has no local interface.

Definition at line 74 of file JEntitySwitch.java.

int org.objectweb.jonas_ejb.container.JEntitySwitch.lockpolicy [protected]
 

Lock policy used for this entity bean. Possible values are :

0 = LOCK_CONTAINER_READ_UNCOMMITTED (1 instance) 1 = LOCK_CONTAINER_SERIALIZED (1 instance) 2 = LOCK_CONTAINER_READ_COMMITTED (2 instances) 3 = LOCK_DATABASE (n instances) 4 = LOCK_READ_ONLY (1 instance)

Definition at line 101 of file JEntitySwitch.java.

boolean org.objectweb.jonas_ejb.container.JEntitySwitch.mustReload = false [protected]
 

True if instance has been modified by a Transaction. This means that reading outside transaction should reload it before use. Always false for policies CS and CRU (only 1 instance)

Definition at line 140 of file JEntitySwitch.java.

boolean org.objectweb.jonas_ejb.container.JEntitySwitch.mustStore = false [protected]
 

True if a TX need this instance currently used outside tx When the last release is done, we must store this instance.

Definition at line 146 of file JEntitySwitch.java.

TimerService org.objectweb.jonas_ejb.container.JEntitySwitch.myTimerService = null [protected]
 

The Timer Service

Definition at line 112 of file JEntitySwitch.java.

Object org.objectweb.jonas_ejb.container.JEntitySwitch.pk = null [protected]
 

The Primary Key for this bean instance.

Definition at line 69 of file JEntitySwitch.java.

boolean org.objectweb.jonas_ejb.container.JEntitySwitch.reentrant [protected]
 

reentrant=true if a bean instance can be accessed concurrently in the same transaction, or outside transaction.

Definition at line 193 of file JEntitySwitch.java.

JEntityRemote org.objectweb.jonas_ejb.container.JEntitySwitch.remote = null [protected]
 

The EJBObject, or null if bean has no remote interface.

Definition at line 79 of file JEntitySwitch.java.

boolean org.objectweb.jonas_ejb.container.JEntitySwitch.shared [protected]
 

shared=true if the bean can be modify outside this container.

Definition at line 89 of file JEntitySwitch.java.

long org.objectweb.jonas_ejb.container.JEntitySwitch.timestamp = System.currentTimeMillis() [protected]
 

timestamp used to free objects when not used for a specified time.

Definition at line 178 of file JEntitySwitch.java.

boolean org.objectweb.jonas_ejb.container.JEntitySwitch.todiscard = false [protected]
 

True when context/instance has been discarded, to avoids that passivate store its state on storage.

Definition at line 152 of file JEntitySwitch.java.

boolean org.objectweb.jonas_ejb.container.JEntitySwitch.txUpdates [protected]
 

True if a transaction is mandatory for all modifying methods. In this case, all methods outside tranction is considered as read-only.

Definition at line 107 of file JEntitySwitch.java.

int org.objectweb.jonas_ejb.container.JEntitySwitch.waiters = 0 [protected]
 

nb of threads waiting (synchronization)

Definition at line 127 of file JEntitySwitch.java.


The documentation for this class was generated from the following file:
Generated on Tue Feb 15 15:10:15 2005 for JOnAS by  doxygen 1.3.9.1