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 @authors tag. See the copyright.txt 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;
 
 
Processor responsible for binding transaction related resources to JNDI. Unlike other resource injections this binding happens for all eligible components, regardless of the presence of the javax.annotation.Resource annotation.

Author(s):
Stuart Douglas
 
     @Override
     public void deploy(DeploymentPhaseContext phaseContextthrows DeploymentUnitProcessingException {
         final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
         final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(.);
 
         if(moduleDescription == null) {
             return;
         }
 
         final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
         //if this is a war we need to bind to the modules comp namespace
         if(DeploymentTypeMarker.isType(.,deploymentUnit)) {
             final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getAppName(),moduleDescription.getModuleName());
             bindServices(deploymentUnitserviceTarget,moduleDescriptionmoduleDescription.getModuleName(), moduleContextServiceName);
         }
 
         for(AbstractComponentDescription component : moduleDescription.getComponentDescriptions()) {
             if(component.getNamingMode() == .) {
                 final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(moduleDescription.getAppName(),moduleDescription.getModuleName(),component.getComponentName());
                 bindServices(deploymentUnitserviceTarget,moduleDescriptioncomponent.getComponentName(), compContextServiceName);
             }
         }
 
     }

    
Binds the java:comp/UserTransaction service and the java:comp/TransactionSyncronizationService

Parameters:
deploymentUnit The deployment unit
serviceTarget The service target
contextServiceName The service name of the context to bind to
 
     private void bindServices(DeploymentUnit deploymentUnitServiceTarget serviceTargetEEModuleDescription description,String componentName,ServiceName contextServiceName) {
 
         final ServiceName userTransactionServiceName = ContextNames.serviceNameOfContext(description.getAppName(),description.getModuleName(),componentName,"java:comp/UserTransaction");
         BinderService userTransactionBindingService = new BinderService("UserTransaction");
         serviceTarget.addService(userTransactionServiceNameuserTransactionBindingService)
                     new ManagedReferenceInjector<UserTransaction>(userTransactionBindingService.getManagedObjectInjector()))
             .addDependency(contextServiceNameNamingStore.classuserTransactionBindingService.getNamingStoreInjector())
             .install();
 
         final ServiceName transactionSynchronizationRegistryName = ContextNames.serviceNameOfContext(description.getAppName(),description.getModuleName(),componentName,"java:comp/TransactionSynchronizationRegistry");
         BinderService transactionSyncBinderService = new BinderService("TransactionSynchronizationRegistry");
         serviceTarget.addService(transactionSynchronizationRegistryNametransactionSyncBinderService)
                     new ManagedReferenceInjector<TransactionSynchronizationRegistry>(transactionSyncBinderService.getManagedObjectInjector()))
            .addDependency(contextServiceNameNamingStore.classtransactionSyncBinderService.getNamingStoreInjector())
            .install();
    }
    @Override
    public void undeploy(DeploymentUnit context) {
    }
New to GrepCode? Check out our FAQ X