forked from wildfly/wildfly-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request wildfly#5588 from pferraro/WFCORE-6400
WFCORE-6400 Update DeploymentPhaseContext to return a ServiceTarget capable of resolving capability requirements.
- Loading branch information
Showing
8 changed files
with
213 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,25 +19,22 @@ | |
package org.jboss.as.controller; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
import org.jboss.as.controller.capability.RuntimeCapability; | ||
import org.jboss.msc.Service; | ||
import org.jboss.msc.service.LifecycleListener; | ||
import org.jboss.msc.service.ServiceBuilder; | ||
import org.jboss.msc.service.ServiceController; | ||
import org.jboss.msc.service.ServiceName; | ||
|
||
/** | ||
* A builder for an individual service in a {@code CapabilityServiceTarget}. | ||
* Create an instance via the {@link CapabilityServiceTarget#addCapability(RuntimeCapability)}. | ||
* Builder also adds support to define capability requirement via {@link #requiresCapability(String, Class, String...)}. | ||
* Create an instance via the {@link CapabilityServiceTarget#addService()} method. | ||
* | ||
* @param <T> the service type | ||
* @author Tomaz Cerar (c) 2017 Red Hat Inc. | ||
* @author <a href="mailto:[email protected]">Richard Opalka</a> | ||
*/ | ||
public interface CapabilityServiceBuilder<T> extends ServiceBuilder<T> { | ||
public interface CapabilityServiceBuilder<T> extends RequirementServiceBuilder<T> { | ||
|
||
@Override | ||
CapabilityServiceBuilder<T> setInitialMode(ServiceController.Mode mode); | ||
|
@@ -86,15 +83,4 @@ public interface CapabilityServiceBuilder<T> extends ServiceBuilder<T> { | |
* @return consumer providing value | ||
*/ | ||
<V> Consumer<V> provides(final RuntimeCapability<?>[] capabilities, final ServiceName[] aliases); | ||
|
||
/** | ||
* Capability requirement. | ||
* | ||
* @param capabilityName name of capability requirement | ||
* @param dependencyType the class of the value of the dependency | ||
* @param <V> the type of the value of the dependency | ||
* @param referenceNames dynamic part(s) of capability name, only useful when using dynamic named capabilities | ||
* @return readonly dependency reference | ||
*/ | ||
<V> Supplier<V> requiresCapability(String capabilityName, Class<V> dependencyType, String... referenceNames); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
|
||
import org.jboss.as.controller.capability.RuntimeCapability; | ||
import org.jboss.msc.service.LifecycleListener; | ||
import org.jboss.msc.service.ServiceTarget; | ||
import org.jboss.msc.service.ServiceName; | ||
|
||
/** | ||
* The target of ServiceBuilder for capability installations. | ||
|
@@ -32,10 +32,10 @@ | |
* @author <a href="mailto:[email protected]">Richard Opalka</a> | ||
* @author Paul Ferraro | ||
*/ | ||
public interface CapabilityServiceTarget extends ServiceTarget { | ||
public interface CapabilityServiceTarget extends RequirementServiceTarget { | ||
|
||
/** | ||
* Gets a builder which can be used to add a capability service into this capability target. | ||
* Returns a builder for installing a service that provides a capability. | ||
* | ||
* @param capability the capability to be installed | ||
* @return new capability builder instance | ||
|
@@ -48,9 +48,16 @@ public interface CapabilityServiceTarget extends ServiceTarget { | |
@Override | ||
CapabilityServiceBuilder<?> addService(); | ||
|
||
@Deprecated | ||
@Override | ||
CapabilityServiceBuilder<?> addService(ServiceName name); | ||
|
||
@Override | ||
CapabilityServiceTarget addListener(LifecycleListener listener); | ||
|
||
@Override | ||
CapabilityServiceTarget removeListener(LifecycleListener listener); | ||
|
||
@Override | ||
CapabilityServiceTarget subTarget(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
controller/src/main/java/org/jboss/as/controller/RequirementServiceBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2023 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.jboss.as.controller; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import org.jboss.msc.Service; | ||
import org.jboss.msc.service.LifecycleListener; | ||
import org.jboss.msc.service.ServiceBuilder; | ||
import org.jboss.msc.service.ServiceController; | ||
|
||
/** | ||
* A {@link org.jboss.msc.service.ServiceBuilder} that supports capability requirements. | ||
* @param <T> an ignored service value type | ||
* @author Paul Ferraro | ||
*/ | ||
public interface RequirementServiceBuilder<T> extends ServiceBuilder<T> { | ||
|
||
@Override | ||
RequirementServiceBuilder<T> setInitialMode(ServiceController.Mode mode); | ||
|
||
@Override | ||
RequirementServiceBuilder<T> setInstance(Service service); | ||
|
||
@Override | ||
RequirementServiceBuilder<T> addListener(LifecycleListener listener); | ||
|
||
/** | ||
* Registers a requirement on the specified capability. | ||
* @param capabilityName name of capability requirement | ||
* @param dependencyType the class of the value of the dependency | ||
* @param referenceNames dynamic part(s) of capability name, only useful when using dynamic named capabilities | ||
* @param <V> the type of the value of the dependency | ||
* @return a reference to the required dependency | ||
*/ | ||
<V> Supplier<V> requiresCapability(String capabilityName, Class<V> dependencyType, String... referenceNames); | ||
} |
39 changes: 39 additions & 0 deletions
39
controller/src/main/java/org/jboss/as/controller/RequirementServiceTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2023 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.jboss.as.controller; | ||
|
||
import org.jboss.msc.service.LifecycleListener; | ||
import org.jboss.msc.service.ServiceTarget; | ||
|
||
/** | ||
* {@link org.jboss.msc.service.ServiceTarget} whose builders support capability requirements. | ||
* @author Paul Ferraro | ||
*/ | ||
public interface RequirementServiceTarget extends ServiceTarget { | ||
|
||
@Override | ||
RequirementServiceBuilder<?> addService(); | ||
|
||
@Override | ||
RequirementServiceTarget addListener(LifecycleListener listener); | ||
|
||
@Override | ||
RequirementServiceTarget removeListener(LifecycleListener listener); | ||
|
||
@Override | ||
RequirementServiceTarget subTarget(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,46 +24,51 @@ | |
|
||
import java.util.List; | ||
|
||
import org.jboss.as.controller.RequirementServiceTarget; | ||
import org.jboss.msc.service.ServiceBuilder; | ||
import org.jboss.msc.service.ServiceName; | ||
import org.jboss.msc.service.ServiceRegistry; | ||
import org.jboss.msc.service.ServiceTarget; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">David M. Lloyd</a> | ||
* @author <a href="mailto:[email protected]">Richard Opalka</a> | ||
*/ | ||
final class DeploymentPhaseContextImpl extends SimpleAttachable implements DeploymentPhaseContext { | ||
private final ServiceTarget serviceTarget; | ||
private final RequirementServiceTarget serviceTarget; | ||
private final ServiceRegistry serviceRegistry; | ||
private final List<DeploymentUnitPhaseDependency> dependencies; | ||
private final DeploymentUnit deploymentUnitContext; | ||
private final Phase phase; | ||
|
||
DeploymentPhaseContextImpl(final ServiceTarget serviceTarget, final ServiceRegistry serviceRegistry, final List<DeploymentUnitPhaseDependency> dependencies, final DeploymentUnit deploymentUnitContext, final Phase phase) { | ||
DeploymentPhaseContextImpl(final RequirementServiceTarget serviceTarget, final ServiceRegistry serviceRegistry, final List<DeploymentUnitPhaseDependency> dependencies, final DeploymentUnit deploymentUnitContext, final Phase phase) { | ||
this.serviceTarget = serviceTarget; | ||
this.serviceRegistry = serviceRegistry; | ||
this.dependencies = dependencies; | ||
this.deploymentUnitContext = deploymentUnitContext; | ||
this.phase = phase; | ||
} | ||
|
||
@Override | ||
public ServiceName getPhaseServiceName() { | ||
return deploymentUnitContext.getServiceName().append(phase.name()); | ||
} | ||
|
||
public ServiceTarget getServiceTarget() { | ||
@Override | ||
public RequirementServiceTarget getRequirementServiceTarget() { | ||
return serviceTarget; | ||
} | ||
|
||
@Override | ||
public ServiceRegistry getServiceRegistry() { | ||
return serviceRegistry; | ||
} | ||
|
||
@Override | ||
public DeploymentUnit getDeploymentUnit() { | ||
return deploymentUnitContext; | ||
} | ||
|
||
@Override | ||
public Phase getPhase() { | ||
return phase; | ||
} | ||
|
Oops, something went wrong.