## org.jboss.ejb.plugins
Class EntityInstanceInterceptor

    java.lang.Object
      |
      +--org.jboss.ejb.plugins.AbstractInterceptor
            |
            +--org.jboss.ejb.plugins.EntityInstanceInterceptor

All Implemented Interfaces:
  ContainerPlugin, Interceptor, Service

public class EntityInstanceInterceptor
extends AbstractInterceptor

The instance interceptors role is to acquire a context representing the target object from the cache.

This particular container interceptor implements pessimistic locking on the transaction that is associated with the retrieved instance. If there is a transaction associated with the target component and it is different from the transaction associated with the MethodInvocation coming in then the policy is to wait for transactional commit.

We also implement serialization of calls in here (this is a spec requirement). This is a fine grained notify, notifyAll mechanism. We notify on ctx serialization locks and notifyAll on global transactional locks.

WARNING: critical code, get approval from senior developers before changing.

Version:
  $Revision: 1.30.2.10 $

  Revisions:

  2001/06/28: marcf

  1. Moved to new synchronization
  2. Pools are gone simple design
  3. two levels of syncrhonization with Tx and ctx
  4. remove busy wait from previous mechanisms

  2001/07/11: starksm

  1. Fix a thread starvation problem due to incomplete condition notification
  2. Add support for trace level diagnositics

  2001/07/12: starksm

  1. Handle a race condition when there is no ctx transaction

  2001/07/16: billb

  1. Added wait(timeout) code, commented out so that we can easily turn it on when this new code is done with it's trial period.
  2. Fixed bug when ejbLoad threw an exception and threads waiting on TxLock did not get awakened.

  2001/07/26: billb

  1. Locking is now separate from EntityEnterpriseContext objects and is now encapsulated in BeanLock and BeanLockManager. Did this because the lifetime of an EntityLock is sometimes longer than the lifetime of the ctx.

  2001/08/1: marcf

  1. Taking the lock out pointed to something new, the fact that the locking policies can be fully automated and factored out of the instance interceptor this results in a new interceptor EntityLockInterceptor that by design sits in front of this one in the chain of interceptors.
  2. This interceptor is greatly simplified and all it does is retrieve the instance from cache
  3. Scheduling is implemented in new interceptor, all notify policies gone, simple
  4. For the record, locking went from cache (early 2.0) -> this interceptor -> new interceptor
  5. new locking is pluggable

  2001/10/18: billb

  1. Do not insert bean into cache on an exception
Author:
  Marc Fleury, Scott Stark, Bill Burke

Field Summary
`protected EntityContainer` `container`

Fields inherited from class org.jboss.ejb.plugins.AbstractInterceptor
`log, nextInterceptor`

Constructor Summary
`EntityInstanceInterceptor()`

Method Summary
`protected void` `clearLockTx(MethodInvocation mi, java.lang.Exception e, boolean trace)`
`Container` `getContainer()`
`java.lang.Object` `invoke(MethodInvocation mi)`
`java.lang.Object` `invokeHome(MethodInvocation mi)`
`void` `setContainer(Container container)` This callback is set by the container so that the plugin may access it

Methods inherited from class org.jboss.ejb.plugins.AbstractInterceptor
`destroy, getNext, init, setNext, start, stop`

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

Field Detail

### container

    protected EntityContainer container

Constructor Detail

### EntityInstanceInterceptor

    public EntityInstanceInterceptor()

Method Detail

### setContainer

    public void setContainer(Container container)

  Description copied from interface: `ContainerPlugin`
  This callback is set by the container so that the plugin may access it
  Overrides:
    `setContainer` in class `AbstractInterceptor`
  Following copied from interface: `org.jboss.ejb.ContainerPlugin`
  Parameters:
    `con` - the container using this plugin

### getContainer

    public Container getContainer()

  Overrides:
    `getContainer` in class `AbstractInterceptor`

### invokeHome

    public java.lang.Object invokeHome(MethodInvocation mi)
                                throws java.lang.Exception

  Overrides:
    `invokeHome` in class `AbstractInterceptor`

### invoke

    public java.lang.Object invoke(MethodInvocation mi)
                            throws java.lang.Exception

  Overrides:
    `invoke` in class `AbstractInterceptor`

### clearLockTx

    protected void clearLockTx(MethodInvocation mi,
                               java.lang.Exception e,
                               boolean trace)

Copyright © 2000 The JBoss Organization. All Rights Reserved.