javax.transaction.TransactionSynchronizationRegistry Java Examples

The following examples show how to use javax.transaction.TransactionSynchronizationRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransactionIntegrationImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor
 * @param tm The transaction manager
 * @param tsr The transaction synchronization registry
 * @param utr The user transaction registry
 * @param terminator The XA terminator
 * @param rr The recovery registry
 */
public TransactionIntegrationImpl(TransactionManager tm,
                                  TransactionSynchronizationRegistry tsr,
                                  org.jboss.tm.usertx.UserTransactionRegistry utr,
                                  org.jboss.tm.JBossXATerminator terminator,
                                  org.jboss.tm.XAResourceRecoveryRegistry rr)
{
   if (tm instanceof org.jboss.tm.TransactionTimeoutConfiguration)
   {
      this.tm = new TransactionManagerDelegator(tm);
   }
   else
   {
      this.tm = tm;
   }
   this.tsr = tsr;
   this.utr = new UserTransactionRegistryImpl(utr);
   this.terminator = terminator;
   this.rr = rr;
}
 
Example #2
Source File: JpaTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void setUp() throws Exception {
    super.setUp();


    // setup tx mgr
    transactionManager = new GeronimoTransactionManager();
    SystemInstance.get().setComponent(TransactionSynchronizationRegistry.class, transactionManager);

    // setup naming
    MockInitialContextFactory.install(Collections.singletonMap("java:comp/TransactionSynchronizationRegistry", transactionManager));
    assertSame(transactionManager, new InitialContext().lookup("java:comp/TransactionSynchronizationRegistry"));

    // Put tx mgr into SystemInstance so OpenJPA can find it
    SystemInstance.get().setComponent(TransactionManager.class, transactionManager);

    // init databases
    jtaDs = createJtaDataSource(transactionManager);
    nonJtaDs = createNonJtaDataSource();
    initializeDatabase(jtaDs);
}
 
Example #3
Source File: DataSources.java    From quarkus with Apache License 2.0 6 votes vote down vote up
public DataSources(DataSourcesBuildTimeConfig dataSourcesBuildTimeConfig,
        DataSourcesRuntimeConfig dataSourcesRuntimeConfig, DataSourcesJdbcBuildTimeConfig dataSourcesJdbcBuildTimeConfig,
        DataSourcesJdbcRuntimeConfig dataSourcesJdbcRuntimeConfig,
        LegacyDataSourcesJdbcBuildTimeConfig legacyDataSourcesJdbcBuildTimeConfig,
        LegacyDataSourcesRuntimeConfig legacyDataSourcesRuntimeConfig,
        LegacyDataSourcesJdbcRuntimeConfig legacyDataSourcesJdbcRuntimeConfig, TransactionManager transactionManager,
        TransactionSynchronizationRegistry transactionSynchronizationRegistry, DataSourceSupport dataSourceSupport,
        @Any Instance<AgroalPoolInterceptor> agroalPoolInterceptors) {
    this.dataSourcesBuildTimeConfig = dataSourcesBuildTimeConfig;
    this.dataSourcesRuntimeConfig = dataSourcesRuntimeConfig;
    this.dataSourcesJdbcBuildTimeConfig = dataSourcesJdbcBuildTimeConfig;
    this.dataSourcesJdbcRuntimeConfig = dataSourcesJdbcRuntimeConfig;
    this.legacyDataSourcesJdbcBuildTimeConfig = legacyDataSourcesJdbcBuildTimeConfig;
    this.legacyDataSourcesRuntimeConfig = legacyDataSourcesRuntimeConfig;
    this.legacyDataSourcesJdbcRuntimeConfig = legacyDataSourcesJdbcRuntimeConfig;
    this.transactionManager = transactionManager;
    this.transactionSynchronizationRegistry = transactionSynchronizationRegistry;
    this.dataSourceSupport = dataSourceSupport;
    this.agroalPoolInterceptors = agroalPoolInterceptors;
}
 
Example #4
Source File: CmrSet.java    From tomee with Apache License 2.0 6 votes vote down vote up
public CmrSet(final EntityBean source, final String sourceProperty, final BeanContext relatedInfo, final String relatedProperty, final Collection<Bean> relatedBeans) {
    this.source = source;
    this.sourceProperty = sourceProperty;
    this.relatedInfo = relatedInfo;
    this.relatedProperty = relatedProperty;
    this.relatedBeans = relatedBeans;

    relatedLocal = relatedInfo.getLocalInterface();
    final TransactionSynchronizationRegistry transactionRegistry = SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class);
    try {
        transactionRegistry.registerInterposedSynchronization(new Synchronization() {
            public void beforeCompletion() {
            }

            public void afterCompletion(final int i) {
                mutable = false;
            }
        });
    } catch (final IllegalStateException ignored) {
        // no tx so not mutable
        mutable = false;
    }
}
 
Example #5
Source File: AbstractPool.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get any transaction synchronization registry associated with the pool.
 * @return The value
 */
protected TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
{
   if (getTransactionIntegration() != null)
      return getTransactionIntegration().getTransactionSynchronizationRegistry();

   return null;
}
 
Example #6
Source File: SimpleBootstrapContext.java    From tomee with Apache License 2.0 5 votes vote down vote up
public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() {
    // for Geronimo transaction manager, it implements XATerminator, TransactionManager & TransactionSynchronizationRegistry
    if (this.xaTerminator != null && this.xaTerminator instanceof TransactionSynchronizationRegistry) {
        return (TransactionSynchronizationRegistry) this.xaTerminator;
    }
    return null;
}
 
Example #7
Source File: EntityContainer.java    From tomee with Apache License 2.0 5 votes vote down vote up
public EntityContainer(final Object id, final SecurityService securityService, final int poolSize) throws OpenEJBException {
    this.containerID = id;
    this.securityService = securityService;
    entrancyTracker = new EntrancyTracker(SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));

    instanceManager = new EntityInstanceManager(this, securityService, poolSize);
}
 
Example #8
Source File: ConfigurableJtaPlatform.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Create a new ConfigurableJtaPlatform instance with the given
 * JTA TransactionManager and optionally a given UserTransaction.
 * @param tm the JTA TransactionManager reference (required)
 * @param ut the JTA UserTransaction reference (optional)
 * @param tsr the JTA 1.1 TransactionSynchronizationRegistry (optional)
 */
public ConfigurableJtaPlatform(TransactionManager tm, @Nullable UserTransaction ut,
		@Nullable TransactionSynchronizationRegistry tsr) {

	Assert.notNull(tm, "TransactionManager reference must not be null");
	this.transactionManager = tm;
	this.userTransaction = (ut != null ? ut : new UserTransactionAdapter(tm));
	this.transactionSynchronizationRegistry = tsr;
}
 
Example #9
Source File: PoolDataSourceCreator.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public DataSource poolManagedWithRecovery(final String name, final XAResourceWrapper xaResourceWrapper, final String driver, final Properties properties) {
    final TransactionManager transactionManager = new TransactionManagerWrapper(OpenEJB.getTransactionManager(), name, xaResourceWrapper);
    final CommonDataSource ds = pool(name, driver, properties);
    if (ds instanceof XADataSource) {
        return new ManagedXADataSource(ds, transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
    }
    return new ManagedDataSource(DataSource.class.cast(ds), transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
}
 
Example #10
Source File: JtaTransactionManager.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Look up the JTA 1.1 TransactionSynchronizationRegistry in JNDI via the configured name.
 * <p>Can be overridden in subclasses to provide a different TransactionManager object.
 * @param registryName the JNDI name of the
 * TransactionSynchronizationRegistry
 * @return the TransactionSynchronizationRegistry object
 * @throws TransactionSystemException if the JNDI lookup failed
 * @see #setJndiTemplate
 * @see #setTransactionSynchronizationRegistryName
 */
protected TransactionSynchronizationRegistry lookupTransactionSynchronizationRegistry(String registryName) throws TransactionSystemException {
	try {
		if (logger.isDebugEnabled()) {
			logger.debug("Retrieving JTA TransactionSynchronizationRegistry from JNDI location [" + registryName + "]");
		}
		return getJndiTemplate().lookup(registryName, TransactionSynchronizationRegistry.class);
	}
	catch (NamingException ex) {
		throw new TransactionSystemException(
				"JTA TransactionSynchronizationRegistry is not available at JNDI location [" + registryName + "]", ex);
	}
}
 
Example #11
Source File: TransactionIntegrationImpl.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Constructor
 * @param tm The transaction manager
 * @param tsr The transaction synchronization registry
 * @param utr The user transaction registry
 * @param terminator The XA terminator
 * @param rr The recovery registry
 */
public TransactionIntegrationImpl(TransactionManager tm,
                                  TransactionSynchronizationRegistry tsr,
                                  UserTransactionRegistry utr,
                                  XATerminator terminator,
                                  XAResourceRecoveryRegistry rr)
{
   this.tm = tm;
   this.tsr = tsr;
   this.utr = utr;
   this.terminator = terminator;
   this.rr = rr;
}
 
Example #12
Source File: CdiJndiTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Test
public void check() {
    assertNotNull(extension.getMgr());
    assertNotNull(extension.getRegistry());
    assertEquals(OpenEJB.getTransactionManager(), extension.getMgr());
    assertEquals(SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class), extension.getRegistry());
}
 
Example #13
Source File: JTADataSourceWrapperFactory.java    From tomee with Apache License 2.0 5 votes vote down vote up
public CommonDataSource create() {
    final TransactionManager transactionManager = OpenEJB.getTransactionManager();

    CommonDataSource cds = findDelegate();
    if (cds instanceof XADataSource) {
        cds = new ManagedXADataSource(cds, transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
    } else {
        cds = new ManagedDataSource(DataSource.class.cast(cds), transactionManager, SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
    }

    if (logSql) {
        cds = DataSourceFactory.makeItLogging(cds, logPackages);
    }
    return cds;
}
 
Example #14
Source File: TransactionRegistryInTimeoutTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void afterCompletion(final int i) {
    try {
        final TransactionSynchronizationRegistry txRegistry = (TransactionSynchronizationRegistry) new InitialContext().lookup("java:comp/TransactionSynchronizationRegistry");
        assertNotNull(txRegistry);
        done++;
        latch.countDown();
    } catch (final NamingException e) {
        throw new IllegalStateException(e);
    }
}
 
Example #15
Source File: CmpContainer.java    From tomee with Apache License 2.0 5 votes vote down vote up
public CmpContainer(final Object id,
                    final TransactionManager transactionManager,
                    final SecurityService securityService,
                    final String cmpEngineFactory) throws OpenEJBException {
    this.containerID = id;
    this.securityService = securityService;
    synchronizationRegistry = SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class);
    entrancyTracker = new EntrancyTracker(synchronizationRegistry);

    // create the cmp engine instance
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    if (classLoader == null) {
        classLoader = getClass().getClassLoader();
    }

    final CmpEngineFactory factory;
    try {
        final Class<?> cmpEngineFactoryClass = classLoader.loadClass(cmpEngineFactory);
        factory = (CmpEngineFactory) cmpEngineFactoryClass.newInstance();
    } catch (final Exception e) {
        throw new OpenEJBException("Unable to create cmp engine factory " + cmpEngineFactory, e);
    }
    factory.setTransactionManager(transactionManager);
    factory.setTransactionSynchronizationRegistry(synchronizationRegistry);
    factory.setCmpCallback(new ContainerCmpCallback());
    cmpEngine = factory.create();
}
 
Example #16
Source File: JtaTransactionManager.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Look up the JTA 1.1 TransactionSynchronizationRegistry in JNDI via the configured name.
 * <p>Can be overridden in subclasses to provide a different TransactionManager object.
 * @param registryName the JNDI name of the
 * TransactionSynchronizationRegistry
 * @return the TransactionSynchronizationRegistry object
 * @throws TransactionSystemException if the JNDI lookup failed
 * @see #setJndiTemplate
 * @see #setTransactionSynchronizationRegistryName
 */
protected TransactionSynchronizationRegistry lookupTransactionSynchronizationRegistry(String registryName) throws TransactionSystemException {
	try {
		if (logger.isDebugEnabled()) {
			logger.debug("Retrieving JTA TransactionSynchronizationRegistry from JNDI location [" + registryName + "]");
		}
		return getJndiTemplate().lookup(registryName, TransactionSynchronizationRegistry.class);
	}
	catch (NamingException ex) {
		throw new TransactionSystemException(
				"JTA TransactionSynchronizationRegistry is not available at JNDI location [" + registryName + "]", ex);
	}
}
 
Example #17
Source File: ManagedTransaction.java    From requery with Apache License 2.0 5 votes vote down vote up
private TransactionSynchronizationRegistry getSynchronizationRegistry() {
    if (registry == null) {
        try {
            registry = InitialContext.doLookup("java:comp/TransactionSynchronizationRegistry");
        } catch (NamingException e) {
            throw new TransactionException(e);
        }
    }
    return registry;
}
 
Example #18
Source File: PersistenceUnitInfoImpl.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void setNonJtaDataSource(final CommonDataSource nonJtaDataSource) {
    if (XADataSource.class.isInstance(nonJtaDataSource)) {
        this.nonJtaDataSource = new DataSourceXADataSource(
                nonJtaDataSource, OpenEJB.getTransactionManager(), SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class));
    } else {
        this.nonJtaDataSource = DataSource.class.cast(nonJtaDataSource);
    }
}
 
Example #19
Source File: TransactionScopedEntityManager.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public TransactionScopedEntityManager(TransactionManager transactionManager,
        TransactionSynchronizationRegistry tsr,
        EntityManagerFactory emf,
        String unitName, Instance<RequestScopedEntityManagerHolder> requestScopedEms) {
    this.transactionManager = transactionManager;
    this.tsr = tsr;
    this.emf = emf;
    this.unitName = unitName;
    this.requestScopedEms = requestScopedEms;
}
 
Example #20
Source File: JtaTransaction.java    From cdi with Apache License 2.0 5 votes vote down vote up
private TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() {
    try {
        return (TransactionSynchronizationRegistry) new InitialContext().lookup(
                TRANSACTION_SYNCHRONIZATION_REGISTRY_LOCATION);
    } catch (NamingException ex) {
        logger.debug("Could not look up TransactionSynchronizationRegistry.", ex);
    }

    return null;
}
 
Example #21
Source File: JtaTransactionManager.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Look up the JTA 1.1 TransactionSynchronizationRegistry in JNDI via the configured name.
 * <p>Can be overridden in subclasses to provide a different TransactionManager object.
 * @param registryName the JNDI name of the
 * TransactionSynchronizationRegistry
 * @return the TransactionSynchronizationRegistry object
 * @throws TransactionSystemException if the JNDI lookup failed
 * @see #setJndiTemplate
 * @see #setTransactionSynchronizationRegistryName
 */
protected TransactionSynchronizationRegistry lookupTransactionSynchronizationRegistry(String registryName) throws TransactionSystemException {
	try {
		if (logger.isDebugEnabled()) {
			logger.debug("Retrieving JTA TransactionSynchronizationRegistry from JNDI location [" + registryName + "]");
		}
		return getJndiTemplate().lookup(registryName, TransactionSynchronizationRegistry.class);
	}
	catch (NamingException ex) {
		throw new TransactionSystemException(
				"JTA TransactionSynchronizationRegistry is not available at JNDI location [" + registryName + "]", ex);
	}
}
 
Example #22
Source File: BuiltInEnvironmentEntries.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void add(final JndiConsumer jndi, final DeploymentModule module, final DeploymentModule app, final boolean defaults) {

        // Standard names
        add(jndi.getEnvEntryMap(), new EnvEntry().name("java:module/ModuleName").value(module.getModuleId()).type(String.class));
        add(jndi.getEnvEntryMap(), new EnvEntry().name("java:app/AppName").value(app.getModuleId()).type(String.class));

        // Standard References to built-in objects
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/BeanManager").type(BeanManager.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/Validator").type(Validator.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/ValidatorFactory").type(ValidatorFactory.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/TransactionManager").type(TransactionManager.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/TransactionSynchronizationRegistry").type(TransactionSynchronizationRegistry.class));

        if (defaults) {
            add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedExecutorService").type(ManagedExecutorService.class));
            add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedScheduledExecutorService").type(ManagedScheduledExecutorService.class));
            add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedThreadFactory").type(ManagedThreadFactory.class));
            add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultContextService").type(ContextService.class));
            try {
                final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
                contextClassLoader.loadClass("org.apache.activemq.ActiveMQSslConnectionFactory");
                final ResourceEnvRef ref = new ResourceEnvRef().name("java:comp/DefaultJMSConnectionFactory")
                    .type(contextClassLoader.loadClass("javax.jms.ConnectionFactory"));
                add(jndi.getResourceEnvRefMap(), ref);
            } catch (final ClassNotFoundException | NoClassDefFoundError notThere) {
                // no-op
            }
        }


        // OpenEJB specific feature
        add(jndi.getEnvEntryMap(), new EnvEntry().name("java:comp/ComponentName").value(jndi.getJndiConsumerName()).type(String.class));

    }
 
Example #23
Source File: AbstractPool.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Init lock
 * @return The lock
 */
private Lock initLock()
{
   TransactionSynchronizationRegistry tsr = getTransactionSynchronizationRegistry();

   if (tsr != null)
      return initLock(tsr);

   return null;
}
 
Example #24
Source File: JtaExtension.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
void findJtaComponents(@Observes final ProcessBean<?> bean) {
    if (!hasManager && bean.getBean().getTypes().contains(TransactionManager.class)) {
        hasManager = true;
    }
    if (!hasRegistry && bean.getBean().getTypes().contains(TransactionSynchronizationRegistry.class)) {
        hasRegistry = true;
    }
}
 
Example #25
Source File: BootstrapContextImpl.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
{
   return transactionSynchronizationRegistry;
}
 
Example #26
Source File: JtaTransactionPolicy.java    From tomee with Apache License 2.0 4 votes vote down vote up
public JtaTransactionPolicy(final TransactionType transactionType, final TransactionManager transactionManager) {
    this.transactionType = transactionType;
    this.transactionManager = transactionManager;
    synchronizationRegistry = SystemInstance.get().getComponent(TransactionSynchronizationRegistry.class);
}
 
Example #27
Source File: CachedConnectionManagerImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Gets transaction synchronization registry
 * @return TransactionSynchronizationRegistry
 */
public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
{
   return transactionIntegration.getTransactionSynchronizationRegistry();
}
 
Example #28
Source File: ManagedXADataSource.java    From tomee with Apache License 2.0 4 votes vote down vote up
public ManagedXADataSource(final CommonDataSource ds, final TransactionManager txMgr, final TransactionSynchronizationRegistry registry) {
    super(ds, txMgr, registry, ds.hashCode());
    this.txMgr = txMgr; // ObjectRecipe and our logic will setTxMgr but we want the original one (wrapper)
}
 
Example #29
Source File: AbstractPool.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean hasConnection(Subject subject, ConnectionRequestInfo cri)
{
   TransactionSynchronizationRegistry tsr = getTransactionSynchronizationRegistry();
   Lock lock = getTSRLock();

   if (lock == null)
      return false;

   try
   {
      lock.lockInterruptibly();
   }
   catch (InterruptedException ie)
   {
      Thread.interrupted();
      return false;
   }
   try
   {
      boolean separateNoTx = false;

      if (noTxSeparatePools)
      {
         separateNoTx = cm.isTransactional();
      }

      // Get specific managed connection pool key
      Object key = getKey(subject, cri, separateNoTx);

      // Get managed connection pool
      ManagedConnectionPool mcp = getManagedConnectionPool(key, subject, cri);

      // Already got one
      ConnectionListener cl = (ConnectionListener)tsr.getResource(mcp);
      if (cl != null)
      {
         return true;
      }
   }
   catch (Throwable t)
   {
      log.debugf(t, "hasConnection error: %s", t.getMessage());
   }
   finally
   {
      lock.unlock();
   }

   return false;
}
 
Example #30
Source File: AbstractPool.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Gets connection listener instance associated with transaction.
 * This method is package protected beacause it is intended only for test case use.
 * Please don't use it in your production code.
 * @param trackByTransaction transaction instance
 * @param mcp the managed connection pool associated with the desired connection listener
 * @return connection listener instance
 * @throws ResourceException Thrown if an error occurs
 */
ConnectionListener getTransactionOldConnection(Transaction trackByTransaction, ManagedConnectionPool mcp)
   throws ResourceException
{
   TransactionSynchronizationRegistry tsr = getTransactionSynchronizationRegistry();
   Lock lock = getTSRLock();

   if (lock == null)
      throw new ResourceException(bundle.unableObtainLock());

   try
   {
      lock.lockInterruptibly();
   }
   catch (InterruptedException ie)
   {
      Thread.interrupted();
      
      throw new ResourceException(bundle.unableObtainLock(), ie);
   }
   try
   {
      // Already got one
      ConnectionListener cl = (ConnectionListener)tsr.getResource(mcp);
      if (cl != null)
      {
         log.tracef("Previous connection tracked by transaction=%s tx=%s", cl, trackByTransaction);
         return cl;
      }

      return null;
   }
   catch (Throwable t)
   {
      throw new ResourceException(bundle.unableGetConnectionListener(), t);
   }
   finally
   {
      lock.unlock();
   }
}