Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2011, Red Hat Middleware LLC, 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.webservices.deployers.deployment;
 
 import static org.jboss.as.webservices.WSLogger.ROOT_LOGGER;
 import static org.jboss.as.webservices.WSMessages.MESSAGES;
 import static org.jboss.as.webservices.util.ASHelper.getJBossWebMetaData;
 import static org.jboss.as.webservices.util.ASHelper.getOptionalAttachment;
 import static org.jboss.as.webservices.util.WSAttachmentKeys.CLASSLOADER_KEY;
 import static org.jboss.as.webservices.util.WSAttachmentKeys.DEPLOYMENT_KEY;
 import static org.jboss.as.webservices.util.WSAttachmentKeys.JAXWS_ENDPOINTS_KEY;
 import static org.jboss.as.webservices.util.WSAttachmentKeys.JBOSS_WEBSERVICES_METADATA_KEY;
 import static org.jboss.as.webservices.util.WSAttachmentKeys.WEBSERVICES_METADATA_KEY;
 
 import  org.jboss.metadata.ejb.spec.EjbJarMetaData;
 import  org.jboss.metadata.web.jboss.JBossWebMetaData;
Base class for all deployment model builders.

Author(s):
Alessio Soldano
Richard Opalka
 
 abstract class AbstractDeploymentModelBuilder implements DeploymentModelBuilder {

    
Deployment model factory.
 
     private final DeploymentModelFactory deploymentModelFactory;

    
Deployment type this builder creates.
 
     private final DeploymentType deploymentType;

    
Endpoint type this builder creates.
 
     private final EndpointType endpointType;

    
Constructor.
 
     protected AbstractDeploymentModelBuilder(final DeploymentType deploymentTypefinal EndpointType endpointType) {
         // deployment factory
         final ClassLoader cl = AbstractDeploymentModelBuilder.class.getClassLoader();
         final SPIProvider spiProvider = SPIProviderResolver.getInstance(cl).getProvider();
         this. = spiProvider.getSPI(DeploymentModelFactory.classcl);
         this. = deploymentType;
         this. = endpointType;
     }

    

Parameters:
unit deployment unit
See also:
org.jboss.webservices.integration.deployers.deployment.DeploymentModelBuilder.newDeploymentModel(DeploymentUnit)
 
     public final void newDeploymentModel(final DeploymentUnit unit) {
         final ArchiveDeployment dep;
         if (unit.hasAttachment()) {
             dep = (ArchiveDeploymentunit.getAttachment();
         } else {
             dep = newDeployment(unit);
             propagateAttachments(unitdep);
         }
 
        this.build(depunit);
    }
    private void propagateAttachments(final DeploymentUnit unitfinal ArchiveDeployment dep) {
        dep.addAttachment(DeploymentUnit.classunit);
        unit.putAttachment(dep);
        final JBossWebMetaData webMD = getJBossWebMetaData(unit);
        dep.addAttachment(JBossWebMetaData.classwebMD);
        final WebservicesMetaData webservicesMD = getOptionalAttachment(unit);
        dep.addAttachment(WebservicesMetaData.classwebservicesMD);
        final JBossWebservicesMetaData jbossWebservicesMD = getOptionalAttachment(unit);
        dep.addAttachment(JBossWebservicesMetaData.classjbossWebservicesMD);
        final JAXWSDeployment jaxwsDeployment = getOptionalAttachment(unit);
        dep.addAttachment(JAXWSDeployment.classjaxwsDeployment);
        final EjbJarMetaData ejbJarMD = getOptionalAttachment(unit.);
        dep.addAttachment(EjbJarMetaData.classejbJarMD);
    }

    
Template method for subclasses to implement.

Parameters:
dep webservice deployment
unit deployment unit
    protected abstract void build(Deployment depDeploymentUnit unit);

    
Creates new Http Web Service endpoint.

Parameters:
endpointClass endpoint class name
endpointName endpoint name
dep deployment
Returns:
WS endpoint
    protected final Endpoint newHttpEndpoint(final String endpointClassfinal String endpointNamefinal Deployment dep) {
        if (endpointName == nullthrow .nullEndpointName();
        if (endpointClass == nullthrow .nullEndpointClass();
        final Endpoint endpoint = this..newHttpEndpoint(endpointClass);
        endpoint.setShortName(endpointName);
        endpoint.setType();
        dep.getService().addEndpoint(endpoint);
        return endpoint;
    }

    
Creates new JMS Web Service endpoint.

Parameters:
endpointClass endpoint class name
endpointName endpoint name
dep deployment
Returns:
WS endpoint
    protected final Endpoint newJMSEndpoint(final String endpointClassfinal String endpointNamefinal String soapAddressfinal Deployment dep) {
        if (endpointName == nullthrow .nullEndpointName();
        if (endpointClass == nullthrow .nullEndpointClass();
        final Endpoint endpoint = .newJMSEndpoint(endpointClass);
        endpoint.setAddress(soapAddress);
        endpoint.setShortName(endpointName);
        endpoint.setType();
        dep.getService().addEndpoint(endpoint);
        return endpoint;
    }

    
Creates new Web Service deployment.

Parameters:
unit deployment unit
Returns:
archive deployment
    private ArchiveDeployment newDeployment(final DeploymentUnit unit) {
        final ResourceRoot deploymentRoot = unit.getAttachment(.);
        final VirtualFile root = deploymentRoot != null ? deploymentRoot.getRoot() : null;
        final ClassLoader classLoader;
        final Module module = unit.getAttachment(.);
        if (module == null) {
            classLoader = unit.getAttachment();
            if (classLoader == null) {
                throw .classLoaderResolutionFailed(unit);
            }
        } else {
            classLoader = module.getClassLoader();
        }
        final ArchiveDeployment dep = this.newDeployment(unit.getName(), classLoader);
        if (unit.getParent() != null) {
            final String parentDeploymentName = unit.getParent().getName();
            final Module parentModule = unit.getParent().getAttachment(.);
            if (parentModule == null) {
                throw .classLoaderResolutionFailed(deploymentRoot);
            }
            final ClassLoader parentClassLoader = parentModule.getClassLoader();
            final ArchiveDeployment parentDep = this.newDeployment(parentDeploymentNameparentClassLoader);
            dep.setParent(parentDep);
        }
        if (root != null) {
            dep.setRootFile(new VirtualFileAdaptor(root));
        } else {
            dep.setRootFile(new ResourceLoaderAdapter(classLoader));
        }
        dep.setRuntimeClassLoader(classLoader);
        dep.setType();
        //add an AnnotationInfo attachment that uses composite jandex index
        dep.addAttachment(AnnotationsInfo.classnew JandexAnnotationsInfo(unit));
        return dep;
    }

    
Creates new archive deployment.

Parameters:
name deployment name
loader deployment loader
Returns:
new archive deployment
    private ArchiveDeployment newDeployment(final String namefinal ClassLoader loader) {
        return (ArchiveDeploymentthis..newDeployment(nameloader);
    }
New to GrepCode? Check out our FAQ X