Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.ejb.plugins.lock
Class SimplePessimisticEJBLock

    java.lang.Object
      |
      +--org.jboss.ejb.plugins.lock.BeanLockSupport
            |
            +--org.jboss.ejb.plugins.lock.SimplePessimisticEJBLock

All Implemented Interfaces:
  BeanLock

public class SimplePessimisticEJBLock
extends BeanLockSupport

Holds all locks for entity beans, not used for stateful.

All BeanLocks have a reference count. When the reference count goes to 0, the lock is released from the id -> lock mapping.

Version:
  $Revision: 1.5.4.3 $

  Revisions:

  2001/07/29: billb

  1. Initial revision

  2001/08/01: marcf

  1. Added the schedule method
  2. The bean lock is now responsible for implementing the locking policies, it was before in the interceptor code it is now factored out allowing for pluggable lock policies (optimistic for ex)
  3. Implemented pessimistic locking and straight spec requirement in the schedule method would need to factor this in an abstract class for the BeanLock that extending policies can use

  2001/08/02: marcf

  1. Did what was said above, moved to an extension based mech with an abstract base class.
  2. This is the simple lock, won't scale well (imho) but is robust in normal operation
  3. The class must now implement schedule and the various notification calls. EndTransaction wontSynchronize can be radically different (N-Lock)
Author:
  Bill Burke, Marc Fleury

Field Summary
`java.lang.Object` | `lock` The actual lock object

Fields inherited from class org.jboss.ejb.plugins.lock.BeanLockSupport
`id, numMethodLocks, reentrant, refs, synched, tx, txTimeout, waiting`

Constructor Summary
`SimplePessimisticEJBLock()`

Method Summary
`protected boolean` | `doSchedule(MethodInvocation mi)` doSchedule implements a particular policy for scheduling the threads coming in.
`void` | `endTransaction(javax.transaction.Transaction transaction)` This is called up synchronization to notify the end of the transaction.
`java.lang.Object` | `getLock()`
`void` | `releaseMethodLock()` if we reach the count of zero it means the instance is free from threads (and reentrency) we wake up the next thread in the currentLock
`void` | `schedule(MethodInvocation mi)`
`void` | `wontSynchronize(javax.transaction.Transaction transaction)` This is called if the synchronization missed registration (Sync interceptor).

Methods inherited from class org.jboss.ejb.plugins.lock.BeanLockSupport
`addMethodLock, addRef, addWaiting, deadlockDetection, getId, getNumMethodLocks, getRefs, getTransaction, isCallAllowed, isMethodLocked, releaseSync, removeRef, removeWaiting, setId, setReentrant, setTimeout, setTransaction, sync`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### lock

    public java.lang.Object lock

  The actual lock object

Constructor Detail

### SimplePessimisticEJBLock

    public SimplePessimisticEJBLock()

Method Detail

### getLock

    public java.lang.Object getLock()

### schedule

    public void schedule(MethodInvocation mi)
                  throws java.lang.Exception

  Overrides:
    `schedule` in class `BeanLockSupport`

### doSchedule

    protected boolean doSchedule(MethodInvocation mi)
                          throws java.lang.Exception

  doSchedule implements a particular policy for scheduling the threads coming in. There is always the spec required "serialization" but we can add custom scheduling in here Synchronizing on lock: a failure to get scheduled must result in a wait() call and a release of the lock. Schedulation must return with lock.
  Returns:
    Returns true if the thread is scheduled to go through the rest of the interceptors. Returns false if the interceptor must try the scheduling again.

### wontSynchronize

    public void wontSynchronize(javax.transaction.Transaction transaction)

  This is called if the synchronization missed registration (Sync interceptor).
  Overrides:
    `wontSynchronize` in class `BeanLockSupport`

### endTransaction

    public void endTransaction(javax.transaction.Transaction transaction)

  This is called up synchronization to notify the end of the transaction.
  Overrides:
    `endTransaction` in class `BeanLockSupport`

### releaseMethodLock

    public void releaseMethodLock()

  if we reach the count of zero it means the instance is free from threads (and reentrency) we wake up the next thread in the currentLock
  Overrides:
    `releaseMethodLock` in class `BeanLockSupport`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000 The JBoss Organization. All Rights Reserved.