Java Code Examples for javax.resource.spi.TransactionSupport.TransactionSupportLevel#LocalTransaction
The following examples show how to use
javax.resource.spi.TransactionSupport.TransactionSupportLevel#LocalTransaction .
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 |
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: StablePool.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * {@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 3
Source File: AbstractPool.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * {@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 4
Source File: DefaultPool.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * {@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 5
Source File: LocalTransactionConnectionManager.java From ironjacamar with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ public TransactionSupportLevel getTransactionSupport() { return TransactionSupportLevel.LocalTransaction; }