Search in sources :

Example 11 with DeploymentUnitProcessingException

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

the class WarMetaDataProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        // Skip non web deployments
        return;
    }
    WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    assert warMetaData != null;
    boolean isComplete = false;
    WebMetaData specMetaData = warMetaData.getWebMetaData();
    if (specMetaData != null) {
        if (specMetaData instanceof Web25MetaData) {
            isComplete |= ((Web25MetaData) specMetaData).isMetadataComplete();
        } else if (specMetaData instanceof Web30MetaData) {
            isComplete |= ((Web30MetaData) specMetaData).isMetadataComplete();
        } else {
            // As per Servlet 3.0 spec, metadata is not completed unless it's set to true in web.xml.
            // Hence, any web.xml 2.4 or earlier deployment is not metadata completed.
            isComplete = false;
        }
    }
    // Find all fragments that have been processed by deployers, and place
    // them in a map keyed by location
    LinkedList<String> order = new LinkedList<String>();
    List<WebOrdering> orderings = new ArrayList<WebOrdering>();
    HashSet<String> jarsSet = new HashSet<String>();
    Set<VirtualFile> overlays = new HashSet<VirtualFile>();
    Map<String, VirtualFile> scis = new HashMap<String, VirtualFile>();
    boolean fragmentFound = false;
    Map<String, WebFragmentMetaData> webFragments = warMetaData.getWebFragmentsMetaData();
    List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
    for (ResourceRoot resourceRoot : resourceRoots) {
        if (resourceRoot.getRoot().getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
            jarsSet.add(resourceRoot.getRootName());
            // Find overlays
            VirtualFile overlay = resourceRoot.getRoot().getChild("META-INF/resources");
            if (overlay.exists()) {
                overlays.add(overlay);
            }
            // Find ServletContainerInitializer services
            VirtualFile sci = resourceRoot.getRoot().getChild("META-INF/services/javax.servlet.ServletContainerInitializer");
            if (sci.exists()) {
                scis.put(resourceRoot.getRootName(), sci);
            }
        }
    }
    if (!isComplete) {
        HashSet<String> jarsWithoutFragmentsSet = new HashSet<String>();
        jarsWithoutFragmentsSet.addAll(jarsSet);
        for (String jarName : webFragments.keySet()) {
            fragmentFound = true;
            WebFragmentMetaData fragmentMetaData = webFragments.get(jarName);
            webFragments.put(jarName, fragmentMetaData);
            WebOrdering webOrdering = new WebOrdering();
            webOrdering.setName(fragmentMetaData.getName());
            webOrdering.setJar(jarName);
            jarsWithoutFragmentsSet.remove(jarName);
            if (fragmentMetaData.getOrdering() != null) {
                if (fragmentMetaData.getOrdering().getAfter() != null) {
                    for (OrderingElementMetaData orderingElementMetaData : fragmentMetaData.getOrdering().getAfter().getOrdering()) {
                        if (orderingElementMetaData.isOthers()) {
                            webOrdering.setAfterOthers(true);
                        } else {
                            webOrdering.addAfter(orderingElementMetaData.getName());
                        }
                    }
                }
                if (fragmentMetaData.getOrdering().getBefore() != null) {
                    for (OrderingElementMetaData orderingElementMetaData : fragmentMetaData.getOrdering().getBefore().getOrdering()) {
                        if (orderingElementMetaData.isOthers()) {
                            webOrdering.setBeforeOthers(true);
                        } else {
                            webOrdering.addBefore(orderingElementMetaData.getName());
                        }
                    }
                }
            }
            orderings.add(webOrdering);
        }
        // fragment specifying no name and no order
        for (String jarName : jarsWithoutFragmentsSet) {
            WebOrdering ordering = new WebOrdering();
            ordering.setJar(jarName);
            orderings.add(ordering);
        }
    }
    if (!fragmentFound) {
        // Drop the order as there is no fragment in the webapp
        orderings.clear();
    }
    // Generate web fragments parsing order
    AbsoluteOrderingMetaData absoluteOrderingMetaData = null;
    if (!isComplete && specMetaData instanceof Web30MetaData) {
        absoluteOrderingMetaData = ((Web30MetaData) specMetaData).getAbsoluteOrdering();
    }
    if (absoluteOrderingMetaData != null) {
        // Absolute ordering from web.xml, any relative fragment ordering is ignored
        int otherPos = -1;
        int i = 0;
        for (OrderingElementMetaData orderingElementMetaData : absoluteOrderingMetaData.getOrdering()) {
            if (orderingElementMetaData.isOthers()) {
                if (otherPos >= 0) {
                    throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.invalidMultipleOthers());
                }
                otherPos = i;
            } else {
                boolean found = false;
                for (WebOrdering ordering : orderings) {
                    if (orderingElementMetaData.getName().equals(ordering.getName())) {
                        order.add(ordering.getJar());
                        jarsSet.remove(ordering.getJar());
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    UndertowLogger.ROOT_LOGGER.invalidAbsoluteOrdering(orderingElementMetaData.getName());
                } else {
                    i++;
                }
            }
        }
        if (otherPos >= 0) {
            order.addAll(otherPos, jarsSet);
            jarsSet.clear();
        }
    } else if (orderings.size() > 0) {
        // Resolve relative ordering
        try {
            resolveOrder(orderings, order);
        } catch (IllegalStateException e) {
            throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.invalidRelativeOrdering(), e);
        }
        jarsSet.clear();
    } else {
        // No order specified
        order.addAll(jarsSet);
        jarsSet.clear();
        warMetaData.setNoOrder(true);
    }
    if (UndertowLogger.ROOT_LOGGER.isDebugEnabled()) {
        StringBuilder builder = new StringBuilder();
        builder.append("Resolved order: [ ");
        for (String jar : order) {
            builder.append(jar).append(' ');
        }
        builder.append(']');
        UndertowLogger.ROOT_LOGGER.debug(builder.toString());
    }
    warMetaData.setOrder(order);
    warMetaData.setOverlays(overlays);
    warMetaData.setScis(scis);
    Map<String, WebMetaData> annotationsMetaData = warMetaData.getAnnotationsMetaData();
    // The fragments and corresponding annotations will need to be merged in order
    // For each JAR in the order:
    // - Merge the annotation metadata into the fragment meta data (unless the fragment exists and is meta data complete)
    // - Merge the fragment metadata into merged fragment meta data
    WebCommonMetaData mergedFragmentMetaData = new WebCommonMetaData();
    if (specMetaData == null) {
        // If there is no web.xml, it has to be considered to be the latest version
        specMetaData = new Web31MetaData();
        specMetaData.setVersion("3.1");
    }
    // Augment with meta data from annotations in /WEB-INF/classes
    WebMetaData annotatedMetaData = annotationsMetaData.get("classes");
    if (annotatedMetaData == null && deploymentUnit.hasAttachment(Attachments.OSGI_MANIFEST)) {
        annotatedMetaData = annotationsMetaData.get(deploymentUnit.getName());
    }
    if (annotatedMetaData != null) {
        if (isComplete) {
            // Discard @WebFilter, @WebListener and @WebServlet
            annotatedMetaData.setFilters(null);
            annotatedMetaData.setFilterMappings(null);
            annotatedMetaData.setListeners(null);
            annotatedMetaData.setServlets(null);
            annotatedMetaData.setServletMappings(null);
        }
        WebCommonMetaDataMerger.augment(specMetaData, annotatedMetaData, null, true);
    }
    // Augment with meta data from fragments and annotations from the corresponding JAR
    for (String jar : order) {
        WebFragmentMetaData webFragmentMetaData = webFragments.get(jar);
        if (webFragmentMetaData == null || isComplete) {
            webFragmentMetaData = new WebFragmentMetaData();
            // Add non overriding default distributable flag
            webFragmentMetaData.setDistributable(new EmptyMetaData());
        }
        WebMetaData jarAnnotatedMetaData = annotationsMetaData.get(jar);
        if ((isComplete || webFragmentMetaData.isMetadataComplete()) && jarAnnotatedMetaData != null) {
            // Discard @WebFilter, @WebListener and @WebServlet
            jarAnnotatedMetaData.setFilters(null);
            jarAnnotatedMetaData.setFilterMappings(null);
            jarAnnotatedMetaData.setListeners(null);
            jarAnnotatedMetaData.setServlets(null);
            jarAnnotatedMetaData.setServletMappings(null);
        }
        if (jarAnnotatedMetaData != null) {
            // Merge annotations corresponding to the JAR
            WebCommonMetaDataMerger.augment(webFragmentMetaData, jarAnnotatedMetaData, null, true);
        }
        // Merge fragment meta data according to the conflict rules
        try {
            WebCommonMetaDataMerger.augment(mergedFragmentMetaData, webFragmentMetaData, specMetaData, false);
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.invalidWebFragment(jar), e);
        }
    }
    // Augment with meta data from annotations from JARs excluded from the order
    for (String jar : jarsSet) {
        WebFragmentMetaData webFragmentMetaData = new WebFragmentMetaData();
        // Add non overriding default distributable flag
        webFragmentMetaData.setDistributable(new EmptyMetaData());
        WebMetaData jarAnnotatedMetaData = annotationsMetaData.get(jar);
        if (jarAnnotatedMetaData != null) {
            // Discard @WebFilter, @WebListener and @WebServlet
            jarAnnotatedMetaData.setFilters(null);
            jarAnnotatedMetaData.setFilterMappings(null);
            jarAnnotatedMetaData.setListeners(null);
            jarAnnotatedMetaData.setServlets(null);
            jarAnnotatedMetaData.setServletMappings(null);
        }
        if (jarAnnotatedMetaData != null) {
            // Merge annotations corresponding to the JAR
            WebCommonMetaDataMerger.augment(webFragmentMetaData, jarAnnotatedMetaData, null, true);
        }
        // Merge fragment meta data according to the conflict rules
        try {
            WebCommonMetaDataMerger.augment(mergedFragmentMetaData, webFragmentMetaData, specMetaData, false);
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.invalidWebFragment(jar), e);
        }
    }
    WebCommonMetaDataMerger.augment(specMetaData, mergedFragmentMetaData, null, true);
    List<WebMetaData> additional = warMetaData.getAdditionalModuleAnnotationsMetadata();
    if (additional != null && !isComplete) {
        //augument with annotations from additional modules
        for (WebMetaData annotations : additional) {
            // Merge annotations corresponding to the JAR
            WebCommonMetaDataMerger.augment(specMetaData, annotations, null, true);
        }
    }
    // Override with meta data (JBossWebMetaData) Create a merged view
    JBossWebMetaData mergedMetaData = new JBossWebMetaData();
    JBossWebMetaData metaData = warMetaData.getJBossWebMetaData();
    JBossWebMetaDataMerger.merge(mergedMetaData, metaData, specMetaData);
    // FIXME: Incorporate any ear level overrides
    // Use the OSGi Web-ContextPath if not given otherwise
    String contextRoot = mergedMetaData.getContextRoot();
    Manifest manifest = deploymentUnit.getAttachment(Attachments.OSGI_MANIFEST);
    if (contextRoot == null && manifest != null) {
        contextRoot = manifest.getMainAttributes().getValue("Web-ContextPath");
        mergedMetaData.setContextRoot(contextRoot);
    }
    warMetaData.setMergedJBossWebMetaData(mergedMetaData);
    if (mergedMetaData.isMetadataComplete()) {
        MetadataCompleteMarker.setMetadataComplete(deploymentUnit, true);
    }
    //now attach any JNDI binding related information to the deployment
    if (mergedMetaData.getJndiEnvironmentRefsGroup() != null) {
        final DeploymentDescriptorEnvironment bindings = new DeploymentDescriptorEnvironment("java:module/env/", mergedMetaData.getJndiEnvironmentRefsGroup());
        deploymentUnit.putAttachment(org.jboss.as.ee.component.Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT, bindings);
    }
    //override module name if applicable
    if (mergedMetaData.getModuleName() != null && !mergedMetaData.getModuleName().isEmpty()) {
        final EEModuleDescription description = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        description.setModuleName(mergedMetaData.getModuleName());
    }
    //WFLY-3102 EJB in WAR should inherit WAR's security domain
    if (mergedMetaData.getSecurityDomain() != null) {
        final EEModuleDescription description = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        description.setDefaultSecurityDomain(mergedMetaData.getSecurityDomain());
    }
    //merge security roles from the ear
    DeploymentUnit parent = deploymentUnit.getParent();
    if (parent != null) {
        final EarMetaData earMetaData = parent.getAttachment(org.jboss.as.ee.structure.Attachments.EAR_METADATA);
        if (earMetaData != null) {
            SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles();
            if (earSecurityRolesMetaData != null) {
                if (mergedMetaData.getSecurityRoles() == null) {
                    mergedMetaData.setSecurityRoles(new SecurityRolesMetaData());
                }
                SecurityRolesMetaDataMerger.merge(mergedMetaData.getSecurityRoles(), mergedMetaData.getSecurityRoles(), earSecurityRolesMetaData);
            }
        }
    }
}
Also used : Web25MetaData(org.jboss.metadata.web.spec.Web25MetaData) VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) HashMap(java.util.HashMap) EmptyMetaData(org.jboss.metadata.javaee.spec.EmptyMetaData) WarMetaData(org.jboss.as.web.common.WarMetaData) ArrayList(java.util.ArrayList) SecurityRolesMetaData(org.jboss.metadata.javaee.spec.SecurityRolesMetaData) EarMetaData(org.jboss.metadata.ear.spec.EarMetaData) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) Web30MetaData(org.jboss.metadata.web.spec.Web30MetaData) Web31MetaData(org.jboss.metadata.web.spec.Web31MetaData) HashSet(java.util.HashSet) AbsoluteOrderingMetaData(org.jboss.metadata.web.spec.AbsoluteOrderingMetaData) Manifest(java.util.jar.Manifest) LinkedList(java.util.LinkedList) WebFragmentMetaData(org.jboss.metadata.web.spec.WebFragmentMetaData) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) OrderingElementMetaData(org.jboss.metadata.web.spec.OrderingElementMetaData) WebCommonMetaData(org.jboss.metadata.web.spec.WebCommonMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) WebMetaData(org.jboss.metadata.web.spec.WebMetaData)

Example 12 with DeploymentUnitProcessingException

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

the class WarStructureDeploymentProcessor method createResourceRoots.

/**
     * Create the resource roots for a .war deployment
     *
     *
     * @param deploymentRoot the deployment root
     * @return the resource roots
     * @throws java.io.IOException for any error
     */
private List<ResourceRoot> createResourceRoots(final VirtualFile deploymentRoot, final DeploymentUnit deploymentUnit) throws IOException, DeploymentUnitProcessingException {
    final List<ResourceRoot> entries = new ArrayList<ResourceRoot>();
    // WEB-INF classes
    final VirtualFile webinfClasses = deploymentRoot.getChild(WEB_INF_CLASSES);
    if (webinfClasses.exists()) {
        final ResourceRoot webInfClassesRoot = new ResourceRoot(webinfClasses.getName(), webinfClasses, null);
        ModuleRootMarker.mark(webInfClassesRoot);
        entries.add(webInfClassesRoot);
    }
    // WEB-INF lib
    Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS);
    final VirtualFile webinfLib = deploymentRoot.getChild(WEB_INF_LIB);
    if (webinfLib.exists()) {
        final List<VirtualFile> archives = webinfLib.getChildren(DEFAULT_WEB_INF_LIB_FILTER);
        for (final VirtualFile archive : archives) {
            try {
                String relativeName = archive.getPathNameRelativeTo(deploymentRoot);
                MountedDeploymentOverlay overlay = overlays.get(relativeName);
                Closeable closable = null;
                if (overlay != null) {
                    overlay.remountAsZip(false);
                } else if (archive.isFile()) {
                    closable = VFS.mountZip(archive, archive, TempFileProviderService.provider());
                } else {
                    closable = null;
                }
                final ResourceRoot webInfArchiveRoot = new ResourceRoot(archive.getName(), archive, new MountHandle(closable));
                ModuleRootMarker.mark(webInfArchiveRoot);
                entries.add(webInfArchiveRoot);
            } catch (IOException e) {
                throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToProcessWebInfLib(archive), e);
            }
        }
    }
    return entries;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) MountedDeploymentOverlay(org.jboss.as.server.deployment.MountedDeploymentOverlay) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) MountHandle(org.jboss.as.server.deployment.module.MountHandle) Closeable(java.io.Closeable) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 13 with DeploymentUnitProcessingException

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

the class WebParsingDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    ClassLoader old = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(WebParsingDeploymentProcessor.class);
        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
            // Skip non web deployments
            return;
        }
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        final VirtualFile alternateDescriptor = deploymentRoot.getAttachment(org.jboss.as.ee.structure.Attachments.ALTERNATE_WEB_DEPLOYMENT_DESCRIPTOR);
        // Locate the descriptor
        final VirtualFile webXml;
        if (alternateDescriptor != null) {
            webXml = alternateDescriptor;
        } else {
            webXml = deploymentRoot.getRoot().getChild(WEB_XML);
        }
        final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
        assert warMetaData != null;
        if (webXml.exists()) {
            InputStream is = null;
            try {
                is = webXml.openStream();
                final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
                MetaDataElementParser.DTDInfo dtdInfo = new MetaDataElementParser.DTDInfo();
                inputFactory.setXMLResolver(dtdInfo);
                final XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is);
                WebMetaData webMetaData = WebMetaDataParser.parse(xmlReader, dtdInfo, SpecDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
                if (schemaValidation && webMetaData.getSchemaLocation() != null) {
                    XMLSchemaValidator validator = new XMLSchemaValidator(new XMLResourceResolver());
                    InputStream xmlInput = webXml.openStream();
                    try {
                        if (webMetaData.is23())
                            validator.validate("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", xmlInput);
                        else if (webMetaData.is24())
                            validator.validate("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd", xmlInput);
                        else if (webMetaData.is25())
                            validator.validate("http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd", xmlInput);
                        else if (webMetaData.is30())
                            validator.validate("http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd", xmlInput);
                        else if (webMetaData.is31())
                            validator.validate("http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd", xmlInput);
                        else
                            validator.validate("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", xmlInput);
                    } catch (SAXException e) {
                        throw new DeploymentUnitProcessingException("Failed to validate " + webXml, e);
                    } finally {
                        xmlInput.close();
                    }
                }
                warMetaData.setWebMetaData(webMetaData);
            } catch (XMLStreamException e) {
                Integer lineNumber = null;
                Integer columnNumber = null;
                if (e.getLocation() != null) {
                    lineNumber = e.getLocation().getLineNumber();
                    columnNumber = e.getLocation().getColumnNumber();
                }
                throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToParseXMLDescriptor(webXml.toString(), lineNumber, columnNumber), e);
            } catch (IOException e) {
                throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToParseXMLDescriptor(webXml.toString()), e);
            } finally {
                try {
                    if (is != null) {
                        is.close();
                    }
                } catch (IOException e) {
                // Ignore
                }
            }
        }
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) XMLStreamReader(javax.xml.stream.XMLStreamReader) InputStream(java.io.InputStream) XMLResourceResolver(org.jboss.metadata.parser.util.XMLResourceResolver) WarMetaData(org.jboss.as.web.common.WarMetaData) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) XMLStreamException(javax.xml.stream.XMLStreamException) MetaDataElementParser(org.jboss.metadata.parser.util.MetaDataElementParser) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) WebMetaData(org.jboss.metadata.web.spec.WebMetaData) XMLInputFactory(javax.xml.stream.XMLInputFactory) XMLSchemaValidator(org.jboss.metadata.parser.util.XMLSchemaValidator)

Example 14 with DeploymentUnitProcessingException

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

the class UndertowHandlersDeploymentProcessor method handleJbossWebXml.

private void handleJbossWebXml(DeploymentUnit deploymentUnit, Module module) throws DeploymentUnitProcessingException {
    WarMetaData warMetadata = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    if (warMetadata == null) {
        return;
    }
    JBossWebMetaData merged = warMetadata.getMergedJBossWebMetaData();
    if (merged == null) {
        return;
    }
    List<HttpHandlerMetaData> handlers = merged.getHandlers();
    if (handlers == null) {
        return;
    }
    for (HttpHandlerMetaData hander : handlers) {
        try {
            ClassLoader cl = module.getClassLoader();
            if (hander.getModule() != null) {
                Module handlerModule = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER).loadModule(ModuleIdentifier.fromString(hander.getModule()));
                cl = handlerModule.getClassLoader();
            }
            Class<?> handlerClass = cl.loadClass(hander.getHandlerClass());
            Map<String, String> params = new HashMap<>();
            if (hander.getParams() != null) {
                for (ParamValueMetaData param : hander.getParams()) {
                    params.put(param.getParamName(), param.getParamValue());
                }
            }
            deploymentUnit.addToAttachmentList(UndertowAttachments.UNDERTOW_OUTER_HANDLER_CHAIN_WRAPPERS, new ConfiguredHandlerWrapper(handlerClass, params));
        } catch (Exception e) {
            throw UndertowLogger.ROOT_LOGGER.failedToConfigureHandlerClass(hander.getHandlerClass(), e);
        }
    }
}
Also used : ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) HashMap(java.util.HashMap) WarMetaData(org.jboss.as.web.common.WarMetaData) IOException(java.io.IOException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) HttpHandlerMetaData(org.jboss.metadata.web.jboss.HttpHandlerMetaData) Module(org.jboss.modules.Module)

Example 15 with DeploymentUnitProcessingException

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

the class AbstractIntegrationProcessorJAXWS method registerView.

static ServiceName registerView(final ComponentDescription componentDescription, final String componentClassName) {
    final ViewDescription pojoView = new ViewDescription(componentDescription, componentClassName);
    componentDescription.getViews().add(pojoView);
    pojoView.getConfigurators().add(new ViewConfigurator() {

        @Override
        public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException {
            configuration.addViewInterceptor(AccessCheckingInterceptor.getFactory(), InterceptorOrder.View.CHECKING_INTERCEPTOR);
            // add WS POJO component instance associating interceptor
            configuration.addViewInterceptor(WSComponentInstanceAssociationInterceptor.FACTORY, InterceptorOrder.View.ASSOCIATING_INTERCEPTOR);
        }
    });
    return pojoView.getServiceName();
}
Also used : ViewConfigurator(org.jboss.as.ee.component.ViewConfigurator) ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ViewConfiguration(org.jboss.as.ee.component.ViewConfiguration) ViewDescription(org.jboss.as.ee.component.ViewDescription) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext)

Aggregations

DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)95 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)45 Module (org.jboss.modules.Module)28 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)26 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)26 VirtualFile (org.jboss.vfs.VirtualFile)22 InputStream (java.io.InputStream)20 IOException (java.io.IOException)19 ArrayList (java.util.ArrayList)18 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)18 ViewConfiguration (org.jboss.as.ee.component.ViewConfiguration)18 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)17 ViewDescription (org.jboss.as.ee.component.ViewDescription)16 Method (java.lang.reflect.Method)15 ViewConfigurator (org.jboss.as.ee.component.ViewConfigurator)15 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)15 ServiceName (org.jboss.msc.service.ServiceName)15 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)14 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)12 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)12