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.connector.deployers.ra.processors;
 
 import static org.jboss.as.connector.logging.ConnectorLogger.DEPLOYMENT_CONNECTOR_LOGGER;
 import static org.jboss.as.connector.logging.ConnectorMessages.MESSAGES;
 
 import java.util.Map;
 
DeploymentUnitProcessor responsible for using IronJacamar metadata and create service for ResourceAdapter.

Author(s):
Stefano Maestri
Jesper Pedersen
 
 
     public ParsedRaDeploymentProcessor() {
     }

    
Process a deployment for a Connector. Will install a JBossService for this ResourceAdapter.

Parameters:
phaseContext the deployment unit context
Throws:
org.jboss.as.server.deployment.DeploymentUnitProcessingException
 
     public void deploy(DeploymentPhaseContext phaseContextthrows DeploymentUnitProcessingException {
        final ConnectorXmlDescriptor connectorXmlDescriptor = phaseContext.getDeploymentUnit().getAttachment(.);
        final ManagementResourceRegistration registration;
        final Resource deploymentResource = phaseContext.getDeploymentUnit().getAttachment(.);
        if (connectorXmlDescriptor == null) {
            return;
        }
        final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        if (deploymentUnit.getParent() != null) {
            registration = baseRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement("subdeployment")));
        } else {
            registration = baseRegistration;
        }
        final IronJacamarXmlDescriptor ironJacamarXmlDescriptor = deploymentUnit
                .getAttachment(.);
        final Module module = deploymentUnit.getAttachment(.);
        if (module == null)
            throw .failedToGetModuleAttachment(phaseContext.getDeploymentUnit());
        .debugf("ParsedRaDeploymentProcessor: Processing=%s"deploymentUnit);
        final ClassLoader classLoader = module.getClassLoader();
        Map<ResourceRootIndexannotationIndexes = AnnotationIndexUtils.getAnnotationIndexes(deploymentUnit);
        ServiceBuilder builder = process(connectorXmlDescriptorironJacamarXmlDescriptorclassLoaderserviceTargetannotationIndexesdeploymentUnit.getServiceName(), null);
        if (builder != null) {
            String bootstrapCtx = null;
            if (ironJacamarXmlDescriptor != null && ironJacamarXmlDescriptor.getIronJacamar() != null && ironJacamarXmlDescriptor.getIronJacamar().getBootstrapContext() != null)
                bootstrapCtx = ironJacamarXmlDescriptor.getIronJacamar().getBootstrapContext();
            if (bootstrapCtx == null)
                bootstrapCtx = "default";
            //Register an empty override model regardless of we're enabled or not - the statistics listener will add the relevant childresources
            if (registration.isAllowsOverride() && registration.getOverrideModel(deploymentUnit.getName()) == null) {
                registration.registerOverrideModel(deploymentUnit.getName(), new OverrideDescriptionProvider() {
                    @Override
                    public Map<StringModelNodegetAttributeOverrideDescriptions(Locale locale) {
                        return Collections.emptyMap();
                    }
                    @Override
                    public Map<StringModelNodegetChildTypeOverrideDescriptions(Locale locale) {
                        return Collections.emptyMap();
                    }
                });
            }
            builder.addListener(new AbstractResourceAdapterDeploymentServiceListener(registrationdeploymentUnit.getName(), deploymentResourcebootstrapCtxdeploymentUnit.getName()) {
                @Override
                protected void registerIronjacamar(final ServiceController<? extends Objectcontrollerfinal ManagementResourceRegistration subRegistrationfinal Resource subsystemResource) {
                    //register ironJacamar
                    try {
                        subRegistration.registerSubModel(new IronJacamarResourceDefinition());
                    } catch (IllegalArgumentException iae) {
                        //ignore it: submodel already registered
                    }
                    AS7MetadataRepository mdr = ((ResourceAdapterDeploymentServicecontroller.getService()).getMdr();
                    ..execute(subsystemResourcemdr);
                }
                @Override
                protected CommonDeployment getDeploymentMetadata(final ServiceController<? extends Objectcontroller) {
                    return ((ResourceAdapterDeploymentServicecontroller.getService()).getRaDeployment();
                }
            });
            builder.setInitialMode(.).install();
        }
    }
    public static ServiceBuilder process(final ConnectorXmlDescriptor connectorXmlDescriptorfinal IronJacamarXmlDescriptor ironJacamarXmlDescriptorfinal ClassLoader classLoaderfinal ServiceTarget serviceTargetfinal Map<ResourceRootIndexannotationIndexesfinal ServiceName duServiceNamefinal ServiceVerificationHandler verificationHandlerthrows DeploymentUnitProcessingException {
        Connector cmd = connectorXmlDescriptor != null ? connectorXmlDescriptor.getConnector() : null;
        final IronJacamar ijmd = ironJacamarXmlDescriptor != null ? ironJacamarXmlDescriptor.getIronJacamar() : null;
        try {
            // Annotation merging
            Annotations annotator = new Annotations();
            if (annotationIndexes != null && annotationIndexes.size() > 0) {
                .debugf("ParsedRaDeploymentProcessor: Found %d annotationIndexes"annotationIndexes.size());
                for (Index index : annotationIndexes.values()) {
                    // Don't apply any empty indexes, as IronJacamar doesn't like that atm.
                    if (index.getKnownClasses() != null && index.getKnownClasses().size() > 0) {
                        AnnotationRepository repository = new JandexAnnotationRepositoryImpl(indexclassLoader);
                        cmd = annotator.merge(cmdrepositoryclassLoader);
                        .debugf("ParsedRaDeploymentProcessor: CMD=%s"cmd);
                    }
                }
            }
            if (annotationIndexes == null || annotationIndexes.size() == 0)
                .debugf("ParsedRaDeploymentProcessor: Found 0 annotationIndexes");
            // FIXME: when the connector is null the Iron Jacamar data is ignored
            if (cmd != null) {
                // Validate metadata
                cmd.validate();
                // Merge metadata
                cmd = (new Merger()).mergeConnectorWithCommonIronJacamar(ijmdcmd);
            }
            final ServiceName deployerServiceName = ..append(connectorXmlDescriptor.getDeploymentName());
            final ResourceAdapterDeploymentService raDeploymentService = new ResourceAdapterDeploymentService(connectorXmlDescriptorcmdijmdclassLoaderdeployerServiceNameduServiceName);
            // Create the service
            ServiceBuilder builder =
                    Services.addServerExecutorDependency(
                        serviceTarget.addService(deployerServiceNameraDeploymentService),
                        raDeploymentService.getExecutorServiceInjector(), false)
                    .addDependency(.AS7MetadataRepository.classraDeploymentService.getMdrInjector())
                    .addDependency(.ResourceAdapterRepository.classraDeploymentService.getRaRepositoryInjector())
                    .addDependency(.ManagementRepository.classraDeploymentService.getManagementRepositoryInjector())
                    .addDependency(.TransactionIntegration.classraDeploymentService.getTxIntegrationInjector())
                    .addDependency(.JcaSubsystemConfiguration.classraDeploymentService.getConfigInjector())
                    .addDependency(.SubjectFactory.classraDeploymentService.getSubjectFactoryInjector())
                    .addDependency(.CachedConnectionManager.classraDeploymentService.getCcmInjector())
                    .addDependency(.)
                    .addDependency(.)
                    .addDependency(.);
            if(verificationHandler != null) {
                builder.addListener(verificationHandler);
            }
            return builder;
        } catch (Throwable t) {
            throw new DeploymentUnitProcessingException(t);
        }
    }
    public void undeploy(final DeploymentUnit context) {
    }
New to GrepCode? Check out our FAQ X