org.jboss.ejb
Interface BeanLock

All Known Subinterfaces:
BeanLockExt
All Known Implementing Classes:
BeanLockSupport, JDBCOptimisticLock, MethodOnlyEJBLock, NoLock, QueuedPessimisticEJBLock, QueuedPessimisticEJBLockNoADE, SimpleReadWriteEJBLock

public interface BeanLock

BeanLock interface

Version:
$Revision: 57209 $

Revisions:

2001/07/29: marcf

  1. Initial revision

20010802: marcf

  1. Moved to a pluggable framework for the locking policies
  2. you specify in jboss.xml what locking-policy you want, eg. pessimistic/optimistic
  3. The BeanLock is now an interface and implementations can be found under ejb/plugins/lock
Author:
Bill Burke, Marc Fleury

Method Summary
 void addRef()
          Increment the reference count of this lock.
 void endInvocation(Invocation mi)
          Callback to the BeanLock to inform it that a method invocation has ended.
 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.
 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.
 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)
          Set the transaction currently associated with this lock.
 void sync()
          Obtain exclusive access to this lock instance.
 void wontSynchronize(Transaction tx)
          Signifies to the lock that the transaction will not Synchronize (Tx demarcation not seen).
 

Method Detail

getId

Object getId()
Get the bean instance cache id for the bean we are locking for.

Returns:
The cache key for the bean instance we are locking for.

setId

void setId(Object id)
Set the bean instance cache id for the bean we are locking for.

Parameters:
id - The cache key for the bean instance we are locking for.

setTimeout

void setTimeout(int timeout)
Change long we should wait for a lock.


setContainer

void setContainer(Container container)
set the ejb container of this lock.


sync

void sync()
Obtain exclusive access to this lock instance.


releaseSync

void releaseSync()
Release exclusive access to this lock instance.


schedule

void schedule(Invocation mi)
              throws Exception
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

Parameters:
mi - The method invocation that needs a lock.
Throws:
Exception

setTransaction

void setTransaction(Transaction tx)
Set the transaction currently associated with this lock. The current transaction is associated by the schedule call.

Parameters:
tx - The transaction to associate with this lock.

getTransaction

Transaction getTransaction()
Get the transaction currently associated with this lock.

Returns:
The transaction currently associated with this lock, or null if no transaction is currently associated with this lock.

endTransaction

void endTransaction(Transaction tx)
Informs the lock that the given transaction has ended.

Parameters:
tx - The transaction that has ended.

wontSynchronize

void wontSynchronize(Transaction tx)
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?


endInvocation

void endInvocation(Invocation mi)
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.


addRef

void addRef()
Increment the reference count of this lock.


removeRef

void removeRef()
Decrement the reference count of this lock.


getRefs

int getRefs()
Get the current reference count of this lock.

Returns:
The current reference count.


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