Search in sources :

Example 46 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class PersistenceUnitParseProcessor method handleWarDeployment.

private void handleWarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!appClientContainerMode && isWarDeployment(deploymentUnit)) {
        int puCount;
        // ordered list of PUs
        List<PersistenceUnitMetadataHolder> listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1);
        // handle WEB-INF/classes/META-INF/persistence.xml
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        VirtualFile persistence_xml = deploymentRoot.getRoot().getChild(WEB_PERSISTENCE_XML);
        parse(persistence_xml, listPUHolders, deploymentUnit);
        PersistenceUnitMetadataHolder holder = normalize(listPUHolders);
        deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
        addApplicationDependenciesOnProvider(deploymentUnit, holder);
        markDU(holder, deploymentUnit);
        puCount = holder.getPersistenceUnits().size();
        // look for persistence.xml in jar files in the META-INF/persistence.xml directory (these are not currently
        // handled as subdeployments)
        List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
        for (ResourceRoot resourceRoot : resourceRoots) {
            if (resourceRoot.getRoot().getName().toLowerCase(Locale.ENGLISH).endsWith(JAR_FILE_EXTENSION)) {
                listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1);
                persistence_xml = resourceRoot.getRoot().getChild(META_INF_PERSISTENCE_XML);
                parse(persistence_xml, listPUHolders, deploymentUnit);
                holder = normalize(listPUHolders);
                resourceRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
                addApplicationDependenciesOnProvider(deploymentUnit, holder);
                markDU(holder, deploymentUnit);
                puCount += holder.getPersistenceUnits().size();
            }
        }
        ROOT_LOGGER.tracef("parsed persistence unit definitions for war %s", deploymentRoot.getRootName());
        incrementPersistenceUnitCount(deploymentUnit, puCount);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) PersistenceUnitMetadataHolder(org.jboss.as.jpa.config.PersistenceUnitMetadataHolder) ArrayList(java.util.ArrayList) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 47 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class WSIntegrationProcessorJAXWS_JMS method getWsdlResourceRoot.

private static ResourceRoot getWsdlResourceRoot(final DeploymentUnit unit, final String wsdlPath) {
    final AttachmentList<ResourceRoot> resourceRoots = new AttachmentList<ResourceRoot>(ResourceRoot.class);
    final ResourceRoot root = unit.getAttachment(DEPLOYMENT_ROOT);
    resourceRoots.add(root);
    final AttachmentList<ResourceRoot> otherResourceRoots = unit.getAttachment(RESOURCE_ROOTS);
    if (otherResourceRoots != null) {
        resourceRoots.addAll(otherResourceRoots);
    }
    for (final ResourceRoot resourceRoot : resourceRoots) {
        VirtualFile file = resourceRoot.getRoot().getChild(wsdlPath);
        if (file.exists())
            return resourceRoot;
    }
    return null;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) AttachmentList(org.jboss.as.server.deployment.AttachmentList)

Example 48 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class WSIntegrationProcessorJAXWS_JMS method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
        return;
    }
    final List<AnnotationInstance> webServiceAnnotations = getAnnotations(unit, WEB_SERVICE_ANNOTATION);
    // TODO: how about @WebServiceProvider JMS based endpoints?
    //group @WebService annotations in the deployment by wsdl contract location
    Map<String, List<AnnotationInstance>> map = new HashMap<String, List<AnnotationInstance>>();
    for (AnnotationInstance webServiceAnnotation : webServiceAnnotations) {
        final AnnotationValue wsdlLocation = webServiceAnnotation.value(WSDL_LOCATION);
        final AnnotationValue port = webServiceAnnotation.value(PORT_NAME);
        final AnnotationValue service = webServiceAnnotation.value(SERVICE_NAME);
        //support for contract-first development only: pick-up @WebService annotations referencing a provided wsdl contract only
        if (wsdlLocation != null && port != null && service != null) {
            String key = wsdlLocation.asString();
            List<AnnotationInstance> annotations = map.get(key);
            if (annotations == null) {
                annotations = new LinkedList<AnnotationInstance>();
                map.put(key, annotations);
            }
            annotations.add(webServiceAnnotation);
        }
    }
    //extract SOAP-over-JMS 1.0 bindings
    List<JMSEndpointMetaData> list = new LinkedList<JMSEndpointMetaData>();
    if (!map.isEmpty()) {
        for (String wsdlLocation : map.keySet()) {
            try {
                final ResourceRoot resourceRoot = getWsdlResourceRoot(unit, wsdlLocation);
                if (resourceRoot == null)
                    continue;
                final VirtualFile wsdlLocationFile = resourceRoot.getRoot().getChild(wsdlLocation);
                final URL url = wsdlLocationFile.toURL();
                SOAPAddressWSDLParser parser = new SOAPAddressWSDLParser(url);
                for (AnnotationInstance ai : map.get(wsdlLocation)) {
                    String port = ai.value(PORT_NAME).asString();
                    String service = ai.value(SERVICE_NAME).asString();
                    AnnotationValue targetNS = ai.value(TARGET_NAMESPACE);
                    String tns = targetNS != null ? targetNS.asString() : null;
                    QName serviceName = new QName(tns, service);
                    QName portName = new QName(tns, port);
                    String soapAddress = parser.filterSoapAddress(serviceName, portName, SOAPAddressWSDLParser.SOAP_OVER_JMS_NS);
                    if (soapAddress != null) {
                        ClassInfo webServiceClassInfo = (ClassInfo) ai.target();
                        String beanClassName = webServiceClassInfo.name().toString();
                        //service name ?
                        list.add(new JMSEndpointMetaData(beanClassName, port, beanClassName, wsdlLocation, soapAddress));
                    }
                }
            } catch (Exception ignore) {
                WSLogger.ROOT_LOGGER.cannotReadWsdl(wsdlLocation);
            }
        }
    }
    unit.putAttachment(JMS_ENDPOINT_METADATA_KEY, new JMSEndpointsMetaData(list));
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) JMSEndpointsMetaData(org.jboss.wsf.spi.metadata.jms.JMSEndpointsMetaData) LinkedList(java.util.LinkedList) URL(java.net.URL) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) JMSEndpointMetaData(org.jboss.wsf.spi.metadata.jms.JMSEndpointMetaData) AnnotationValue(org.jboss.jandex.AnnotationValue) LinkedList(java.util.LinkedList) AttachmentList(org.jboss.as.server.deployment.AttachmentList) List(java.util.List) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) SOAPAddressWSDLParser(org.jboss.ws.common.deployment.SOAPAddressWSDLParser) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

Example 49 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class WebservicesDescriptorDeploymentProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    final ResourceRoot deploymentRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final URL webservicesDescriptorURL = getWebServicesDescriptorURL(deploymentRoot);
    if (webservicesDescriptorURL != null) {
        final WebservicesPropertyReplaceFactory webservicesFactory = new WebservicesPropertyReplaceFactory(webservicesDescriptorURL, JBossDescriptorPropertyReplacement.propertyReplacer(unit));
        final WebservicesMetaData webservicesMD = webservicesFactory.load(webservicesDescriptorURL);
        unit.putAttachment(WSAttachmentKeys.WEBSERVICES_METADATA_KEY, webservicesMD);
        if (hasJaxRpcMapping(webservicesMD)) {
            throw WSLogger.ROOT_LOGGER.jaxRpcNotSupported();
        }
    }
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) WebservicesPropertyReplaceFactory(org.jboss.as.webservices.metadata.WebservicesPropertyReplaceFactory) WebservicesMetaData(org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) URL(java.net.URL)

Example 50 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class AbstractDeploymentModelBuilder method newDeployment.

/**
     * Creates new Web Service deployment.
     *
     * @param unit deployment unit
     * @return archive deployment
     */
private ArchiveDeployment newDeployment(final DeploymentUnit unit) {
    WSLogger.ROOT_LOGGER.tracef("Creating new unified WS deployment model for %s", unit);
    final ResourceRoot deploymentRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final VirtualFile root = deploymentRoot != null ? deploymentRoot.getRoot() : null;
    final ClassLoader classLoader;
    final Module module = unit.getAttachment(Attachments.MODULE);
    if (module == null) {
        classLoader = unit.getAttachment(CLASSLOADER_KEY);
        if (classLoader == null) {
            throw WSLogger.ROOT_LOGGER.classLoaderResolutionFailed(unit);
        }
    } else {
        classLoader = module.getClassLoader();
    }
    ArchiveDeployment parentDep = null;
    if (unit.getParent() != null) {
        final Module parentModule = unit.getParent().getAttachment(Attachments.MODULE);
        if (parentModule == null) {
            throw WSLogger.ROOT_LOGGER.classLoaderResolutionFailed(deploymentRoot);
        }
        WSLogger.ROOT_LOGGER.tracef("Creating new unified WS deployment model for %s", unit.getParent());
        parentDep = this.newDeployment(null, unit.getParent().getName(), parentModule.getClassLoader(), null);
    }
    final UnifiedVirtualFile uvf = root != null ? new VirtualFileAdaptor(root) : new ResourceLoaderAdapter(classLoader);
    final ArchiveDeployment dep = this.newDeployment(parentDep, unit.getName(), classLoader, uvf);
    //add an AnnotationInfo attachment that uses composite jandex index
    dep.addAttachment(AnnotationsInfo.class, new JandexAnnotationsInfo(unit));
    return dep;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) UnifiedVirtualFile(org.jboss.wsf.spi.deployment.UnifiedVirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ArchiveDeployment(org.jboss.wsf.spi.deployment.ArchiveDeployment) UnifiedVirtualFile(org.jboss.wsf.spi.deployment.UnifiedVirtualFile) VirtualFileAdaptor(org.jboss.as.webservices.util.VirtualFileAdaptor) ResourceLoaderAdapter(org.jboss.ws.common.ResourceLoaderAdapter) Module(org.jboss.modules.Module)

Aggregations

ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)71 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)49 VirtualFile (org.jboss.vfs.VirtualFile)37 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)16 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)12 HashMap (java.util.HashMap)10 PersistenceUnitMetadataHolder (org.jboss.as.jpa.config.PersistenceUnitMetadataHolder)10 WarMetaData (org.jboss.as.web.common.WarMetaData)10 MountHandle (org.jboss.as.server.deployment.module.MountHandle)9 Index (org.jboss.jandex.Index)8 Closeable (java.io.Closeable)7 URL (java.net.URL)7 HashSet (java.util.HashSet)7 Module (org.jboss.modules.Module)7 InputStream (java.io.InputStream)6 EarMetaData (org.jboss.metadata.ear.spec.EarMetaData)6 ServiceName (org.jboss.msc.service.ServiceName)6 XMLStreamException (javax.xml.stream.XMLStreamException)5 EEApplicationDescription (org.jboss.as.ee.component.EEApplicationDescription)5