Skip to content

Commit

Permalink
Merge pull request wildfly#18062 from pferraro/main
Browse files Browse the repository at this point in the history
WFLY-19548 Remove redundant capability name String instances for core capabilities
  • Loading branch information
bstansberry authored Jul 23, 2024
2 parents b3b32dc + 631398f commit 5e7a24f
Show file tree
Hide file tree
Showing 48 changed files with 136 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import java.io.File;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Supplier;

Expand All @@ -43,18 +43,18 @@ public class ApplicationClientDeploymentService implements Service {
private final File path;
private final Consumer<ApplicationClientDeploymentService> consumer;
private final Supplier<ModelControllerClientFactory> clientFactorySupplier;
private final Supplier<ExecutorService> executorServiceSupplier;
private final Supplier<Executor> executorSupplier;
private final CountDownLatch deploymentCompleteLatch = new CountDownLatch(1);


public ApplicationClientDeploymentService(final Consumer<ApplicationClientDeploymentService> consumer,
final File path,
final Supplier<ModelControllerClientFactory> clientFactorySupplier,
final Supplier<ExecutorService> executorServiceSupplier) {
final Supplier<Executor> executorSupplier) {
this.consumer = consumer;
this.path = path;
this.clientFactorySupplier = clientFactorySupplier;
this.executorServiceSupplier = executorServiceSupplier;
this.executorSupplier = executorSupplier;
}

@Override
Expand Down Expand Up @@ -111,7 +111,7 @@ private DeploymentTask(final Operation deploymentOp) {

@Override
public void run() {
try (LocalModelControllerClient controllerClient = clientFactorySupplier.get().createSuperUserClient(executorServiceSupplier.get())) {
try (LocalModelControllerClient controllerClient = clientFactorySupplier.get().createSuperUserClient(executorSupplier.get())) {
ModelNode result = controllerClient.execute(deploymentOp);
if (!SUCCESS.equals(result.get(OUTCOME).asString())) {
System.exit(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Supplier;

Expand All @@ -28,6 +28,7 @@
import org.jboss.as.controller.ModelControllerClientFactory;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.management.Capabilities;
import org.jboss.as.server.AbstractDeploymentChainStep;
import org.jboss.as.server.DeploymentProcessorTarget;
import org.jboss.as.server.deployment.Phase;
Expand All @@ -40,8 +41,6 @@
import org.jboss.msc.service.StopContext;

import static org.jboss.as.appclient.subsystem.AppClientSubsystemResourceDefinition.APPCLIENT_CAPABILITY;
import static org.jboss.as.appclient.subsystem.AppClientSubsystemResourceDefinition.EXECUTOR_CAPABILITY;
import static org.jboss.as.appclient.subsystem.AppClientSubsystemResourceDefinition.MCF_CAPABILITY;
import static org.jboss.as.appclient.subsystem.Constants.CONNECTION_PROPERTIES_URL;
import static org.jboss.as.appclient.subsystem.Constants.HOST_URL;

Expand Down Expand Up @@ -97,11 +96,9 @@ protected void execute(DeploymentProcessorTarget processorTarget) {

CapabilityServiceBuilder<?> builder = context.getCapabilityServiceTarget().addCapability(APPCLIENT_CAPABILITY);
Consumer<ApplicationClientDeploymentService> consumer = builder.provides(APPCLIENT_CAPABILITY);
Supplier<ModelControllerClientFactory> mcfSupplier =
builder.requiresCapability(MCF_CAPABILITY, ModelControllerClientFactory.class);
Supplier<ExecutorService> esSupplier =
builder.requiresCapability(EXECUTOR_CAPABILITY, ExecutorService.class);
builder.setInstance(new ApplicationClientDeploymentService(consumer, file, mcfSupplier, esSupplier));
Supplier<ModelControllerClientFactory> mcfSupplier = builder.requires(ModelControllerClientFactory.SERVICE_DESCRIPTOR);
Supplier<Executor> executorSupplier = builder.requires(Capabilities.MANAGEMENT_EXECUTOR);
builder.setInstance(new ApplicationClientDeploymentService(consumer, file, mcfSupplier, executorSupplier));
builder.install();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
*/
public class AppClientSubsystemResourceDefinition extends SimpleResourceDefinition {

static final String MCF_CAPABILITY = "org.wildfly.management.model-controller-client-factory";
static final String EXECUTOR_CAPABILITY = "org.wildfly.management.executor";

public static final RuntimeCapability<Void> APPCLIENT_CAPABILITY = RuntimeCapability.Builder.of("org.wildfly.appclient", Void.class)
//.addRequirements(MCF_CAPABILITY, EXECUTOR_CAPABILITY) TODO determine why this breaks domain mode provisioning
//.addRequirements(ModelControllerClientFactory.SERVICE_DESCRIPTOR, Capabilities.MANAGEMENT_EXECUTOR) TODO determine why this breaks domain mode provisioning
.build();

public static final SimpleAttributeDefinition FILE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,4 @@ public class Capabilities {
* The capability name for the kernel SuspendController
*/
public static final String SUSPEND_CONTROLLER_CAPABILITY = "org.wildfly.server.suspend-controller";

/**
* The capability name for the kernel ProcessStateNotifier.
*/
public static final String PROCESS_STATE_NOTIFIER_CAPABILITY = "org.wildfly.management.process-state-notifier";
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.jberet.spi.JobExecutor;
import org.jberet.spi.JobOperatorContext;
import org.jboss.as.controller.ProcessStateNotifier;
import org.jboss.as.controller.RequirementServiceBuilder;
import org.jboss.as.controller.RequirementServiceTarget;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.ee.component.EEModuleDescription;
import org.jboss.as.ee.structure.DeploymentType;
Expand All @@ -38,7 +40,6 @@
import org.jboss.modules.Module;
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.extension.batch.jberet.BatchConfiguration;
import org.wildfly.extension.batch.jberet.BatchServiceNames;
import org.wildfly.extension.batch.jberet._private.BatchLogger;
Expand Down Expand Up @@ -79,7 +80,7 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
final ClassLoader moduleClassLoader = module.getClassLoader();

final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
final RequirementServiceTarget serviceTarget = phaseContext.getRequirementServiceTarget();

// Check for a deployment descriptor
BatchEnvironmentMetaData metaData = deploymentUnit.getAttachment(BatchAttachments.BATCH_ENVIRONMENT_META_DATA);
Expand Down Expand Up @@ -160,12 +161,12 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU

// Install the JobOperatorService
final ServiceName jobOperatorServiceName = BatchServiceNames.jobOperatorServiceName(deploymentUnit);
final ServiceBuilder<?> jobOperatorServiceSB = serviceTarget.addService(jobOperatorServiceName);
final RequirementServiceBuilder<?> jobOperatorServiceSB = serviceTarget.addService();
final Consumer<JobOperator> jobOperatorConsumer = jobOperatorServiceSB.provides(jobOperatorServiceName);
final Supplier<ExecutorService> executorSupplier = Services.requireServerExecutor(jobOperatorServiceSB);
final Supplier<BatchConfiguration> batchConfigSupplier = jobOperatorServiceSB.requires(support.getCapabilityServiceName(Capabilities.BATCH_CONFIGURATION_CAPABILITY.getName()));
final Supplier<SuspendController> suspendControllerSupplier = jobOperatorServiceSB.requires(support.getCapabilityServiceName(Capabilities.SUSPEND_CONTROLLER_CAPABILITY));
final Supplier<ProcessStateNotifier> processStateSupplier = jobOperatorServiceSB.requires(support.getCapabilityServiceName(Capabilities.PROCESS_STATE_NOTIFIER_CAPABILITY));
final Supplier<ProcessStateNotifier> processStateSupplier = jobOperatorServiceSB.requires(ProcessStateNotifier.SERVICE_DESCRIPTOR);
final Supplier<SecurityAwareBatchEnvironment> batchEnvironmentSupplier = jobOperatorServiceSB.requires(BatchServiceNames.batchEnvironmentServiceName(deploymentUnit));
final JobOperatorService jobOperatorService = new JobOperatorService(jobOperatorConsumer, batchConfigSupplier, batchEnvironmentSupplier, executorSupplier, suspendControllerSupplier, processStateSupplier, restartJobsOnResume, deploymentName, jobXmlResolver);
jobOperatorServiceSB.setInstance(jobOperatorService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jboss.as.naming.service.NamingService;
import org.jboss.as.network.SocketBindingManager;
import org.wildfly.clustering.service.Requirement;
import org.wildfly.service.descriptor.NullaryServiceDescriptor;

/**
* Enumerates common requirements for clustering resources.
Expand All @@ -22,13 +23,17 @@ public enum CommonRequirement implements Requirement, ServiceNameFactoryProvider
LOCAL_TRANSACTION_PROVIDER("org.wildfly.transactions.global-default-local-provider", Void.class),
MBEAN_SERVER("org.wildfly.management.jmx", MBeanServer.class),
NAMING_STORE(NamingService.CAPABILITY_NAME, NamingStore.class),
PATH_MANAGER("org.wildfly.management.path-manager", PathManager.class),
SOCKET_BINDING_MANAGER("org.wildfly.management.socket-binding-manager", SocketBindingManager.class),
PATH_MANAGER(PathManager.SERVICE_DESCRIPTOR),
SOCKET_BINDING_MANAGER(SocketBindingManager.SERVICE_DESCRIPTOR),
;
private final String name;
private final Class<?> type;
private final ServiceNameFactory factory = new RequirementServiceNameFactory(this);

CommonRequirement(NullaryServiceDescriptor<?> descriptor) {
this(descriptor.getName(), descriptor.getType());
}

CommonRequirement(String name, Class<?> type) {
this.name = name;
this.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import javax.net.ssl.SSLContext;
import javax.sql.DataSource;

import org.jboss.as.controller.services.path.PathManager;
import org.jboss.as.network.OutboundSocketBinding;
import org.jboss.as.network.SocketBinding;
import org.wildfly.clustering.service.UnaryRequirement;
import org.wildfly.security.credential.store.CredentialStore;
import org.wildfly.service.descriptor.UnaryServiceDescriptor;

/**
* Enumerates common unary requirements for clustering resources
Expand All @@ -23,15 +25,19 @@ public enum CommonUnaryRequirement implements UnaryRequirement, UnaryServiceName
CREDENTIAL_STORE("org.wildfly.security.credential-store", CredentialStore.class),
DATA_SOURCE("org.wildfly.data-source", DataSource.class),
KEY_STORE("org.wildfly.security.key-store", KeyStore.class),
OUTBOUND_SOCKET_BINDING("org.wildfly.network.outbound-socket-binding", OutboundSocketBinding.class),
PATH("org.wildfly.management.path", String.class),
SOCKET_BINDING("org.wildfly.network.socket-binding", SocketBinding.class),
OUTBOUND_SOCKET_BINDING(OutboundSocketBinding.SERVICE_DESCRIPTOR),
PATH(PathManager.PATH_SERVICE_DESCRIPTOR),
SOCKET_BINDING(SocketBinding.SERVICE_DESCRIPTOR),
SSL_CONTEXT("org.wildfly.security.ssl-context", SSLContext.class),
;
private final String name;
private final Class<?> type;
private final UnaryServiceNameFactory factory = new UnaryRequirementServiceNameFactory(this);

CommonUnaryRequirement(UnaryServiceDescriptor<?> descriptor) {
this(descriptor.getName(), descriptor.getType());
}

CommonUnaryRequirement(String name, Class<?> type) {
this.name = name;
this.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
<module name="org.wildfly.clustering.service"/>
<module name="org.wildfly.common"/>
<module name="org.wildfly.security.elytron-private"/>
<module name="org.wildfly.service"/>
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<module name="org.jboss.metadata.ear"/>
<module name="org.jboss.vfs"/>
<module name="org.wildfly.common"/>
<module name="org.wildfly.service"/>
<module name="org.wildfly.transaction.client" optional="true" />
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</resources>

<dependencies>
<module name="java.xml"/>
<module name="jakarta.mail.api" />
<module name="org.eclipse.angus.mail">
<imports>
Expand All @@ -35,6 +36,6 @@
<module name="org.jboss.logging"/>
<module name="org.wildfly.common"/>
<module name="org.wildfly.security.elytron-private"/>
<module name="java.xml"/>
<module name="org.wildfly.service"/>
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
<module name="org.jboss.msc"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.vfs"/>
<module name="org.wildfly.service"/>
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.glassfish.enterprise.concurrent.AbstractManagedExecutorService;
import org.glassfish.enterprise.concurrent.ManagedExecutorServiceAdapter;
import org.jboss.as.controller.ProcessStateNotifier;
import org.jboss.as.controller.RequirementServiceBuilder;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.ee.concurrent.ContextServiceImpl;
import org.jboss.as.ee.concurrent.deployers.EEConcurrentDefaultBindingProcessor;
Expand Down Expand Up @@ -42,7 +43,6 @@ public class ManagedExecutorDefinitionInjectionSource extends ResourceDefinition
public static final String HUNG_TASK_THRESHOLD_PROP = "hungTaskThreshold";
public static final String MAX_ASYNC_PROP = "maxAsync";

private static final String PROCESS_STATE_NOTIFIER_CAPABILITY_NAME = "org.wildfly.management.process-state-notifier";
private static final String REQUEST_CONTROLLER_CAPABILITY_NAME = "org.wildfly.request-controller";

private String contextServiceRef;
Expand All @@ -69,10 +69,10 @@ public void getResourceValue(final ResolutionContext context, final ServiceBuild
try {
// install the resource service
final ServiceName resourceServiceName = ManagedExecutorServiceResourceDefinition.CAPABILITY.getCapabilityServiceName(resourceName);
final ServiceBuilder resourceServiceBuilder = phaseContext.getServiceTarget().addService(resourceServiceName);
final RequirementServiceBuilder<?> resourceServiceBuilder = phaseContext.getRequirementServiceTarget().addService();
final Consumer<ManagedExecutorServiceAdapter> consumer = resourceServiceBuilder.provides(resourceServiceName);
final Supplier<ManagedExecutorHungTasksPeriodicTerminationService> hungTasksPeriodicTerminationService = resourceServiceBuilder.requires(ConcurrentServiceNames.HUNG_TASK_PERIODIC_TERMINATION_SERVICE_NAME);
final Supplier<ProcessStateNotifier> processStateNotifierSupplier = resourceServiceBuilder.requires(capabilityServiceSupport.getCapabilityServiceName(PROCESS_STATE_NOTIFIER_CAPABILITY_NAME));
final Supplier<ProcessStateNotifier> processStateNotifierSupplier = resourceServiceBuilder.requires(ProcessStateNotifier.SERVICE_DESCRIPTOR);
Supplier<RequestController> requestControllerSupplier = null;
if (capabilityServiceSupport.hasCapability(REQUEST_CONTROLLER_CAPABILITY_NAME)) {
requestControllerSupplier = resourceServiceBuilder.requires(capabilityServiceSupport.getCapabilityServiceName(REQUEST_CONTROLLER_CAPABILITY_NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.glassfish.enterprise.concurrent.AbstractManagedExecutorService;
import org.glassfish.enterprise.concurrent.ManagedScheduledExecutorServiceAdapter;
import org.jboss.as.controller.ProcessStateNotifier;
import org.jboss.as.controller.RequirementServiceBuilder;
import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.ee.concurrent.ContextServiceImpl;
import org.jboss.as.ee.concurrent.deployers.EEConcurrentDefaultBindingProcessor;
Expand Down Expand Up @@ -42,7 +43,6 @@ public class ManagedScheduledExecutorDefinitionInjectionSource extends ResourceD
public static final String HUNG_TASK_THRESHOLD_PROP = "hungTaskThreshold";
public static final String MAX_ASYNC_PROP = "maxAsync";

private static final String PROCESS_STATE_NOTIFIER_CAPABILITY_NAME = "org.wildfly.management.process-state-notifier";
private static final String REQUEST_CONTROLLER_CAPABILITY_NAME = "org.wildfly.request-controller";

private String contextServiceRef;
Expand All @@ -68,10 +68,10 @@ public void getResourceValue(final ResolutionContext context, final ServiceBuild
try {
// install the resource service
final ServiceName resourceServiceName = ManagedScheduledExecutorServiceResourceDefinition.CAPABILITY.getCapabilityServiceName(resourceName);
final ServiceBuilder resourceServiceBuilder = phaseContext.getServiceTarget().addService(resourceServiceName);
final RequirementServiceBuilder<?> resourceServiceBuilder = phaseContext.getRequirementServiceTarget().addService();
final Consumer<ManagedScheduledExecutorServiceAdapter> consumer = resourceServiceBuilder.provides(resourceServiceName);
final Supplier<ManagedExecutorHungTasksPeriodicTerminationService> hungTasksPeriodicTerminationService = resourceServiceBuilder.requires(ConcurrentServiceNames.HUNG_TASK_PERIODIC_TERMINATION_SERVICE_NAME);
final Supplier<ProcessStateNotifier> processStateNotifierSupplier = resourceServiceBuilder.requires(capabilityServiceSupport.getCapabilityServiceName(PROCESS_STATE_NOTIFIER_CAPABILITY_NAME));
final Supplier<ProcessStateNotifier> processStateNotifierSupplier = resourceServiceBuilder.requires(ProcessStateNotifier.SERVICE_DESCRIPTOR);
Supplier<RequestController> requestControllerSupplier = null;
if (capabilityServiceSupport.hasCapability(REQUEST_CONTROLLER_CAPABILITY_NAME)) {
requestControllerSupplier = resourceServiceBuilder.requires(capabilityServiceSupport.getCapabilityServiceName(REQUEST_CONTROLLER_CAPABILITY_NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.jboss.as.ee.subsystem;

import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.services.path.PathManager;

/**
* The capabilities provided by and required by this subsystem.
Expand All @@ -15,13 +16,11 @@
public final class EeCapabilities {
private static final String CAPABILITY_BASE = "org.wildfly.ee.";

static final String PATH_MANAGER_CAPABILITY = "org.wildfly.management.path-manager";

public static final String EE_GLOBAL_DIRECTORY_CAPABILITY_NAME = CAPABILITY_BASE + "global-directory";

public static final RuntimeCapability<Void> EE_GLOBAL_DIRECTORY_CAPABILITY = RuntimeCapability
.Builder.of(EE_GLOBAL_DIRECTORY_CAPABILITY_NAME, true, GlobalDirectoryService.class)
.addRequirements(PATH_MANAGER_CAPABILITY)
.addRequirements(PathManager.SERVICE_DESCRIPTOR)
.build();

public static final String ELYTRON_JACC_CAPABILITY = "org.wildfly.security.jacc-policy";
Expand Down
Loading

0 comments on commit 5e7a24f

Please sign in to comment.