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

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

    java.lang.Object
      org.jboss.ejb.plugins.lock.BeanLockSupport

All Implemented Interfaces:
  BeanLock, BeanLockExt, org.jboss.util.deadlock.Resource

Direct Known Subclasses:
  NoLock, QueuedPessimisticEJBLock, SimpleReadWriteEJBLock

public abstract class BeanLockSupport
extends Object
implements org.jboss.util.deadlock.Resource, BeanLockExt

Support for the BeanLock

Version:
  $Revision: 1.28.6.1 $
Author:
  Bill Burke, Marc Fleury

Field Summary
`protected Container` | `container`
`protected Object` | `id` The Cachekey corresponding to this Bean
`protected int` | `refs` Number of threads that retrieved this lock from the manager (0 means removing)
`protected Thread` | `synched`
`protected int` | `synchedDepth`
`protected Transaction` | `tx` Transaction holding lock on bean
`protected int` | `txTimeout`

Constructor Summary
`BeanLockSupport()`

Method Summary
`void` | `addRef()` Increment the reference count of this lock.
`boolean` | `attemptSync()` A non-blocking method that checks if the calling thread will be able to acquire the sync lock based on the calling thread.
`abstract void` | `endInvocation(Invocation mi)` Callback to the BeanLock to inform it that a method invocation has ended.
`abstract void` | `endTransaction(Transaction tx)` Informs the lock that the given transaction has ended.
`Object` | `getId()` Get the bean instance cache id for the bean we are locking for.
`int` | `getRefs()` Get the current reference count of this lock.
`Object` | `getResourceHolder()`
`Transaction` | `getTransaction()` Get the transaction currently associated with this lock.
`void` | `releaseSync()` Release exclusive access to this lock instance.
`void` | `removeRef()` Decrement the reference count of this lock.
`abstract void` | `schedule(Invocation mi)` This method implements the actual logic of the lock.
`void` | `setContainer(Container container)` set the ejb container of this lock.
`void` | `setId(Object id)` Set the bean instance cache id for the bean we are locking for.
`void` | `setTimeout(int timeout)` Change long we should wait for a lock.
`void` | `setTransaction(Transaction tx)` The setTransaction associates a transaction with the lock.
`void` | `sync()` A method that checks if the calling thread has the lock, and if it does not blocks until the lock is available.
`abstract void` | `wontSynchronize(Transaction tx)` Signifies to the lock that the transaction will not Synchronize (Tx demarcation not seen).

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

Field Detail

### container

    protected Container container

### refs

    protected int refs

  Number of threads that retrieved this lock from the manager (0 means removing)

### id

    protected Object id

  The Cachekey corresponding to this Bean

### tx

    protected Transaction tx

  Transaction holding lock on bean

### synched

    protected Thread synched

### synchedDepth

    protected int synchedDepth

### txTimeout

    protected int txTimeout

Constructor Detail

### BeanLockSupport

    public BeanLockSupport()

Method Detail

### setId

    public void setId(Object id)

  Description copied from interface: `BeanLock`
  Set the bean instance cache id for the bean we are locking for.

  Specified by:
    `setId` in interface `BeanLock`
  Parameters:
    `id` - The cache key for the bean instance we are locking for.

### getId

    public Object getId()

  Description copied from interface: `BeanLock`
  Get the bean instance cache id for the bean we are locking for.

  Specified by:
    `getId` in interface `BeanLock`
  Returns:
    The cache key for the bean instance we are locking for.

### setTimeout

    public void setTimeout(int timeout)

  Description copied from interface: `BeanLock`
  Change long we should wait for a lock.

  Specified by:
    `setTimeout` in interface `BeanLock`

### setContainer

    public void setContainer(Container container)

  Description copied from interface: `BeanLock`
  set the ejb container of this lock.

  Specified by:
    `setContainer` in interface `BeanLock`

### getResourceHolder

    public Object getResourceHolder()

  Specified by:
    `getResourceHolder` in interface `org.jboss.util.deadlock.Resource`

### attemptSync

    public boolean attemptSync()

  A non-blocking method that checks if the calling thread will be able to acquire the sync lock based on the calling thread.

  Specified by:
    `attemptSync` in interface `BeanLockExt`
  Returns:
    true if the calling thread can obtain the sync lock in which case it will, false if another thread already has the lock.

### sync

    public void sync()

  A method that checks if the calling thread has the lock, and if it does not blocks until the lock is available. If there is no current owner of the lock, or the calling thread already owns the lock then the calling thread will immeadiately acquire the lock.

  Specified by:
    `sync` in interface `BeanLock`

### releaseSync

    public void releaseSync()

  Description copied from interface: `BeanLock`
  Release exclusive access to this lock instance.

  Specified by:
    `releaseSync` in interface `BeanLock`

### schedule

    public abstract void schedule(Invocation mi)
                           throws Exception

  Description copied from interface: `BeanLock`
  This method implements the actual logic of the lock. In the case of an EJB lock it must at least implement the serialization of calls

  Specified by:
    `schedule` in interface `BeanLock`
  Parameters:
    `mi` - The method invocation that needs a lock.
  Throws:
    `Exception`

### setTransaction

    public void setTransaction(Transaction tx)

  The setTransaction associates a transaction with the lock. The current transaction is associated by the schedule call.

  Specified by:
    `setTransaction` in interface `BeanLock`
  Parameters:
    `tx` - The transaction to associate with this lock.

### getTransaction

    public Transaction getTransaction()

  Description copied from interface: `BeanLock`
  Get the transaction currently associated with this lock.

  Specified by:
    `getTransaction` in interface `BeanLock`
  Returns:
    The transaction currently associated with this lock, or `null` if no transaction is currently associated with this lock.

### endTransaction

    public abstract void endTransaction(Transaction tx)

  Description copied from interface: `BeanLock`
  Informs the lock that the given transaction has ended.

  Specified by:
    `endTransaction` in interface `BeanLock`
  Parameters:
    `tx` - The transaction that has ended.

### wontSynchronize

    public abstract void wontSynchronize(Transaction tx)

  Description copied from interface: `BeanLock`
  Signifies to the lock that the transaction will not Synchronize (Tx demarcation not seen).

  OSH: This method does not seem to be called from anywhere. What is it meant for? To be called on a timeout before the transaction has terminated?

  Specified by:
    `wontSynchronize` in interface `BeanLock`

### endInvocation

    public abstract void endInvocation(Invocation mi)

  Description copied from interface: `BeanLock`
  Callback to the BeanLock to inform it that a method invocation has ended. A common use of this method is to release a method lock.

  Specified by:
    `endInvocation` in interface `BeanLock`

### addRef

    public void addRef()

  Description copied from interface: `BeanLock`
  Increment the reference count of this lock.

  Specified by:
    `addRef` in interface `BeanLock`

### removeRef

    public void removeRef()

  Description copied from interface: `BeanLock`
  Decrement the reference count of this lock.

  Specified by:
    `removeRef` in interface `BeanLock`

### getRefs

    public int getRefs()

  Description copied from interface: `BeanLock`
  Get the current reference count of this lock.

  Specified by:
    `getRefs` in interface `BeanLock`
  Returns:
    The current reference count.

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

Copyright © 2002 JBoss Group, LLC. All Rights Reserved.