Search in sources :

Example 1 with WarMetaData

use of org.jboss.as.web.common.WarMetaData in project wildfly by wildfly.

the class JSFManagedBeanProcessor method getConfigurationFiles.

public Set<VirtualFile> getConfigurationFiles(DeploymentUnit deploymentUnit) {
    final Set<VirtualFile> ret = new HashSet<VirtualFile>();
    final List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
    for (final ResourceRoot resourceRoot : resourceRoots) {
        final VirtualFile webInfFacesConfig = resourceRoot.getRoot().getChild(WEB_INF_FACES_CONFIG);
        if (webInfFacesConfig.exists()) {
            ret.add(webInfFacesConfig);
        }
        //look for files that end in .faces-config.xml
        final VirtualFile metaInf = resourceRoot.getRoot().getChild("META-INF");
        if (metaInf.exists() && metaInf.isDirectory()) {
            for (final VirtualFile file : metaInf.getChildren()) {
                if (file.getName().equals("faces-config.xml") || file.getName().endsWith(".faces-config.xml")) {
                    ret.add(file);
                }
            }
        }
    }
    String configFiles = null;
    //now look for files in the javax.faces.CONFIG_FILES context param
    final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    if (warMetaData != null) {
        final WebMetaData webMetaData = warMetaData.getWebMetaData();
        if (webMetaData != null) {
            final List<ParamValueMetaData> contextParams = webMetaData.getContextParams();
            if (contextParams != null) {
                for (final ParamValueMetaData param : contextParams) {
                    if (param.getParamName().equals(CONFIG_FILES)) {
                        configFiles = param.getParamValue();
                        break;
                    }
                }
            }
        }
    }
    if (configFiles != null) {
        final String[] files = configFiles.split(",");
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        if (deploymentRoot != null) {
            for (final String file : files) {
                final VirtualFile configFile = deploymentRoot.getRoot().getChild(file);
                if (configFile.exists()) {
                    ret.add(configFile);
                }
            }
        }
    }
    return ret;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) WarMetaData(org.jboss.as.web.common.WarMetaData) WebMetaData(org.jboss.metadata.web.spec.WebMetaData) HashSet(java.util.HashSet)

Example 2 with WarMetaData

use of org.jboss.as.web.common.WarMetaData in project wildfly by wildfly.

the class EntityProviderService method configureWarMetadata.

private void configureWarMetadata(DeploymentUnit deploymentUnit) {
    WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    warMetaData.getMergedJBossWebMetaData().setSecurityDomain(this.getConfiguration().getSecurityDomain());
}
Also used : WarMetaData(org.jboss.as.web.common.WarMetaData)

Example 3 with WarMetaData

use of org.jboss.as.web.common.WarMetaData in project wildfly by wildfly.

the class JSFComponentProcessor method getConfigurationFiles.

public Set<VirtualFile> getConfigurationFiles(DeploymentUnit deploymentUnit) {
    final Set<VirtualFile> ret = new HashSet<VirtualFile>();
    final List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
    for (final ResourceRoot resourceRoot : resourceRoots) {
        final VirtualFile webInfFacesConfig = resourceRoot.getRoot().getChild(WEB_INF_FACES_CONFIG);
        if (webInfFacesConfig.exists()) {
            ret.add(webInfFacesConfig);
        }
        // look for files that end in .faces-config.xml
        final VirtualFile metaInf = resourceRoot.getRoot().getChild("META-INF");
        if (metaInf.exists() && metaInf.isDirectory()) {
            for (final VirtualFile file : metaInf.getChildren()) {
                if (file.getName().equals("faces-config.xml") || file.getName().endsWith(".faces-config.xml")) {
                    ret.add(file);
                }
            }
        }
    }
    String configFiles = null;
    // now look for files in the javax.faces.CONFIG_FILES context param
    final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    if (warMetaData != null) {
        final WebMetaData webMetaData = warMetaData.getWebMetaData();
        if (webMetaData != null) {
            final List<ParamValueMetaData> contextParams = webMetaData.getContextParams();
            if (contextParams != null) {
                for (final ParamValueMetaData param : contextParams) {
                    if (param.getParamName().equals(CONFIG_FILES)) {
                        configFiles = param.getParamValue();
                        break;
                    }
                }
            }
        }
    }
    if (configFiles != null) {
        final String[] files = configFiles.split(",");
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
        if (deploymentRoot != null) {
            for (final String file : files) {
                if (!file.isEmpty()) {
                    final VirtualFile configFile = deploymentRoot.getRoot().getChild(file);
                    if (configFile.exists()) {
                        ret.add(configFile);
                    }
                }
            }
        }
    }
    return ret;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) WarMetaData(org.jboss.as.web.common.WarMetaData) WebMetaData(org.jboss.metadata.web.spec.WebMetaData) HashSet(java.util.HashSet)

Example 4 with WarMetaData

use of org.jboss.as.web.common.WarMetaData in project wildfly by wildfly.

the class JSFMetadataProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    WarMetaData metaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    if (JsfVersionMarker.isJsfDisabled(deploymentUnit)) {
        return;
    }
    if (metaData == null || metaData.getMergedJBossWebMetaData() == null || metaData.getMergedJBossWebMetaData().getServlets() == null) {
        return;
    }
    JBossServletMetaData jsf = null;
    for (JBossServletMetaData servlet : metaData.getMergedJBossWebMetaData().getServlets()) {
        if (JAVAX_FACES_WEBAPP_FACES_SERVLET.equals(servlet.getServletClass())) {
            jsf = servlet;
        }
    }
    if (jsf != null && jsf.getMultipartConfig() == null) {
        // WFLY-2329 File upload doesn't work
        jsf.setMultipartConfig(new MultipartConfigMetaData());
    }
    if (disallowDoctypeDecl != null) {
        // Add the disallowDoctypeDecl context param if it's not already present
        setContextParameterIfAbsent(metaData.getMergedJBossWebMetaData(), DISALLOW_DOCTYPE_DECL, disallowDoctypeDecl.toString());
    }
    // This can otherwise cause missing @PreDestroy events.
    if (metaData.getMergedJBossWebMetaData().getDistributable() != null) {
        String disabled = Boolean.toString(false);
        if (!setContextParameterIfAbsent(metaData.getMergedJBossWebMetaData(), LAZY_BEAN_VALIDATION_PARAM, disabled).equals(disabled)) {
            JSFLogger.ROOT_LOGGER.lazyBeanValidationEnabled();
        }
    }
}
Also used : JBossServletMetaData(org.jboss.metadata.web.jboss.JBossServletMetaData) MultipartConfigMetaData(org.jboss.metadata.web.spec.MultipartConfigMetaData) WarMetaData(org.jboss.as.web.common.WarMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 5 with WarMetaData

use of org.jboss.as.web.common.WarMetaData in project wildfly by wildfly.

the class JSFVersionProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final DeploymentUnit topLevelDeployment = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
    final WarMetaData metaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    if (!shouldJsfActivate(deploymentUnit, metaData)) {
        JsfVersionMarker.setVersion(deploymentUnit, JsfVersionMarker.NONE);
        return;
    }
    if (metaData == null) {
        return;
    }
    List<ParamValueMetaData> contextParams = new ArrayList<ParamValueMetaData>();
    if ((metaData.getWebMetaData() != null) && (metaData.getWebMetaData().getContextParams() != null)) {
        contextParams.addAll(metaData.getWebMetaData().getContextParams());
    }
    if (metaData.getWebFragmentsMetaData() != null) {
        for (WebFragmentMetaData fragmentMetaData : metaData.getWebFragmentsMetaData().values()) {
            if (fragmentMetaData.getContextParams() != null) {
                contextParams.addAll(fragmentMetaData.getContextParams());
            }
        }
    }
    // to manually sort out the dependencies
    for (final ParamValueMetaData param : contextParams) {
        if ((param.getParamName().equals(WAR_BUNDLES_JSF_IMPL_PARAM) && (param.getParamValue() != null) && (param.getParamValue().toLowerCase(Locale.ENGLISH).equals("true")))) {
            JsfVersionMarker.setVersion(topLevelDeployment, JsfVersionMarker.WAR_BUNDLES_JSF_IMPL);
            // WAR_BUNDLES_JSF_IMPL always wins
            break;
        }
        if (param.getParamName().equals(JSF_CONFIG_NAME_PARAM)) {
            JsfVersionMarker.setVersion(topLevelDeployment, param.getParamValue());
            break;
        }
    }
}
Also used : ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) WarMetaData(org.jboss.as.web.common.WarMetaData) ArrayList(java.util.ArrayList) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) WebFragmentMetaData(org.jboss.metadata.web.spec.WebFragmentMetaData)

Aggregations

WarMetaData (org.jboss.as.web.common.WarMetaData)38 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)31 JBossWebMetaData (org.jboss.metadata.web.jboss.JBossWebMetaData)20 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)14 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)12 VirtualFile (org.jboss.vfs.VirtualFile)11 HashSet (java.util.HashSet)9 Module (org.jboss.modules.Module)9 ArrayList (java.util.ArrayList)8 ParamValueMetaData (org.jboss.metadata.javaee.spec.ParamValueMetaData)8 HashMap (java.util.HashMap)7 JBossServletMetaData (org.jboss.metadata.web.jboss.JBossServletMetaData)6 ListenerMetaData (org.jboss.metadata.web.spec.ListenerMetaData)6 IOException (java.io.IOException)5 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)5 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)5 WebMetaData (org.jboss.metadata.web.spec.WebMetaData)5 ServiceName (org.jboss.msc.service.ServiceName)5 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)4 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)4