Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2010, Red Hat, Inc., and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 
 package org.jboss.as.txn;
 
 
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
 import static org.jboss.as.txn.CommonAttributes.*;

Adds the transaction management subsystem.

Author(s):
David M. Lloyd
Emanuel Muckenhuber
 
 
     static final TransactionSubsystemAdd INSTANCE = new TransactionSubsystemAdd();
     private static final String INTERNAL_OBJECTSTORE_PATH = "jboss.transactions.object.store.path";
 
     private static final Logger log = Logger.getLogger("org.jboss.as.transactions");
 
     private TransactionSubsystemAdd() {
         //
     }

    
 
     @Override
     public OperationResult execute(final OperationContext contextfinal ModelNode operationfinal ResultHandler resultHandler) {
 
         if(context instanceof BootOperationContext) {
         }
 
         final ModelNode compensatingOperation = Util.getResourceRemoveOperation(operation.require());
 
         final String bindingName = operation.get().require().asString();
         final String recoveryBindingName = operation.get().require().asString();
         final String recoveryStatusBindingName = operation.get().require().asString();
         final String nodeIdentifier = operation.get().has() ? operation.get().asString() : "1";
         final boolean coordinatorEnableStatistics = operation.get().asBoolean(false);
         final ModelNode objectStore = operation.get();
         final String objectStorePathRef = objectStore.hasDefined() ? objectStore.get().asString() : "jboss.server.data.dir";
         final String objectStorePath = objectStore.hasDefined() ? objectStore.get().asString() : "tx-object-store";
         final int maxPorts = 10;
         final int coordinatorDefaultTimeout = 300;
 
         final ModelNode subModel = context.getSubModel();
         subModel.get().set(operation.get().require());
         subModel.get().set(operation.get());
         subModel.get().set(operation.get().require());
         subModel.get().set(operation.get());
         subModel.get().set(operation.get());
 
         if (context.getRuntimeContext() != null) {
            context.getRuntimeContext().setRuntimeTask(new RuntimeTask() {
                @Override
                public void execute(RuntimeTaskContext contextthrows OperationFailedException {
                    final ServiceTarget target = context.getServiceTarget();
                    // XATerminator has no deps, so just add it in there
                    final XATerminatorService xaTerminatorService = new XATerminatorService();
                    target.addService(.xaTerminatorService).setInitialMode(.).install();
                    // Configure the ObjectStoreEnvironmentBeans
                    final ArjunaObjectStoreEnvironmentService objStoreEnvironmentService = new ArjunaObjectStoreEnvironmentService();
                    target.addService(.objStoreEnvironmentService)
                        .addDependency(AbstractPathService.pathNameOf(), String.classobjStoreEnvironmentService.getPathInjector())
                        .setInitialMode(.).install();
                    final ArjunaRecoveryManagerService recoveryManagerService = new ArjunaRecoveryManagerService();
                    target.addService(.recoveryManagerService)
                        .addDependency(...append("iiop""orb"), ORB.classrecoveryManagerService.getOrbInjector())
                        .addDependency(..append(recoveryBindingName), SocketBinding.classrecoveryManagerService.getRecoveryBindingInjector())
                        .addDependency(..append(recoveryStatusBindingName), SocketBinding.classrecoveryManagerService.getStatusBindingInjector())
                        .addDependency(.)
                        .setInitialMode(.)
                        .install();
                    final ArjunaTransactionManagerService transactionManagerService = new ArjunaTransactionManagerService(nodeIdentifiermaxPortscoordinatorEnableStatisticscoordinatorDefaultTimeout);
                    target.addService(.transactionManagerService)
                            .addDependency(...append("iiop""orb"), ORB.classtransactionManagerService.getOrbInjector())
                            .addDependency(.JBossXATerminator.classtransactionManagerService.getXaTerminatorInjector())
                            .addDependency(..append(bindingName), SocketBinding.classtransactionManagerService.getSocketProcessBindingInjector())
                            .addDependency(.)
                            .addDependency(.)
                            .setInitialMode(.)
                            .install();
                    TransactionManagerService.addService(target);
                    UserTransactionService.addService(target);
                    TransactionSynchronizationRegistryService.addService(target);
                    RelativePathService.addService(objectStorePathobjectStorePathReftarget);
                    //we need to initialize this class when we have the correct TCCL set
                    //so we force it to be initialized here
                    try {
                        Class.forName("com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple",true,getClass().getClassLoader());
                    } catch (ClassNotFoundException e) {
                        .warn("Could not load com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple",e);
                    }
                    resultHandler.handleResultComplete();
                }
            });
        } else {
            resultHandler.handleResultComplete();
        }
        return new BasicOperationResult(compensatingOperation);
    }
New to GrepCode? Check out our FAQ X