package org.jboss.as.undertow; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import org.jboss.as.controller.Extension; import org.jboss.as.controller.ExtensionContext; import org.jboss.as.controller.PathElement; import org.jboss.as.controller.SubsystemRegistration; import org.jboss.as.controller.descriptions.NonResolvingResourceDescriptionResolver; import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver; import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler; import org.jboss.as.controller.parsing.ExtensionParsingContext; import org.jboss.as.controller.registry.ManagementResourceRegistration; /** * @author <a href="mailto:tomaz.cerar@redhat.com">Tomaz Cerar</a> (c) 2012 Red Hat Inc. */ public class UndertowExtension implements Extension { public static final String SUBSYSTEM_NAME = "undertow"; protected static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME); protected static final PathElement AJP_LISTENER_PATH = PathElement.pathElement(Constants.AJP_LISTENER); protected static final PathElement BUFFER_POOL_PATH = PathElement.pathElement(Constants.BUFFER_POOL); protected static final PathElement HOST_PATH = PathElement.pathElement(Constants.HOST); protected static final PathElement HTTP_LISTENER_PATH = PathElement.pathElement(Constants.HTTP_LISTENER); protected static final PathElement HTTPS_LISTENER_PATH = PathElement.pathElement(Constants.HTTPS_LISTENER); protected static final PathElement WORKER_PATH = PathElement.pathElement(Constants.WORKER); protected static final PathElement PATH_SERVLET_CONTAINER = PathElement.pathElement(Constants.SERVLET_CONTAINER); protected static final PathElement PATH_LOCATION = PathElement.pathElement(Constants.LOCATION); protected static final PathElement SERVER_PATH = PathElement.pathElement(Constants.SERVER); public static final PathElement PATH_JSP = PathElement.pathElement(Constants.SETTING, Constants.JSP); private static final String RESOURCE_NAME = UndertowExtension.class.getPackage().getName() + ".LocalDescriptions"; public static StandardResourceDescriptionResolver getResolver(final String... keyPrefix) { /*StringBuilder prefix = new StringBuilder(SUBSYSTEM_NAME); for (String kp : keyPrefix) { prefix.append('.').append(kp); } return new StandardResourceDescriptionResolver(prefix.toString(), RESOURCE_NAME, UndertowExtension.class.getClassLoader(), true, false);*/ //todo for now we don't care about this and since model is subject to often change in this phase, no need to resolve properties return new NonResolvingResourceDescriptionResolver(); } @Override public void initializeParsers(ExtensionParsingContext context) { context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.UNDERTOW_1_0.getUriString(), UndertowSubsystemParser.INSTANCE); } @Override public void initialize(ExtensionContext context) { final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, 1, 0, 0); final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(UndertowRootDefinition.INSTANCE); registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE, false); registration.registerSubModel(WorkerResourceDefinition.INSTANCE); registration.registerSubModel(BufferPoolResourceDefinition.INSTANCE); registration.registerSubModel(ServerDefinition.INSTANCE); registration.registerSubModel(ServletContainerDefinition.INSTANCE); final ManagementResourceRegistration deployments = subsystem.registerDeploymentModel(DeploymentDefinition.INSTANCE); deployments.registerSubModel(DeploymentServletDefinition.INSTANCE); subsystem.registerXMLElementWriter(UndertowSubsystemParser.INSTANCE); } }