Search in sources :

Example 6 with ParamValueMetaData

use of org.jboss.metadata.javaee.spec.ParamValueMetaData in project wildfly by wildfly.

the class WebMetaDataHelper method newParamValue.

/**
     * Creates new parameter meta data and associates it with parameters meta data.
     *
     * @param key parameter key
     * @param value parameter value
     * @param paramsMD parameters meta data
     * @return new parameter meta data
     */
public static ParamValueMetaData newParamValue(final String key, final String value, final List<ParamValueMetaData> paramsMD) {
    final ParamValueMetaData paramValueMD = WebMetaDataHelper.newParamValue(key, value);
    paramsMD.add(paramValueMD);
    return paramValueMD;
}
Also used : ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData)

Example 7 with ParamValueMetaData

use of org.jboss.metadata.javaee.spec.ParamValueMetaData in project wildfly by wildfly.

the class WebMetaDataModifier method configureEndpoints.

/**
     * Configures transport servlet class for every found webservice endpoint.
     *
     * @param dep webservice deployment
     * @param jbossWebMD web meta data
     */
private void configureEndpoints(final Deployment dep, final JBossWebMetaData jbossWebMD) {
    final String transportClassName = this.getTransportClassName(dep);
    WSLogger.ROOT_LOGGER.trace("Modifying servlets");
    // get a list of the endpoint bean class names
    final Set<String> epNames = new HashSet<String>();
    for (Endpoint ep : dep.getService().getEndpoints()) {
        epNames.add(ep.getTargetBeanName());
    }
    // fix servlet class names for endpoints
    for (final ServletMetaData servletMD : jbossWebMD.getServlets()) {
        final String endpointClassName = ASHelper.getEndpointClassName(servletMD);
        if (endpointClassName != null && endpointClassName.length() > 0) {
            // exclude JSP
            if (epNames.contains(endpointClassName)) {
                // set transport servlet
                servletMD.setServletClass(WSFServlet.class.getName());
                WSLogger.ROOT_LOGGER.tracef("Setting transport class: %s for endpoint: %s", transportClassName, endpointClassName);
                final List<ParamValueMetaData> initParams = WebMetaDataHelper.getServletInitParams(servletMD);
                // configure transport class name
                WebMetaDataHelper.newParamValue(WSFServlet.STACK_SERVLET_DELEGATE_CLASS, transportClassName, initParams);
                // configure webservice endpoint
                WebMetaDataHelper.newParamValue(Endpoint.SEPID_DOMAIN_ENDPOINT, endpointClassName, initParams);
            } else if (endpointClassName.startsWith("org.apache.cxf")) {
                throw WSLogger.ROOT_LOGGER.invalidWSServlet(endpointClassName);
            }
        }
    }
}
Also used : ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) Endpoint(org.jboss.wsf.spi.deployment.Endpoint) ServletMetaData(org.jboss.metadata.web.spec.ServletMetaData) HashSet(java.util.HashSet) WSFServlet(org.jboss.wsf.spi.deployment.WSFServlet)

Example 8 with ParamValueMetaData

use of org.jboss.metadata.javaee.spec.ParamValueMetaData in project wildfly by wildfly.

the class EndpointPublisherImpl method addServlets.

private static void addServlets(JBossWebMetaData jbwebMD, WebDeploymentBuilder deployment) {
    for (JBossServletMetaData smd : jbwebMD.getServlets()) {
        final String sc = smd.getServletClass();
        if (sc.equals(WSFServlet.class.getName())) {
            ServletBuilder servletBuilder = new ServletBuilder();
            final String servletName = smd.getServletName();
            List<ParamValueMetaData> params = smd.getInitParam();
            List<String> urlPatterns = null;
            for (ServletMappingMetaData smmd : jbwebMD.getServletMappings()) {
                if (smmd.getServletName().equals(servletName)) {
                    urlPatterns = smmd.getUrlPatterns();
                    servletBuilder.addUrlMappings(urlPatterns);
                    break;
                }
            }
            WSFServlet wsfs = new WSFServlet();
            servletBuilder.setServletName(servletName);
            servletBuilder.setServlet(wsfs);
            servletBuilder.setServletClass(WSFServlet.class);
            for (ParamValueMetaData param : params) {
                servletBuilder.addInitParam(param.getParamName(), param.getParamValue());
            }
            deployment.addServlet(servletBuilder);
        }
    }
}
Also used : ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) ServletMappingMetaData(org.jboss.metadata.web.spec.ServletMappingMetaData) JBossServletMetaData(org.jboss.metadata.web.jboss.JBossServletMetaData) ServletBuilder(org.jboss.as.web.host.ServletBuilder) WSFServlet(org.jboss.wsf.spi.deployment.WSFServlet)

Example 9 with ParamValueMetaData

use of org.jboss.metadata.javaee.spec.ParamValueMetaData in project wildfly by wildfly.

the class WebIntegrationProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription module = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        // Skip non web deployments
        return;
    }
    WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    if (warMetaData == null) {
        WeldLogger.DEPLOYMENT_LOGGER.debug("Not installing Weld web tier integration as no war metadata found");
        return;
    }
    JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
    if (webMetaData == null) {
        WeldLogger.DEPLOYMENT_LOGGER.debug("Not installing Weld web tier integration as no merged web metadata found");
        return;
    }
    if (!WeldDeploymentMarker.isWeldDeployment(deploymentUnit)) {
        if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
            createDependency(deploymentUnit, warMetaData);
        }
        return;
    }
    createDependency(deploymentUnit, warMetaData);
    List<ListenerMetaData> listeners = webMetaData.getListeners();
    if (listeners == null) {
        listeners = new ArrayList<ListenerMetaData>();
        webMetaData.setListeners(listeners);
    } else {
        //if the weld servlet listener is present remove it
        //this should allow wars to be portable between AS7 and servlet containers
        final ListIterator<ListenerMetaData> iterator = listeners.listIterator();
        while (iterator.hasNext()) {
            final ListenerMetaData listener = iterator.next();
            if (listener.getListenerClass().trim().equals(WELD_SERVLET_LISTENER)) {
                WeldLogger.DEPLOYMENT_LOGGER.debugf("Removing weld servlet listener %s from web config, as it is not needed in EE6 environments", WELD_SERVLET_LISTENER);
                iterator.remove();
                break;
            }
        }
    }
    listeners.add(0, INITIAL_LISTENER_METADATA);
    listeners.add(TERMINAL_LISTENER_MEDATADA);
    //These listeners use resource injection, so they need to be components
    registerAsComponent(WELD_INITIAL_LISTENER, deploymentUnit);
    registerAsComponent(WELD_TERMINAL_LISTENER, deploymentUnit);
    deploymentUnit.addToAttachmentList(ExpressionFactoryWrapper.ATTACHMENT_KEY, WeldJspExpressionFactoryWrapper.INSTANCE);
    if (webMetaData.getContextParams() == null) {
        webMetaData.setContextParams(new ArrayList<ParamValueMetaData>());
    }
    final List<ParamValueMetaData> contextParams = webMetaData.getContextParams();
    setupWeldContextIgnores(contextParams, InitParameters.CONTEXT_IGNORE_FORWARD);
    setupWeldContextIgnores(contextParams, InitParameters.CONTEXT_IGNORE_INCLUDE);
    if (webMetaData.getFilterMappings() != null) {
        // register ConversationFilter
        boolean filterMappingFound = false;
        for (FilterMappingMetaData mapping : webMetaData.getFilterMappings()) {
            if (CONVERSATION_FILTER_NAME.equals(mapping.getFilterName())) {
                filterMappingFound = true;
                break;
            }
        }
        if (filterMappingFound) {
            // otherwise WeldListener will take care of conversation context activation
            boolean filterFound = false;
            // register ConversationFilter
            if (webMetaData.getFilters() == null) {
                webMetaData.setFilters(new FiltersMetaData());
            }
            for (FilterMetaData filter : webMetaData.getFilters()) {
                if (CONVERSATION_FILTER_CLASS.equals(filter.getFilterClass())) {
                    filterFound = true;
                    break;
                }
            }
            if (!filterFound) {
                webMetaData.getFilters().add(conversationFilterMetadata);
                registerAsComponent(CONVERSATION_FILTER_CLASS, deploymentUnit);
                webMetaData.getContextParams().add(CONVERSATION_FILTER_INITIALIZED);
            }
        }
    }
}
Also used : ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) FilterMetaData(org.jboss.metadata.web.spec.FilterMetaData) WarMetaData(org.jboss.as.web.common.WarMetaData) FiltersMetaData(org.jboss.metadata.web.spec.FiltersMetaData) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) ListenerMetaData(org.jboss.metadata.web.spec.ListenerMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) FilterMappingMetaData(org.jboss.metadata.web.spec.FilterMappingMetaData)

Example 10 with ParamValueMetaData

use of org.jboss.metadata.javaee.spec.ParamValueMetaData in project wildfly by wildfly.

the class JaxrsSpringProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getParent() != null) {
        return;
    }
    final List<DeploymentUnit> deploymentUnits = new ArrayList<DeploymentUnit>();
    deploymentUnits.add(deploymentUnit);
    deploymentUnits.addAll(deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS));
    boolean found = false;
    for (DeploymentUnit unit : deploymentUnits) {
        WarMetaData warMetaData = unit.getAttachment(WarMetaData.ATTACHMENT_KEY);
        if (warMetaData == null) {
            continue;
        }
        JBossWebMetaData md = warMetaData.getMergedJBossWebMetaData();
        if (md == null) {
            continue;
        }
        if (md.getContextParams() != null) {
            boolean skip = false;
            for (ParamValueMetaData prop : md.getContextParams()) {
                if (prop.getParamName().equals(ENABLE_PROPERTY)) {
                    boolean explicitEnable = Boolean.parseBoolean(prop.getParamValue());
                    if (explicitEnable) {
                        found = true;
                    } else {
                        skip = true;
                    }
                    break;
                } else if (prop.getParamName().equals(DISABLE_PROPERTY) && "true".equals(prop.getParamValue())) {
                    skip = true;
                    JaxrsLogger.JAXRS_LOGGER.disablePropertyDeprecated();
                    break;
                }
            }
            if (skip) {
                continue;
            }
        }
        if (md.getListeners() != null) {
            for (ListenerMetaData listener : md.getListeners()) {
                if (SPRING_LISTENER.equals(listener.getListenerClass())) {
                    found = true;
                    break;
                }
            }
        }
        if (md.getServlets() != null) {
            for (JBossServletMetaData servlet : md.getServlets()) {
                if (SPRING_SERVLET.equals(servlet.getServletClass())) {
                    found = true;
                    break;
                }
            }
        }
        if (found) {
            try {
                // actual close is done by the MSC service above
                MountHandle mh = new MountHandle(null);
                ResourceRoot resourceRoot = new ResourceRoot(getResteasySpringVirtualFile(), mh);
                ModuleRootMarker.mark(resourceRoot);
                deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot);
            } catch (Exception e) {
                throw new DeploymentUnitProcessingException(e);
            }
            return;
        }
    }
}
Also used : ParamValueMetaData(org.jboss.metadata.javaee.spec.ParamValueMetaData) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) MountHandle(org.jboss.as.server.deployment.module.MountHandle) JBossServletMetaData(org.jboss.metadata.web.jboss.JBossServletMetaData) ArrayList(java.util.ArrayList) WarMetaData(org.jboss.as.web.common.WarMetaData) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) StartException(org.jboss.msc.service.StartException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ListenerMetaData(org.jboss.metadata.web.spec.ListenerMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

ParamValueMetaData (org.jboss.metadata.javaee.spec.ParamValueMetaData)24 WarMetaData (org.jboss.as.web.common.WarMetaData)7 JBossWebMetaData (org.jboss.metadata.web.jboss.JBossWebMetaData)6 ArrayList (java.util.ArrayList)5 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)5 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)5 JBossServletMetaData (org.jboss.metadata.web.jboss.JBossServletMetaData)5 HashSet (java.util.HashSet)4 ListenerMetaData (org.jboss.metadata.web.spec.ListenerMetaData)4 ServletMappingMetaData (org.jboss.metadata.web.spec.ServletMappingMetaData)4 FilterMappingMetaData (org.jboss.metadata.web.spec.FilterMappingMetaData)3 FilterMetaData (org.jboss.metadata.web.spec.FilterMetaData)3 SecurityConstraint (io.undertow.servlet.api.SecurityConstraint)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 TagLibraryInfo (org.apache.jasper.deploy.TagLibraryInfo)2 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)2 ServletMetaData (org.jboss.metadata.web.spec.ServletMetaData)2 StartException (org.jboss.msc.service.StartException)2 HttpServlet30Dispatcher (org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher)2