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 QueuedPessimisticEJBLock

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

All Implemented Interfaces:
  BeanLock

Direct Known Subclasses:
  MethodOnlyEJBLock

public class QueuedPessimisticEJBLock
extends BeanLockSupport

This class is holds threads awaiting the transactional lock to be free in a fair FIFO transactional queue. Non-transactional threads are also put in this wait queue as well. Unlike SimplePessimisticEJBLock which notifies all threads on transaction completion, this class pops the next waiting transaction from the queue and notifies only those threads waiting associated with that transaction. This class should perform better than Simple on high contention loads. 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. FIXME marcf: we should get solid numbers on this locking, bench in multi-thread environments We need someone with serious SUN hardware to run this lock into the ground

Version:
  $Revision: 1.3.4.10 $

  Revisions:

  2001/08/03: billb

  1. Initial revision
Author:
  Marc Fleury, Bill Burke

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

Constructor Summary
`QueuedPessimisticEJBLock()`

Method Summary
`protected boolean` | `attemptMethodLock(MethodInvocation mi, boolean trace)` Attempt to acquire a method lock.
`protected boolean` | `doSchedule(MethodInvocation mi)` doSchedule(MethodInvocation) doSchedule implements a particular policy for scheduling the threads coming in.
`void` | `endTransaction(javax.transaction.Transaction transaction)`
`protected org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.TxLock` | `getTxLock(javax.transaction.Transaction miTx)`
`protected boolean` | `isTxExpired(javax.transaction.Transaction miTx)`
`protected void` | `nextTransaction()`
`void` | `releaseMethodLock()` 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` | `removeRef()`
`void` | `schedule(MethodInvocation mi)`
`java.lang.String` | `toString()`
`protected boolean` | `waitForTx(javax.transaction.Transaction miTx, boolean trace)` Wait until no other transaction is running with this lock.
`void` | `wontSynchronize(javax.transaction.Transaction trasaction)`

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

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

Constructor Detail

### QueuedPessimisticEJBLock

    public QueuedPessimisticEJBLock()

Method Detail

### getTxLock

    protected org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.TxLock getTxLock(javax.transaction.Transaction miTx)

### isTxExpired

    protected boolean isTxExpired(javax.transaction.Transaction miTx)
                           throws java.lang.Exception

### 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(MethodInvocation) 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.

### waitForTx

    protected boolean waitForTx(javax.transaction.Transaction miTx,
                                boolean trace)
                         throws java.lang.Exception

  Wait until no other transaction is running with this lock.
  Returns:
    Returns true if this thread was scheduled in txWaitQueue

### attemptMethodLock

    protected boolean attemptMethodLock(MethodInvocation mi,
                                        boolean trace)
                                 throws java.lang.Exception

  Attempt to acquire a method lock.

### nextTransaction

    protected void nextTransaction()

### endTransaction

    public void endTransaction(javax.transaction.Transaction transaction)

  Overrides:
    `endTransaction` in class `BeanLockSupport`

### wontSynchronize

    public void wontSynchronize(javax.transaction.Transaction trasaction)

  Overrides:
    `wontSynchronize` in class `BeanLockSupport`

### releaseMethodLock

    public void releaseMethodLock()

  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`

### removeRef

    public void removeRef()

  Overrides:
    `removeRef` in class `BeanLockSupport`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

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.