Example #1
0
 @Override
 protected void populateModel(ModelNode operation, ModelNode model)
     throws OperationFailedException {
   WebDefinition.DEFAULT_VIRTUAL_SERVER.validateAndSet(operation, model);
   WebDefinition.NATIVE.validateAndSet(operation, model);
   WebDefinition.INSTANCE_ID.validateAndSet(operation, model);
 }
Example #2
0
  @Override
  protected void performBoottime(
      OperationContext context,
      ModelNode baseOperation,
      ModelNode model,
      ServiceVerificationHandler verificationHandler,
      List<ServiceController<?>> newControllers)
      throws OperationFailedException {
    ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
    final ModelNode config = resolveConfiguration(context, fullModel.get(Constants.CONFIGURATION));
    final String defaultVirtualServer =
        WebDefinition.DEFAULT_VIRTUAL_SERVER.resolveModelAttribute(context, fullModel).asString();

    final boolean useNative =
        WebDefinition.NATIVE.resolveModelAttribute(context, fullModel).asBoolean();
    final ModelNode instanceIdModel =
        WebDefinition.INSTANCE_ID.resolveModelAttribute(context, fullModel);
    final String instanceId = instanceIdModel.isDefined() ? instanceIdModel.asString() : null;

    context.addStep(
        new AbstractDeploymentChainStep() {
          @Override
          protected void execute(DeploymentProcessorTarget processorTarget) {

            final SharedWebMetaDataBuilder sharedWebBuilder =
                new SharedWebMetaDataBuilder(config.clone());
            final SharedTldsMetaDataBuilder sharedTldsBuilder =
                new SharedTldsMetaDataBuilder(config.clone());

            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.STRUCTURE,
                Phase.STRUCTURE_REGISTER_JBOSS_ALL_XML_PARSER,
                new JBossAllXmlParserRegisteringProcessor<JBossWebMetaData>(
                    WebJBossAllParser.ROOT_ELEMENT,
                    WebJBossAllParser.ATTACHMENT_KEY,
                    new WebJBossAllParser()));
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.STRUCTURE,
                Phase.STRUCTURE_WAR_DEPLOYMENT_INIT,
                new WarDeploymentInitializingProcessor());
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.STRUCTURE,
                Phase.STRUCTURE_WAR,
                new WarStructureDeploymentProcessor(sharedWebBuilder.create(), sharedTldsBuilder));
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_WEB_DEPLOYMENT,
                new WebParsingDeploymentProcessor());
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_WEB_DEPLOYMENT_FRAGMENT,
                new WebFragmentParsingDeploymentProcessor());
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_JBOSS_WEB_DEPLOYMENT,
                new JBossWebParsingDeploymentProcessor());
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_TLD_DEPLOYMENT,
                new TldParsingDeploymentProcessor());
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_ANNOTATION_WAR,
                new WarAnnotationDeploymentProcessor());
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_WEB_COMPONENTS,
                new WebComponentProcessor());
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_EAR_CONTEXT_ROOT,
                new EarContextRootProcessor());
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_WEB_MERGE_METADATA,
                new WarMetaDataProcessor());
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.PARSE,
                Phase.PARSE_WEB_INITIALIZE_IN_ORDER,
                new WebInitializeInOrderProcessor(defaultVirtualServer));

            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.DEPENDENCIES,
                Phase.DEPENDENCIES_WAR_MODULE,
                new WarClassloadingDependencyProcessor());

            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.INSTALL,
                Phase.INSTALL_SERVLET_INIT_DEPLOYMENT,
                new ServletContainerInitializerDeploymentProcessor());
            processorTarget.addDeploymentProcessor(
                WebExtension.SUBSYSTEM_NAME,
                Phase.INSTALL,
                Phase.INSTALL_WAR_DEPLOYMENT,
                new WarDeploymentProcessor(defaultVirtualServer));
          }
        },
        OperationContext.Stage.RUNTIME);

    final ServiceTarget target = context.getServiceTarget();
    final WebServerService service =
        new WebServerService(defaultVirtualServer, useNative, instanceId, TEMP_DIR);
    newControllers.add(
        target
            .addService(WebSubsystemServices.JBOSS_WEB, service)
            .addDependency(
                PathManagerService.SERVICE_NAME,
                PathManager.class,
                service.getPathManagerInjector())
            .addDependency(
                DependencyType.OPTIONAL,
                ServiceName.JBOSS.append("mbean", "server"),
                MBeanServer.class,
                service.getMbeanServer())
            .setInitialMode(Mode.ON_DEMAND)
            .install());

    final DistributedCacheManagerFactory factory =
        new DistributedCacheManagerFactoryService().getValue();
    if (factory != null) {
      final InjectedValue<WebServer> server = new InjectedValue<WebServer>();
      newControllers.add(
          target
              .addService(
                  DistributedCacheManagerFactoryService
                      .JVM_ROUTE_REGISTRY_ENTRY_PROVIDER_SERVICE_NAME,
                  new JvmRouteRegistryEntryProviderService(server))
              .addDependency(WebSubsystemServices.JBOSS_WEB, WebServer.class, server)
              .setInitialMode(Mode.ON_DEMAND)
              .install());
      newControllers.addAll(factory.installServices(target));
    }
  }