Package org.jboss.tm

Examples of org.jboss.tm.TransactionLocal


     * This method will create the database table and compile the queries.
     */
    void startStoreManager() throws Exception {
        tm = getComponent().getTransactionManager();

        cascadeDeleteSet = new TransactionLocal(tm) {
            protected Object initialValue() {
                return new CascadeDeleteRegistry();
            }

            public Transaction getTransaction() {
View Full Code Here


     
      //Sub-pool internal managed connection pool
      ManagedConnectionPool imcp = subPoolContext.getSubPool();

      // Are we doing track by transaction?
      TransactionLocal trackByTx = subPoolContext.getTrackByTx();
     
      if (trackByTransaction == null || trackByTx == null)
      {
         cl = getSimpleConnection(subject, cri, subPoolContext);
      } //end of if trackByTransaction  
View Full Code Here

   protected Synchronization ccmSynch;

   /** Initialization */
   public static void setTransactionManager(TransactionManager tm)
   {
      txSynchs = new TransactionLocal(tm);
   }
View Full Code Here

      public SubPoolContext(TransactionManager tm, ManagedConnectionFactory mcf, ConnectionListenerFactory clf, Subject subject,
                            ConnectionRequestInfo cri, PoolParams poolParams, JBossManagedConnectionPool jmcp, Logger log)
      {
         subPool = new InternalManagedConnectionPool(mcf, clf, subject, cri, poolParams, jmcp, log);
         if (tm != null)
            trackByTx = new TransactionLocal(tm);
      }
View Full Code Here

         SubPoolContext subPool = getSubPool(key, subject, cri);
        
         InternalManagedConnectionPool mcp = subPool.getSubPool();
        
         // Are we doing track by connection?
         TransactionLocal trackByTx = subPool.getTrackByTx();

         // Simple case
         if (trackByTransaction == null || trackByTx == null)
         {
            try
            {
               ConnectionListener cl = mcp.getConnection(subject, cri);
               if (traceEnabled)
                  dump("Got connection from pool " + cl);
               return cl;
            }
            catch (RetryableResourceException rre)
            {
               if (log.isDebugEnabled())
                  log.debug("Got a RetryableResourceException - trying to reinitialize the pool");

               // The IMCP is down - retry
               subPool = getSubPool(key, subject, cri);
               mcp = subPool.getSubPool();

               // Make sure that IMCP is running
               if (!mcp.isRunning())
                  mcp.initialize();

               ConnectionListener cl = mcp.getConnection(subject, cri);
               if (traceEnabled)
                  dump("Got connection from pool (retried) " + cl);

               return cl;
            }
         }

         // Track by transaction
         try
         {
            trackByTx.lock(trackByTransaction);
         }
         catch (Throwable t)
         {
            JBossResourceException.rethrowAsResourceException("Unable to get connection from the pool for tx=" + trackByTransaction, t);
         }
         try
         {
            // Already got one
            ConnectionListener cl = (ConnectionListener) trackByTx.get(trackByTransaction);
            if (cl != null)
            {
               if (traceEnabled)
                  dump("Previous connection tracked by transaction " + cl + " tx=" + trackByTransaction);
               return cl;
            }
         }
         finally
         {
            trackByTx.unlock(trackByTransaction);
         }

         // Need a new one for this transaction
         // This must be done outside the tx local lock, otherwise
         // the tx timeout won't work and get connection can do a lot of other work
         // with many opportunities for deadlocks.
         // Instead we do a double check after we got the transaction to see
         // whether another thread beat us to the punch.
         ConnectionListener cl = mcp.getConnection(subject, cri);
         if (traceEnabled)
            dump("Got connection from pool tracked by transaction " + cl + " tx=" + trackByTransaction);
        
         // Relock and check/set status
         try
         {
            trackByTx.lock(trackByTransaction);
         }
         catch (Throwable t)
         {
            mcp.returnConnection(cl, false);
            if (traceEnabled)
               dump("Had to return connection tracked by transaction " + cl + " tx=" + trackByTransaction + " error=" + t.getMessage());
            JBossResourceException.rethrowAsResourceException("Unable to get connection from the pool for tx=" + trackByTransaction, t);
         }
         try
         {
            // Check we weren't racing with another transaction
            ConnectionListener other = (ConnectionListener) trackByTx.get(trackByTransaction);
            if (other != null)
            {
               mcp.returnConnection(cl, false);
               if (traceEnabled)
                  dump("Another thread already got a connection tracked by transaction " + other + " tx=" + trackByTransaction);
               return other;
            }
           
            // This is the connection for this transaction
            cl.setTrackByTx(true);
            trackByTx.set(cl);
            if (traceEnabled)
               dump("Using connection from pool tracked by transaction " + cl + " tx=" + trackByTransaction);
            return cl;
         }
         finally
         {
            trackByTx.unlock(trackByTransaction);
         }
      }
View Full Code Here

     * This method will create the database table and compile the queries.
     */
    void startStoreManager() throws Exception {
        tm = getComponent().getTransactionManager();

        cascadeDeleteSet = new TransactionLocal(tm) {
            protected Object initialValue() {
                return new CascadeDeleteRegistry();
            }

            public Transaction getTransaction() {
View Full Code Here

     *
     * @
     */
    public void start() {
        cascadeDeleteStrategy = CascadeDeleteStrategy.getCascadeDeleteStrategy(this);
        relatedPKValuesWaitingForMyPK = new TransactionLocal(this.manager.getComponent().getTransactionManager()) {
            protected Object initialValue() {
                return new HashMap();
            }

            public Transaction getTransaction() {
View Full Code Here

    private static final Logger log = Logger.getLogger(TransactionEntityMap.class);
    private final InjectedValue<TransactionManager> transactionManager = new InjectedValue<TransactionManager>();
    private TransactionLocal txSynch;

    public synchronized void start(StartContext context) throws StartException {
        txSynch = new TransactionLocal(transactionManager.getValue()) {
            public Transaction getTransaction() {
                try {
                    return transactionManager.getTransaction();
                } catch (SystemException e) {
                    throw MESSAGES.errorGettingCurrentTransaction(e);
View Full Code Here

     * This method will create the database table and compile the queries.
     */
    void startStoreManager() throws Exception {
        tm = getComponent().getTransactionManager();

        cascadeDeleteSet = new TransactionLocal(tm) {
            protected Object initialValue() {
                return new CascadeDeleteRegistry();
            }

            public Transaction getTransaction() {
View Full Code Here

     *
     * @
     */
    public void start() {
        cascadeDeleteStrategy = CascadeDeleteStrategy.getCascadeDeleteStrategy(this);
        relatedPKValuesWaitingForMyPK = new TransactionLocal(this.manager.getComponent().getTransactionManager()) {
            protected Object initialValue() {
                return new HashMap();
            }

            public Transaction getTransaction() {
View Full Code Here

TOP

Related Classes of org.jboss.tm.TransactionLocal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.