javax.resource.spi.TransactionSupport.TransactionSupportLevel Java Examples

The following examples show how to use javax.resource.spi.TransactionSupport.TransactionSupportLevel. 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: TomEEManagedConnectionFactory.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void setTransactionSupport(String transactionSupport) {
    if (transactionSupport == null) {
        throw new IllegalArgumentException("transactionSupport cannot be not null");
    } else {
        switch (transactionSupport.toLowerCase(Locale.ENGLISH)) {
            case "xa":
                transactionSupportLevel = TransactionSupportLevel.XATransaction;
                break;
            case "local":
                transactionSupportLevel = TransactionSupportLevel.LocalTransaction;
                break;
            case "none":
                transactionSupportLevel = TransactionSupportLevel.NoTransaction;
                break;
            default:
                throw new IllegalArgumentException("transactionSupport must be xa, local, or none:" + transactionSupport);
        }
    }
}
 
Example #2
Source File: TomEEManagedConnectionProxy.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public Session createSession() throws JMSException {
    int mode;
    boolean xa;
    TransactionSupportLevel transactionSupportLevel;
    if (connection instanceof TomEEManagedConnection) {
        transactionSupportLevel = ((TomEEManagedConnection) connection).getTransactionSupportLevel();
    } else {
        transactionSupportLevel = TransactionSupportLevel.XATransaction;
    }
    switch (transactionSupportLevel) {
        case XATransaction:
            if (JMS2.inTx()) {
                mode = -1;
                xa = true;
                break;
            }
        case NoTransaction:
            mode = JMSContext.AUTO_ACKNOWLEDGE;
            xa = false;
            break;
        case LocalTransaction:
            mode = JMSContext.SESSION_TRANSACTED;
            xa = false;
            break;
        default:
            throw new IllegalStateException("transactionSupportLevel mode not supported:" + transactionSupportLevel);
    }
    if (xa) {
        return createXASession();
    } else {
        return connection.getPhysicalConnection().createSession(mode);
    }
}
 
Example #3
Source File: TomEEManagedConnectionProxy.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
    int mode;
    boolean xa;
    TransactionSupportLevel transactionSupportLevel;
    if (connection instanceof TomEEManagedConnection) {
        transactionSupportLevel = ((TomEEManagedConnection) connection).getTransactionSupportLevel();
    } else if (!transacted) {
        transactionSupportLevel = TransactionSupportLevel.NoTransaction;
    } else {
        transactionSupportLevel = TransactionSupportLevel.XATransaction;
    }
    switch (transactionSupportLevel) {
        case XATransaction:
            if (JMS2.inTx()) {
                mode = -1;
                xa = true;
                break;
            }
        case NoTransaction:
            mode = acknowledgeMode;
            xa = false;
            break;
        case LocalTransaction:
            mode = JMSContext.SESSION_TRANSACTED;
            xa = false;
            break;
        default:
            throw new IllegalStateException("transactionSupportLevel mode not supported:" + transactionSupportLevel);
    }
    if (xa) {
        return createXASession();
    } else {
        return connection.getPhysicalConnection().createSession(mode);
    }
}
 
Example #4
Source File: TomEEManagedConnection.java    From tomee with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public TomEEManagedConnection(final Subject subject, final ActiveMQConnection physicalConnection,
                              final ActiveMQConnectionRequestInfo info, TransactionSupportLevel transactionSupportLevel) throws ResourceException {
    super(subject, physicalConnection, info);
    try {
        proxyConnections = Collection.class.cast(PROXY_CONNECTIONS_FIELD.get(this));
    } catch (final IllegalAccessException e) {
        throw new IllegalStateException("Incompatible AMQ", e);
    }
    this.transactionSupportLevel = transactionSupportLevel;
}
 
Example #5
Source File: TomEERAConnectionFactory.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void setTransactionSupport(TransactionSupportLevel transactionSupportLevel) {
    if (transactionSupportLevel == null) {
        throw new IllegalArgumentException("transactionSupportLevel cannot be null");
    } else {
        this.transactionSupportLevel = transactionSupportLevel;
    }
}
 
Example #6
Source File: CCMNoTransactionTestCase.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * The activation
 * @throws Throwable In case of an error
 */
@Deployment(order = 2)
private static ResourceAdaptersDescriptor createActivation() throws Throwable
{
   return ResourceAdapterFactory.createTxLogDeployment(TransactionSupportLevel.NoTransaction,
                                                       "", Boolean.FALSE);
}
 
Example #7
Source File: CCMXATransactionTestCase.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * The activation
 * @throws Throwable In case of an error
 */
@Deployment(order = 2)
private static ResourceAdaptersDescriptor createActivation() throws Throwable
{
   return ResourceAdapterFactory.createTxLogDeployment(TransactionSupportLevel.XATransaction,
                                                       "", Boolean.FALSE);
}
 
Example #8
Source File: CCMLocalTransactionTestCase.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * The activation
 * @throws Throwable In case of an error
 */
@Deployment(order = 2)
private static ResourceAdaptersDescriptor createActivation() throws Throwable
{
   return ResourceAdapterFactory.createTxLogDeployment(TransactionSupportLevel.LocalTransaction,
                                                       "", Boolean.FALSE);
}
 
Example #9
Source File: AbstractPool.java    From ironjacamar with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public ConnectionListener getActiveConnectionListener(Credential credential)
{
   if (cm.getTransactionSupport() == TransactionSupportLevel.NoTransaction)
      return null;

   try
   {
      TransactionalConnectionManager txCM = (TransactionalConnectionManager) cm;
      Transaction tx = txCM.getTransactionIntegration().getTransactionManager().getTransaction();

      if (TxUtils.isUncommitted(tx))
      {
         Object id = txCM.getTransactionIntegration().getTransactionSynchronizationRegistry().getTransactionKey();
         Map<ManagedConnectionPool, ConnectionListener> currentMap = transactionMap.get(id);
         ManagedConnectionPool key = pools.get(credential);

         return currentMap.get(key);
      }
   }
   catch (Exception e)
   {
      log.tracef(e, "getActiveConnectionListener(%s)", credential);
   }

   return null;
}
 
Example #10
Source File: EnlistmentNoTransactionTestCase.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * The activation
 * @throws Throwable In case of an error
 */
@Deployment(order = 2)
private static ResourceAdaptersDescriptor createActivation() throws Throwable
{
   return ResourceAdapterFactory.createTxLogDeployment(TransactionSupportLevel.NoTransaction);
}
 
Example #11
Source File: EnlistmentLocalTransactionTestCase.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * The activation for resource 2
 * @throws Throwable In case of an error
 */
@Deployment(order = 3)
private static ResourceAdaptersDescriptor createActivationTwo() throws Throwable
{
   return ResourceAdapterFactory.createTxLogDeployment(TransactionSupportLevel.LocalTransaction, "2");
}
 
Example #12
Source File: EnlistmentXATransactionTestCase.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * The activation for resource 1
 * @throws Throwable In case of an error
 */
@Deployment(order = 2)
private static ResourceAdaptersDescriptor createActivationOne() throws Throwable
{
   return ResourceAdapterFactory.createTxLogDeployment(TransactionSupportLevel.XATransaction, "1");
}
 
Example #13
Source File: EnlistmentXATransactionTestCase.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * The activation for resource 2
 * @throws Throwable In case of an error
 */
@Deployment(order = 3)
private static ResourceAdaptersDescriptor createActivationTwo() throws Throwable
{
   return ResourceAdapterFactory.createTxLogDeployment(TransactionSupportLevel.XATransaction, "2");
}
 
Example #14
Source File: XAResourceTimeoutTestCase.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * The activation for resource 1
 * @throws Throwable In case of an error
 */
@Deployment(order = 2)
private static ResourceAdaptersDescriptor createActivation() throws Throwable
{
   return ResourceAdapterFactory.createTxLogDeployment(TransactionSupportLevel.XATransaction);
}
 
Example #15
Source File: StablePool.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public ConnectionListener createConnectionListener(Credential credential, ManagedConnectionPool mcp)
   throws ResourceException
{
   try
   {
      if (semaphore.tryAcquire(poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS))
      {
         long start = getInternalStatistics().isEnabled() ? System.currentTimeMillis() : 0L;

         ManagedConnection mc =
            cm.getManagedConnectionFactory().createManagedConnection(credential.getSubject(),
                                                                     credential.getConnectionRequestInfo());

         if (getInternalStatistics().isEnabled())
         {
            getInternalStatistics().deltaCreatedCount();
            getInternalStatistics().deltaTotalCreationTime(System.currentTimeMillis() - start);
         }

         if (cm.getTransactionSupport() == TransactionSupportLevel.NoTransaction)
         {
            return new NoTransactionConnectionListener(cm, mc, credential, mcp, cm.getPool().getFlushStrategy());
         }
         else if (cm.getTransactionSupport() == TransactionSupportLevel.LocalTransaction)
         {
            return new LocalTransactionConnectionListener(cm, mc, credential, getLocalXAResource(mc), mcp,
                  cm.getPool().getFlushStrategy());
         }
         else
         {
            return new XATransactionConnectionListener(cm, mc, credential, getXAResource(mc),
                  cm.getConnectionManagerConfiguration().getXAResourceTimeout(), mcp,
                  cm.getPool().getFlushStrategy());
         }
      }
   }
   catch (ResourceException re)
   {
      throw re;
   }
   catch (Exception e)
   {
      throw new ResourceException(e);
   }

   throw new ResourceException("No ConnectionListener");
}
 
Example #16
Source File: AbstractPool.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public ConnectionListener getConnectionListener(Credential credential) throws ResourceException
{
   log.tracef("getConnectionListener(%s)", credential);

   ConnectionListener cl = null;
   ManagedConnectionPool mcp = getManagedConnectionPool(credential);

   if (isShutdown())
      throw new ResourceException();
   
   if (cm.getTransactionSupport() == TransactionSupportLevel.LocalTransaction
         || cm.getTransactionSupport() == TransactionSupportLevel.XATransaction)
   {
      try
      {
         TransactionalConnectionManager txCM = (TransactionalConnectionManager) cm;
         Transaction tx = txCM.getTransactionIntegration().getTransactionManager().getTransaction();

         if (TxUtils.isUncommitted(tx))
         {
            Object id = txCM.getTransactionIntegration().getTransactionSynchronizationRegistry().getTransactionKey();

            Map<ManagedConnectionPool, ConnectionListener> currentMap = transactionMap.get(id);

            if (currentMap == null)
            {
               Map<ManagedConnectionPool, ConnectionListener> map = new HashMap<>();

               currentMap = transactionMap.putIfAbsent(id, map);
               if (currentMap == null)
               {
                  currentMap = map;
               }
            }

            cl = currentMap.get(mcp);

            if (cl == null)
            {
               if (TxUtils.isActive(tx))
               {
                  cl = mcp.getConnectionListener();

                  currentMap.put(mcp, cl);

                  txCM.getTransactionIntegration().getTransactionSynchronizationRegistry().
                     registerInterposedSynchronization(new TransactionMapCleanup(id, transactionMap));
               }
               else
               {
                  throw new ResourceException();
               }
            }
         }
      }
      catch (ResourceException re)
      {
         throw re;
      }
      catch (Exception e)
      {
         throw new ResourceException(e);
      }
   }

   if (cl == null)
      cl = mcp.getConnectionListener();

   return cl;
}
 
Example #17
Source File: AbstractPool.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void enlist(ManagedConnection mc) throws ResourceException
{
   if (cm.getTransactionSupport() == TransactionSupportLevel.NoTransaction)
      return;

   ConnectionListener cl = findConnectionListener(mc, null);
   if (cl != null)
   {
      if (cl.isEnlisted())
         throw new ResourceException();

      try
      {
         TransactionalConnectionManager txCM = (TransactionalConnectionManager) cm;
         Transaction tx = txCM.getTransactionIntegration().getTransactionManager().getTransaction();

         if (TxUtils.isUncommitted(tx))
         {
            Object id = txCM.getTransactionIntegration().getTransactionSynchronizationRegistry().getTransactionKey();

            Map<ManagedConnectionPool, ConnectionListener> currentMap = transactionMap.get(id);

            if (currentMap == null)
            {
               Map<ManagedConnectionPool, ConnectionListener> map = new HashMap<>();

               currentMap = transactionMap.putIfAbsent(id, map);
               if (currentMap == null)
               {
                  currentMap = map;
               }
            }

            ConnectionListener existing = currentMap.get(cl.getManagedConnectionPool());

            if (existing == null)
            {
               if (TxUtils.isActive(tx))
               {
                  cl.enlist();
                  
                  currentMap.put(cl.getManagedConnectionPool(), cl);

                  txCM.getTransactionIntegration().getTransactionSynchronizationRegistry().
                     registerInterposedSynchronization(new TransactionMapCleanup(id, transactionMap));
               }
               else
               {
                  throw new ResourceException();
               }
            }
            else
            {
               log.tracef("Already a connection listener in the pool tracked by transaction=%s (existing=%s)",
                          id, existing);

               if (existing.equals(cl))
               {
                  if (TxUtils.isActive(tx))
                  {
                     cl.enlist();
                  }
                  else
                  {
                     throw new ResourceException();
                  }
               }
               else
               {
                  throw new ResourceException();
               }
            }
         }
         else
         {
            throw new ResourceException();
         }
      }
      catch (ResourceException re)
      {
         throw re;
      }
      catch (Throwable t)
      {
         throw new ResourceException(t);
      }
   }
   else
   {
      throw new ResourceException();
   }
}
 
Example #18
Source File: AbstractPool.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void delist(ConnectionListener cl) throws ResourceException
{
   if (cm.getTransactionSupport() == TransactionSupportLevel.NoTransaction)
      return;

   if (cl != null)
   {
      try
      {
         TransactionalConnectionManager txCM = (TransactionalConnectionManager) cm;
         Transaction tx = txCM.getTransactionIntegration().getTransactionManager().getTransaction();

         if (TxUtils.isUncommitted(tx))
         {
            try
            {
               cl.delist();
            }
            finally
            {
               Object id = txCM.getTransactionIntegration()
                  .getTransactionSynchronizationRegistry().getTransactionKey();

               Map<ManagedConnectionPool, ConnectionListener> currentMap = transactionMap.get(id);

               if (currentMap != null)
               {
                  ConnectionListener registered = currentMap.remove(cl.getManagedConnectionPool());
                  transactionMap.put(id, currentMap);
               }
            }
         }
      }
      catch (ResourceException re)
      {
         throw re;
      }
      catch (Exception e)
      {
         throw new ResourceException(e);
      }
   }
   else
   {
      throw new ResourceException();
   }
}
 
Example #19
Source File: DefaultPool.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public ConnectionListener createConnectionListener(Credential credential, ManagedConnectionPool mcp)
   throws ResourceException
{
   try
   {
      if (semaphore.tryAcquire(poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS))
      {
         long start = getInternalStatistics().isEnabled() ? System.currentTimeMillis() : 0L;

         ManagedConnection mc =
            cm.getManagedConnectionFactory().createManagedConnection(credential.getSubject(),
                                                                     credential.getConnectionRequestInfo());

         if (getInternalStatistics().isEnabled())
         {
            getInternalStatistics().deltaCreatedCount();
            getInternalStatistics().deltaTotalCreationTime(System.currentTimeMillis() - start);
         }

         if (cm.getTransactionSupport() == TransactionSupportLevel.NoTransaction)
         {
            return new NoTransactionConnectionListener(cm, mc, credential, mcp, cm.getPool().getFlushStrategy());
         }
         else if (cm.getTransactionSupport() == TransactionSupportLevel.LocalTransaction)
         {
            return new LocalTransactionConnectionListener(cm, mc, credential, getLocalXAResource(mc), mcp,
                  cm.getPool().getFlushStrategy());
         }
         else
         {
            return new XATransactionConnectionListener(cm, mc, credential, getXAResource(mc),
                  cm.getConnectionManagerConfiguration().getXAResourceTimeout(), mcp,
                  cm.getPool().getFlushStrategy());
         }
      }
   }
   catch (ResourceException re)
   {
      throw re;
   }
   catch (Exception e)
   {
      throw new ResourceException(e);
   }

   throw new ResourceException("No ConnectionListener");
}
 
Example #20
Source File: LocalTransactionConnectionManager.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public TransactionSupportLevel getTransactionSupport()
{
   return TransactionSupportLevel.LocalTransaction;
}
 
Example #21
Source File: NoTransactionConnectionManager.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public TransactionSupportLevel getTransactionSupport()
{
   return TransactionSupportLevel.NoTransaction;
}
 
Example #22
Source File: XATransactionConnectionManager.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public TransactionSupportLevel getTransactionSupport()
{
   return TransactionSupportLevel.XATransaction;
}
 
Example #23
Source File: TomEERAConnectionFactory.java    From tomee with Apache License 2.0 4 votes vote down vote up
public TransactionSupportLevel getTransactionSupport() {
    return transactionSupportLevel;
}
 
Example #24
Source File: TomEEManagedConnection.java    From tomee with Apache License 2.0 4 votes vote down vote up
public TransactionSupportLevel getTransactionSupportLevel() {
    return transactionSupportLevel;
}
 
Example #25
Source File: TomEEManagedConnectionProxy.java    From tomee with Apache License 2.0 4 votes vote down vote up
@Override
public Session createSession(final int acknowledgeMode) throws JMSException {
    // For the next three methods, we ignore the requested session mode per the
    // spec:
    // https://docs.oracle.com/javaee/7/api/javax/jms/Connection.html#createSession-int-
    //
    // But we also allow the user to override this behavior. If they set
    // transactionSupport on the connection factory
    // we will not return to them a xa session, even though the underlying physical
    // connection may support XA.

    int mode;
    boolean xa;
    TransactionSupportLevel transactionSupportLevel;
    if (connection instanceof TomEEManagedConnection) {
        transactionSupportLevel = ((TomEEManagedConnection) connection).getTransactionSupportLevel();
    } else {
        transactionSupportLevel = TransactionSupportLevel.XATransaction;
    }
    switch (transactionSupportLevel) {
        case XATransaction:
            if (JMS2.inTx()) {
                mode = -1;
                xa = true;
                break;
            }
        case NoTransaction:
            mode = acknowledgeMode;
            xa = false;
            break;
        case LocalTransaction:
            mode = JMSContext.SESSION_TRANSACTED;
            xa = false;
            break;
        default:
            throw new IllegalStateException("transactionSupportLevel mode not supported:" + transactionSupportLevel);
    }
    if (xa) {
        return createXASession();
    } else {
        return connection.getPhysicalConnection().createSession(mode);
    }
}
 
Example #26
Source File: LazyXATransactionMTTestCase.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Define the deployment
 * @return The deployment archive
 * @throws Exception in case of errors
 */
@Deployment(order = 2)
public static Descriptor createDescriptor() throws Exception
{
   return ResourceAdapterFactory.createLazyDeployment(TransactionSupportLevel.XATransaction);
}
 
Example #27
Source File: ConnectionManagerFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a transactional connection manager
 * @param tsl The transaction support level
 * @param pool The pool for the connection manager
 * @param subjectFactory The subject factory
 * @param securityDomain The security domain 
 * @param useCcm Should the CCM be used
 * @param ccm The cached connection manager
 * @param sharable Enable sharable connections
 * @param enlistment Enable enlistment connections
 * @param connectable Enable connectable connections
 * @param tracking The tracking status
 * @param enlistmentTrace The enlistment trace
 * @param flushStrategy The flush strategy
 * @param allocationRetry The allocation retry value
 * @param allocationRetryWaitMillis The allocation retry millis value
 * @param txIntegration The transaction manager integration
 * @param interleaving Enable interleaving
 * @param xaResourceTimeout The transaction timeout for XAResource
 * @param isSameRMOverride Should isSameRM be overridden
 * @param wrapXAResource Should XAResource be wrapped
 * @param padXid Should Xids be padded
 * @return The connection manager instance
 */
public TxConnectionManager createTransactional(final TransactionSupportLevel tsl,
                                               final Pool pool,
                                               final SubjectFactory subjectFactory,
                                               final String securityDomain,
                                               final boolean useCcm,
                                               final CachedConnectionManager ccm,
                                               final boolean sharable,
                                               final boolean enlistment,
                                               final boolean connectable,
                                               final Boolean tracking,
                                               final ManagedEnlistmentTrace enlistmentTrace,
                                               final FlushStrategy flushStrategy,
                                               final Integer allocationRetry,
                                               final Long allocationRetryWaitMillis,
                                               final TransactionIntegration txIntegration,
                                               final Boolean interleaving,
                                               final Integer xaResourceTimeout,
                                               final Boolean isSameRMOverride,
                                               final Boolean wrapXAResource,
                                               final Boolean padXid)
{
   if (tsl == null)
      throw new IllegalArgumentException("TransactionSupportLevel is null");

   if (pool == null)
      throw new IllegalArgumentException("Pool is null");

   if (txIntegration == null)
      throw new IllegalArgumentException("TransactionIntegration is null");

   if (flushStrategy == null)
      throw new IllegalArgumentException("FlushStrategy is null");

   TxConnectionManagerImpl cm = null;

   switch (tsl)
   {
      case NoTransaction:
         throw new IllegalArgumentException("Non transactional connection manager not supported");

      case LocalTransaction:
         cm = new TxConnectionManagerImpl(txIntegration, true);
         break;

      case XATransaction:
         cm = new TxConnectionManagerImpl(txIntegration, false);
         break;

      default:
         throw new IllegalArgumentException("Unknown transaction support level " + tsl);
   }

   setProperties(cm, pool, 
                 subjectFactory, securityDomain, 
                 useCcm, ccm,
                 sharable,
                 enlistment,
                 connectable,
                 tracking,
                 enlistmentTrace,
                 flushStrategy,
                 allocationRetry, allocationRetryWaitMillis,
                 txIntegration.getTransactionManager());
   setTxProperties(cm, interleaving, xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);

   return cm;
}
 
Example #28
Source File: LazyCCMNoTransactionTestCase.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Define the deployment
 * @return The deployment archive
 * @throws Exception in case of errors
 */
@Deployment(order = 2)
public static Descriptor createDescriptor() throws Exception
{
   return ResourceAdapterFactory.createLazyDeployment(TransactionSupportLevel.NoTransaction);
}
 
Example #29
Source File: ConnectionManagerFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a connection manager
 * @param tsl The transaction support level
 * @param pool The pool for the connection manager
 * @param subjectFactory The subject factory
 * @param securityDomain The security domain 
 * @param useCcm Should the CCM be used
 * @param ccm The cached connection manager
 * @param sharable Enable sharable connections
 * @param enlistment Enable enlistment connections
 * @param connectable Enable connectable connections
 * @param tracking The tracking status
 * @param flushStrategy The flush strategy
 * @param allocationRetry The allocation retry value
 * @param allocationRetryWaitMillis The allocation retry millis value
 * @return The connection manager instance
 */
public NoTxConnectionManager createNonTransactional(final TransactionSupportLevel tsl,
                                                    final Pool pool,
                                                    final SubjectFactory subjectFactory,
                                                    final String securityDomain,
                                                    final boolean useCcm,
                                                    final CachedConnectionManager ccm,
                                                    final boolean sharable,
                                                    final boolean enlistment,
                                                    final boolean connectable,
                                                    final Boolean tracking,
                                                    final FlushStrategy flushStrategy,
                                                    final Integer allocationRetry,
                                                    final Long allocationRetryWaitMillis)
{
   if (tsl == null)
      throw new IllegalArgumentException("TransactionSupportLevel is null");

   if (pool == null)
      throw new IllegalArgumentException("Pool is null");

   if (flushStrategy == null)
      throw new IllegalArgumentException("FlushStrategy is null");

   NoTxConnectionManagerImpl cm = null;

   switch (tsl)
   {
      case NoTransaction:
         cm = new NoTxConnectionManagerImpl();
         break;

      case LocalTransaction:
         throw new IllegalArgumentException("Transactional connection manager not supported");

      case XATransaction:
         throw new IllegalArgumentException("Transactional connection manager not supported");

      default:
         throw new IllegalArgumentException("Unknown transaction support level " + tsl);
   }

   setProperties(cm, pool,
                 subjectFactory, securityDomain, 
                 useCcm, ccm,
                 sharable,
                 enlistment,
                 connectable,
                 tracking,
                 null,
                 flushStrategy,
                 allocationRetry, allocationRetryWaitMillis, 
                 null);
   setNoTxProperties(cm);

   return cm;
}
 
Example #30
Source File: LazyCCMXATransactionTestCase.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Define the deployment
 * @return The deployment archive
 * @throws Exception in case of errors
 */
@Deployment(order = 2)
public static Descriptor createDescriptor() throws Exception
{
   return ResourceAdapterFactory.createLazyDeployment(TransactionSupportLevel.XATransaction);
}