Search in sources :

Example 1 with HttpHandlerMetaData

use of org.jboss.metadata.web.jboss.HttpHandlerMetaData 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)

Aggregations

IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 WarMetaData (org.jboss.as.web.common.WarMetaData)1 ParamValueMetaData (org.jboss.metadata.javaee.spec.ParamValueMetaData)1 HttpHandlerMetaData (org.jboss.metadata.web.jboss.HttpHandlerMetaData)1 JBossWebMetaData (org.jboss.metadata.web.jboss.JBossWebMetaData)1 Module (org.jboss.modules.Module)1