Skip to content
Permalink
Browse files

[WFCORE-4412] Eliminating CapabilityServiceTarget.addCapability() dep…

…recated method usages
  • Loading branch information
ropalka committed Apr 9, 2019
1 parent 1d3d387 commit 75df45d5e1e35941b2497bdb694a69c8c538921e
@@ -58,12 +58,14 @@
this.initialMode = checkNotNullParam("initialMode", initialMode);
}

@SuppressWarnings("unchecked")
@Override
protected final void performRuntime(OperationContext context, ModelNode operation, Resource resource)
throws OperationFailedException {
TrivialService<T> trivialService = new TrivialService<T>();

ServiceBuilder<T> serviceBuilder = context.getCapabilityServiceTarget().addCapability(runtimeCapability, trivialService);
ServiceBuilder<T> serviceBuilder = (ServiceBuilder<T>)context.getCapabilityServiceTarget().addCapability(runtimeCapability);
serviceBuilder.setInstance(trivialService);

trivialService.setValueSupplier(getValueSupplier(serviceBuilder, context, resource.getModel()));

@@ -142,7 +142,8 @@ protected boolean requiresRuntime(OperationContext context) {
service.getPortInjector().inject(port);
service.getSecurePortInjector().inject(securePort);
service.getAllowedOriginsInjector().inject(commonPolicy.getAllowedOrigins());
CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY, service)
CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY)
.setInstance(service)
.addCapabilityRequirement("org.wildfly.network.interface",
NetworkInterfaceBinding.class, service.getInterfaceInjector(), interfaceName)
.addCapabilityRequirement("org.wildfly.network.interface",
@@ -155,13 +155,15 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod
final boolean direct = directModel.isDefined() ? directModel.asBoolean() : defaultDirectBuffers;

final BufferPoolService service = new BufferPoolService(bufferSize, bufferPerSlice, direct);
context.getCapabilityServiceTarget().addCapability(IO_POOL_RUNTIME_CAPABILITY, service)
context.getCapabilityServiceTarget().addCapability(IO_POOL_RUNTIME_CAPABILITY)
.setInstance(service)
.setInitialMode(ServiceController.Mode.ON_DEMAND)
.install();

ByteBufferPoolService poolService = new ByteBufferPoolService();

context.getCapabilityServiceTarget().addCapability(IO_BYTE_BUFFER_POOL_RUNTIME_CAPABILITY, poolService)
context.getCapabilityServiceTarget().addCapability(IO_BYTE_BUFFER_POOL_RUNTIME_CAPABILITY)
.setInstance(poolService)
.addCapabilityRequirement(IO_POOL_RUNTIME_CAPABILITY.getDynamicName(address), Pool.class, poolService.bufferPool)
.setInitialMode(ServiceController.Mode.ON_DEMAND)
.install();
@@ -217,7 +217,8 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod
registerMax(context, name, workerThreads);

final WorkerService workerService = new WorkerService(builder);
context.getCapabilityServiceTarget().addCapability(IO_WORKER_RUNTIME_CAPABILITY, workerService)
context.getCapabilityServiceTarget().addCapability(IO_WORKER_RUNTIME_CAPABILITY)
.setInstance(workerService)
.addCapabilityRequirement("org.wildfly.management.executor",
ExecutorService.class, workerService.injectedExecutor)
.setInitialMode(ServiceController.Mode.ON_DEMAND)
@@ -83,7 +83,8 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod
}
}

context.getCapabilityServiceTarget().addCapability(REMOTING_ENDPOINT_CAPABILITY, endpointService)
context.getCapabilityServiceTarget().addCapability(REMOTING_ENDPOINT_CAPABILITY)
.setInstance(endpointService)
.addCapabilityRequirement(IO_WORKER_CAPABILITY_NAME, XnioWorker.class, endpointService.getWorker(), workerName)
.install();
}
@@ -66,7 +66,6 @@
import org.jboss.as.server.mgmt.HttpShutdownService;
import org.jboss.as.server.mgmt.ManagementWorkerService;
import org.jboss.as.server.mgmt.UndertowHttpManagementService;
import org.jboss.as.server.mgmt.domain.HttpManagement;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
@@ -137,8 +136,10 @@ protected boolean requiresRuntime(OperationContext context) {
ServerEnvironment environment = (ServerEnvironment) context.getServiceRegistry(false).getRequiredService(ServerEnvironmentService.SERVICE_NAME).getValue();
final UndertowHttpManagementService undertowService = new UndertowHttpManagementService(consoleMode, environment.getProductConfig().getConsoleSlot());
undertowService.getAllowedOriginsInjector().inject(commonPolicy.getAllowedOrigins());
CapabilityServiceBuilder<HttpManagement> undertowBuilder = serviceTarget.addCapability(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY, undertowService).addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, undertowService.getModelControllerInjector())
CapabilityServiceBuilder<?> undertowBuilder = serviceTarget.addCapability(EXTENSIBLE_HTTP_MANAGEMENT_CAPABILITY)
.setInstance(undertowService)
.addCapabilityRequirement("org.wildfly.management.socket-binding-manager", SocketBindingManager.class, undertowService.getSocketBindingManagerInjector())
.addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, undertowService.getModelControllerInjector())
.addDependency(ControlledProcessStateService.SERVICE_NAME, ControlledProcessStateService.class, undertowService.getControlledProcessStateServiceInjector())
.addDependency(RemotingServices.HTTP_LISTENER_REGISTRY, ListenerRegistry.class, undertowService.getListenerRegistry())
.addDependency(requestProcessorName, ManagementHttpRequestProcessor.class, undertowService.getRequestProcessorValue())
@@ -99,7 +99,8 @@ static void installBindingService(OperationContext context, ModelNode config, St
final List<ClientMapping> clientMappings = mappingsNode.isDefined() ? parseClientMappings(context, mappingsNode) : null;

final SocketBindingService service = new SocketBindingService(name, port, fixedPort, mcastInet, mcastPort, clientMappings);
final CapabilityServiceBuilder<SocketBinding> builder = serviceTarget.addCapability(SOCKET_BINDING_CAPABILITY, service);
final CapabilityServiceBuilder<?> builder = serviceTarget.addCapability(SOCKET_BINDING_CAPABILITY);
builder.setInstance(service);
if (intf != null) {
builder.addCapabilityRequirement("org.wildfly.network.interface", NetworkInterfaceBinding.class, service.getInterfaceBinding(), intf);
}
@@ -108,7 +108,8 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod
String defaultInterface = SocketBindingGroupResourceDefinition.DEFAULT_INTERFACE.resolveModelAttribute(context, model).asString();

SocketBindingManagerService service = new SocketBindingManagerService(portOffset);
context.getCapabilityServiceTarget().addCapability(SOCKET_BINDING_MANAGER_CAPABILITY, service)
context.getCapabilityServiceTarget().addCapability(SOCKET_BINDING_MANAGER_CAPABILITY)
.setInstance(service)
.addCapabilityRequirement("org.wildfly.network.interface", NetworkInterfaceBinding.class, service.getDefaultInterfaceBindingInjector(), defaultInterface)
.setInitialMode(ServiceController.Mode.ON_DEMAND)
.addAliases(SocketBindingManager.SOCKET_BINDING_MANAGER)
@@ -147,7 +147,8 @@ static void installOutboundSocketBindingService(final OperationContext context,

// create the service
final LocalDestinationOutboundSocketBindingService outboundSocketBindingService = new LocalDestinationOutboundSocketBindingService(outboundSocketName, sourcePort, fixedSourcePort);
final CapabilityServiceBuilder<OutboundSocketBinding> serviceBuilder = serviceTarget.addCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY, outboundSocketBindingService);
final CapabilityServiceBuilder<?> serviceBuilder = serviceTarget.addCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY);
serviceBuilder.setInstance(outboundSocketBindingService);
// if a source interface has been specified then add a dependency on it
if (sourceInterfaceName != null) {
serviceBuilder.addCapabilityRequirement("org.wildfly.network.interface", NetworkInterfaceBinding.class, outboundSocketBindingService.getSourceNetworkInterfaceBindingInjector(), sourceInterfaceName);
@@ -147,7 +147,8 @@ static void installOutboundSocketBindingService(final OperationContext context,

// create the service
final OutboundSocketBindingService outboundSocketBindingService = new RemoteDestinationOutboundSocketBindingService(outboundSocketName, destinationHost, destinationPort, sourcePort, fixedSourcePort);
final CapabilityServiceBuilder<OutboundSocketBinding> serviceBuilder = serviceTarget.addCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY, outboundSocketBindingService);
final CapabilityServiceBuilder<?> serviceBuilder = serviceTarget.addCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY);
serviceBuilder.setInstance(outboundSocketBindingService);
// if a source interface has been specified then add a dependency on it
if (sourceInterfaceName != null) {
serviceBuilder.addCapabilityRequirement("org.wildfly.network.interface", NetworkInterfaceBinding.class, outboundSocketBindingService.getSourceNetworkInterfaceBindingInjector(), sourceInterfaceName);
@@ -45,7 +45,8 @@ protected boolean requiresRuntime(OperationContext context) {

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, String name, ParsedInterfaceCriteria criteria) {
context.getCapabilityServiceTarget().addCapability(InterfaceResourceDefinition.INTERFACE_CAPABILITY.fromBaseCapability(name), createInterfaceService(name, criteria))
context.getCapabilityServiceTarget().addCapability(InterfaceResourceDefinition.INTERFACE_CAPABILITY.fromBaseCapability(name))
.setInstance(createInterfaceService(name, criteria))
.addAliases(NetworkInterfaceService.JBOSS_NETWORK_INTERFACE.append(name))
.setInitialMode(ServiceController.Mode.ON_DEMAND)
.install();

0 comments on commit 75df45d

Please sign in to comment.
You can’t perform that action at this time.