@Override
 protected void initializeExtraSubystemsAndModel(
     ExtensionRegistry extensionRegistry,
     Resource rootResource,
     ManagementResourceRegistration rootRegistration,
     RuntimeCapabilityRegistry capabilityRegistry) {
   super.initializeExtraSubystemsAndModel(
       extensionRegistry, rootResource, rootRegistration, capabilityRegistry);
   Map<String, Class> capabilities = new HashMap<>();
   capabilities.put(
       buildDynamicCapabilityName(
           ListenerResourceDefinition.IO_WORKER_CAPABILITY,
           ListenerResourceDefinition.WORKER.getDefaultValue().asString()),
       XnioWorker.class);
   capabilities.put(
       buildDynamicCapabilityName(
           ListenerResourceDefinition.IO_WORKER_CAPABILITY, "non-default"),
       XnioWorker.class);
   capabilities.put(
       buildDynamicCapabilityName(
           ListenerResourceDefinition.IO_BUFFER_POOL_CAPABILITY,
           ListenerResourceDefinition.BUFFER_POOL.getDefaultValue().asString()),
       Pool.class);
   for (String entry : sockets.keySet()) {
     capabilities.put(
         buildDynamicCapabilityName(ListenerResourceDefinition.SOCKET_CAPABILITY, entry),
         SocketBinding.class);
   }
   registerServiceCapabilities(capabilityRegistry, capabilities);
 }
Exemple #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);
    }
  }