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
Class EntitySynchronizationInterceptor

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

All Implemented Interfaces:
  ContainerPlugin, Interceptor, Service

Direct Known Subclasses:
  EntityMultiInstanceSynchronizationInterceptor

public class EntitySynchronizationInterceptor
extends AbstractInterceptor

The role of this interceptor is to synchronize the state of the cache with the underlying storage. It does this with the ejbLoad and ejbStore semantics of the EJB specification. In the presence of a transaction this is triggered by transaction demarcation. It registers a callback with the underlying transaction monitor through the JTA interfaces. If there is no transaction the policy is to store state upon returning from invocation. The synchronization polices A,B,C of the specification are taken care of here.

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

Version:
  $Revision: 1.37.2.5 $

  Revisions:

  2001/06/28: marcf

  1. Moved to new synchronization
  2. afterCompletion doesn't return to pool anymore, idea is to simplify design by not mucking with reuse of the instances
  3. before completion checks for a rolledback tx and doesn't call the store in case of a rollback we are notified but we don't register the resource

  2001/07/12: starksm

  1. Fixed invalid use of the ctx.transaction in beforeCompletion
  2. Added clearContextTx to make sure clean up of ctx.tx was done consistently
  3. Clean up the EntityContainer cast-fest

  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/01: marcf

  1. Updated BeanLock to work in new interceptor and out of InstanceInterceptor so we update here as well to use the new interceptor lock logic and the BeanLock that bill introduced
  2. Make use of clearContextTx in all exceptional cases

  2001/08/02: marcf

  1. Moved policy to pluggable framework. Work through the interface of the lock only Use of "endTransaction" and "wontSynchronize" to communicate with the lock

  2001/08/07: billb

  1. Moved storeEntity to EntityContainer.
  2. invokeHome is now scheduled
  3. made InstanceSynchronization protected so that I could inherit from it
  4. made a protected method createSynchronization for inheritance purposes.

  2001/10/11: billb

  1. do not call cache.release if entity has been removed

  2001/10/18: billb

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

Inner Class Summary
`protected class` | `EntitySynchronizationInterceptor.InstanceSynchronization`

Field Summary
`protected int` | `commitOption` The current commit option.
`protected EntityContainer` | `container` The container of this interceptor.
`protected long` | `optionDRefreshRate` The refresh rate for commit option d
`protected java.util.HashSet` | `validContexts` For commit option D this is the cache of valid entities

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

Constructor Summary
`EntitySynchronizationInterceptor()`

Method Summary
`protected void` | `clearContextTx(java.lang.String msg, EntityEnterpriseContext ctx, javax.transaction.Transaction tx, boolean trace)`
`protected javax.transaction.Synchronization` | `createSynchronization(javax.transaction.Transaction tx, EntityEnterpriseContext ctx)`
`Container` | `getContainer()`
`void` | `init()`
`java.lang.Object` | `invoke(MethodInvocation mi)`
`java.lang.Object` | `invokeHome(MethodInvocation mi)`
`protected void` | `register(EntityEnterpriseContext ctx, javax.transaction.Transaction tx)` Register a transaction synchronization callback with a context.
`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, setNext, start, stop`

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

Field Detail

### commitOption

    protected int commitOption

  The current commit option.

### optionDRefreshRate

    protected long optionDRefreshRate

  The refresh rate for commit option d

### container

    protected EntityContainer container

  The container of this interceptor.

### validContexts

    protected java.util.HashSet validContexts

  For commit option D this is the cache of valid entities

Constructor Detail

### EntitySynchronizationInterceptor

    public EntitySynchronizationInterceptor()

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

### init

    public void init()
              throws java.lang.Exception

  Overrides:
    `init` in class `AbstractInterceptor`

### getContainer

    public Container getContainer()

  Overrides:
    `getContainer` in class `AbstractInterceptor`

### createSynchronization

    protected javax.transaction.Synchronization createSynchronization(javax.transaction.Transaction tx,
                                                                      EntityEnterpriseContext ctx)

### register

    protected void register(EntityEnterpriseContext ctx,
                            javax.transaction.Transaction tx)

  Register a transaction synchronization callback with a context.

### 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`

### clearContextTx

    protected void clearContextTx(java.lang.String msg,
                                  EntityEnterpriseContext ctx,
                                  javax.transaction.Transaction tx,
                                  boolean trace)

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.