Ejemplo n.º 1
0
    @Override
    protected void addExtraServices(ServiceTarget target) {
      super.addExtraServices(target);
      target
          .addService(Services.JBOSS_SERVICE_MODULE_LOADER, new ServiceModuleLoader(null))
          .install();
      target
          .addService(ContextNames.JAVA_CONTEXT_SERVICE_NAME, new NamingStoreService())
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();
      target
          .addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, new NamingStoreService())
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();

      target
          .addService(
              IOServices.WORKER.append("default"),
              new WorkerService(OptionMap.builder().set(Options.WORKER_IO_THREADS, 2).getMap()))
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();

      target
          .addService(
              IOServices.WORKER.append("non-default"),
              new WorkerService(OptionMap.builder().set(Options.WORKER_IO_THREADS, 2).getMap()))
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();

      target
          .addService(
              IOServices.BUFFER_POOL.append("default"), new BufferPoolService(2048, 2048, true))
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();
      // ListenerRegistry.Listener listener = new ListenerRegistry.Listener("http", "default",
      // "default",
      // InetSocketAddress.createUnresolved("localhost",8080));
      target
          .addService(HttpListenerAdd.REGISTRY_SERVICE_NAME, new HttpListenerRegistryService())
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();

      target
          .addService(
              SecurityRealm.ServiceUtil.createServiceName("UndertowRealm"),
              new SecurityRealmService("UndertowRealm", false))
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();
      target
          .addService(
              SecurityRealm.ServiceUtil.createServiceName("other"),
              new SecurityRealmService("other", false))
          .setInitialMode(ServiceController.Mode.ACTIVE)
          .install();
    }
Ejemplo n.º 2
0
  @Override
  protected void performRuntime(
      OperationContext context,
      ModelNode operation,
      ModelNode model,
      ServiceVerificationHandler verificationHandler,
      List<ServiceController<?>> newControllers)
      throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final PathAddress parent = address.subAddress(0, address.size() - 1);
    String name = address.getLastElement().getValue();
    String bindingRef =
        ListenerResourceDefinition.SOCKET_BINDING.resolveModelAttribute(context, model).asString();
    String workerName =
        ListenerResourceDefinition.WORKER.resolveModelAttribute(context, model).asString();
    String bufferPoolName =
        ListenerResourceDefinition.BUFFER_POOL.resolveModelAttribute(context, model).asString();
    boolean enabled =
        ListenerResourceDefinition.ENABLED.resolveModelAttribute(context, model).asBoolean();
    OptionMap listenerOptions =
        OptionList.resolveOptions(context, model, ListenerResourceDefinition.LISTENER_OPTIONS);
    OptionMap socketOptions =
        OptionList.resolveOptions(context, model, ListenerResourceDefinition.SOCKET_OPTIONS);
    String serverName = parent.getLastElement().getValue();
    final ServiceName listenerServiceName = UndertowService.listenerName(name);
    final ListenerService<? extends ListenerService> service =
        createService(name, serverName, context, model, listenerOptions, socketOptions);
    final ServiceBuilder<? extends ListenerService> serviceBuilder =
        context.getServiceTarget().addService(listenerServiceName, service);
    serviceBuilder
        .addDependency(IOServices.WORKER.append(workerName), XnioWorker.class, service.getWorker())
        .addDependency(
            SocketBinding.JBOSS_BINDING_NAME.append(bindingRef),
            SocketBinding.class,
            service.getBinding())
        .addDependency(
            IOServices.BUFFER_POOL.append(bufferPoolName), Pool.class, service.getBufferPool())
        .addDependency(
            UndertowService.SERVER.append(serverName), Server.class, service.getServerService());

    configureAdditionalDependencies(context, serviceBuilder, model, service);
    serviceBuilder.setInitialMode(
        enabled ? ServiceController.Mode.ACTIVE : ServiceController.Mode.NEVER);

    serviceBuilder.addListener(verificationHandler);
    final ServiceController<? extends ListenerService> serviceController = serviceBuilder.install();
    if (newControllers != null) {
      newControllers.add(serviceController);
    }
  }