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#5225 from ropalka/WFCORE-6066
[WFCORE-6066] Rewriting DeploymentUnitServices to use MSC values API
- Loading branch information
Showing
5 changed files
with
48 additions
and
40 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
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 |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
package org.jboss.as.server.deployment; | ||
|
||
import java.lang.ref.WeakReference; | ||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
import org.jboss.as.controller.capability.CapabilityServiceSupport; | ||
import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration; | ||
|
@@ -31,20 +33,19 @@ | |
import org.jboss.as.controller.services.path.PathManager; | ||
import org.jboss.as.server.deployment.annotation.AnnotationIndexSupport; | ||
import org.jboss.as.server.deploymentoverlay.DeploymentOverlayIndex; | ||
import org.jboss.msc.inject.Injector; | ||
import org.jboss.msc.service.ServiceRegistry; | ||
import org.jboss.msc.value.InjectedValue; | ||
import org.jboss.vfs.VirtualFile; | ||
|
||
/** | ||
* The top-level service corresponding to a deployment unit. | ||
* | ||
* @author <a href="mailto:[email protected]">David M. Lloyd</a> | ||
* @author <a href="mailto:[email protected]">Richard Opalka</a> | ||
*/ | ||
final class RootDeploymentUnitService extends AbstractDeploymentUnitService { | ||
private final InjectedValue<DeploymentMountProvider> serverDeploymentRepositoryInjector = new InjectedValue<DeploymentMountProvider>(); | ||
private final InjectedValue<PathManager> pathManagerInjector = new InjectedValue<PathManager>(); | ||
private final InjectedValue<VirtualFile> contentsInjector = new InjectedValue<VirtualFile>(); | ||
private final Supplier<DeploymentMountProvider> serverDeploymentRepositorySupplier; | ||
private final Supplier<PathManager> pathManagerSupplier; | ||
private final Supplier<VirtualFile> contentsSupplier; | ||
private final String name; | ||
private final String managementName; | ||
private final DeploymentUnit parent; | ||
|
@@ -65,14 +66,21 @@ final class RootDeploymentUnitService extends AbstractDeploymentUnitService { | |
* @param annotationIndexSupport operation-scoped cache of static module annotation indexes | ||
* @param exploded the deployment has been exploded | ||
*/ | ||
public RootDeploymentUnitService(final String name, final String managementName, final DeploymentUnit parent, | ||
public RootDeploymentUnitService(final Consumer<DeploymentUnit> deploymentUnitConsumer, | ||
final Supplier<DeploymentMountProvider> serverDeploymentRepositorySupplier, | ||
final Supplier<PathManager> pathManagerSupplier, | ||
final Supplier<VirtualFile> contentsSupplier, | ||
final String name, final String managementName, final DeploymentUnit parent, | ||
final ImmutableManagementResourceRegistration registration, final ManagementResourceRegistration mutableRegistration, | ||
final Resource resource, final CapabilityServiceSupport capabilityServiceSupport, | ||
final DeploymentOverlayIndex deploymentOverlays, | ||
final AnnotationIndexSupport annotationIndexSupport, | ||
final boolean exploded) { | ||
super(registration, mutableRegistration, resource, capabilityServiceSupport); | ||
super(deploymentUnitConsumer, registration, mutableRegistration, resource, capabilityServiceSupport); | ||
assert name != null : "name is null"; | ||
this.serverDeploymentRepositorySupplier = serverDeploymentRepositorySupplier; | ||
this.pathManagerSupplier = pathManagerSupplier; | ||
this.contentsSupplier = contentsSupplier; | ||
this.name = name; | ||
this.managementName = managementName; | ||
this.parent = parent; | ||
|
@@ -88,34 +96,22 @@ public RootDeploymentUnitService(final String name, final String managementName, | |
protected DeploymentUnit createAndInitializeDeploymentUnit(final ServiceRegistry registry) { | ||
final DeploymentUnit deploymentUnit = new DeploymentUnitImpl(parent, name, registry); | ||
deploymentUnit.putAttachment(Attachments.MANAGEMENT_NAME, managementName); | ||
deploymentUnit.putAttachment(Attachments.DEPLOYMENT_CONTENTS, contentsInjector.getValue()); | ||
deploymentUnit.putAttachment(Attachments.DEPLOYMENT_CONTENTS, contentsSupplier.get()); | ||
deploymentUnit.putAttachment(DeploymentResourceSupport.REGISTRATION_ATTACHMENT, registration); | ||
deploymentUnit.putAttachment(DeploymentResourceSupport.MUTABLE_REGISTRATION_ATTACHMENT, mutableRegistration); | ||
deploymentUnit.putAttachment(DeploymentResourceSupport.DEPLOYMENT_RESOURCE, resource); | ||
deploymentUnit.putAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT, new DeploymentResourceSupport(deploymentUnit)); | ||
deploymentUnit.putAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT, capabilityServiceSupport); | ||
deploymentUnit.putAttachment(Attachments.DEPLOYMENT_OVERLAY_INDEX, deploymentOverlays); | ||
deploymentUnit.putAttachment(Attachments.PATH_MANAGER, pathManagerInjector.getValue()); | ||
deploymentUnit.putAttachment(Attachments.PATH_MANAGER, pathManagerSupplier.get()); | ||
deploymentUnit.putAttachment(Attachments.ANNOTATION_INDEX_SUPPORT, annotationIndexSupport); | ||
if(this.isExplodedContent) { | ||
MountExplodedMarker.setMountExploded(deploymentUnit); | ||
} | ||
|
||
// Attach the deployment repo | ||
deploymentUnit.putAttachment(Attachments.SERVER_DEPLOYMENT_REPOSITORY, serverDeploymentRepositoryInjector.getValue()); | ||
deploymentUnit.putAttachment(Attachments.SERVER_DEPLOYMENT_REPOSITORY, serverDeploymentRepositorySupplier.get()); | ||
|
||
return deploymentUnit; | ||
} | ||
|
||
Injector<DeploymentMountProvider> getServerDeploymentRepositoryInjector() { | ||
return serverDeploymentRepositoryInjector; | ||
} | ||
|
||
InjectedValue<PathManager> getPathManagerInjector() { | ||
return pathManagerInjector; | ||
} | ||
|
||
InjectedValue<VirtualFile> getContentsInjector() { | ||
return contentsInjector; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -23,13 +23,15 @@ | |
package org.jboss.as.server.deployment; | ||
|
||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
import org.jboss.as.controller.capability.CapabilityServiceSupport; | ||
import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration; | ||
import org.jboss.as.controller.registry.ManagementResourceRegistration; | ||
import org.jboss.as.controller.registry.Resource; | ||
import org.jboss.as.controller.services.path.PathManager; | ||
import org.jboss.as.server.deployment.module.ResourceRoot; | ||
import org.jboss.msc.service.ServiceBuilder; | ||
import org.jboss.msc.service.ServiceController; | ||
import org.jboss.msc.service.ServiceName; | ||
import org.jboss.msc.service.ServiceRegistry; | ||
|
@@ -39,6 +41,7 @@ | |
* Deployment processor responsible to creating deployment unit services for sub-deployment. | ||
* | ||
* @author John Bailey | ||
* @author <a href="mailto:[email protected]">Richard Opalka</a> | ||
*/ | ||
public class SubDeploymentProcessor implements DeploymentUnitProcessor { | ||
|
||
|
@@ -64,14 +67,12 @@ public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentU | |
final ManagementResourceRegistration mutableRegistration = deploymentUnit.getAttachment(DeploymentResourceSupport.MUTABLE_REGISTRATION_ATTACHMENT); | ||
final CapabilityServiceSupport capabilityServiceSupport = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT); | ||
final PathManager pathManager = deploymentUnit.getAttachment(Attachments.PATH_MANAGER); | ||
final SubDeploymentUnitService service = new SubDeploymentUnitService(childRoot, deploymentUnit, registration, | ||
mutableRegistration, resource, capabilityServiceSupport, pathManager); | ||
|
||
final ServiceName serviceName = Services.deploymentUnitName(deploymentUnit.getName(), childRoot.getRootName()); | ||
|
||
serviceTarget.addService(serviceName, service) | ||
.setInitialMode(ServiceController.Mode.ACTIVE) | ||
.install(); | ||
final ServiceBuilder<?> sb = serviceTarget.addService(serviceName); | ||
final Consumer<DeploymentUnit> deploymentUnitConsumer = sb.provides(serviceName); | ||
final SubDeploymentUnitService service = new SubDeploymentUnitService(deploymentUnitConsumer, childRoot, deploymentUnit, registration, mutableRegistration, resource, capabilityServiceSupport, pathManager); | ||
sb.setInstance(service); | ||
sb.install(); | ||
phaseContext.addDeploymentDependency(serviceName, Attachments.SUB_DEPLOYMENTS); | ||
//we also need a dep on the first phase of the sub deployments | ||
phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, serviceName.append(ServiceName.of(Phase.STRUCTURE.name()))); | ||
|
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 |
---|---|---|
|
@@ -32,18 +32,21 @@ | |
import org.jboss.as.server.logging.ServerLogger; | ||
import org.jboss.msc.service.ServiceRegistry; | ||
|
||
import java.util.function.Consumer; | ||
|
||
/** | ||
* Service responsible for installing the correct services to install a {@link DeploymentUnit}. | ||
* | ||
* @author John Bailey | ||
* @author <a href="mailto:[email protected]">Richard Opalka</a> | ||
*/ | ||
final class SubDeploymentUnitService extends AbstractDeploymentUnitService { | ||
private final ResourceRoot deploymentRoot; | ||
private final DeploymentUnit parent; | ||
private final PathManager pathManager; | ||
|
||
public SubDeploymentUnitService(ResourceRoot deploymentRoot, DeploymentUnit parent, ImmutableManagementResourceRegistration registration, final ManagementResourceRegistration mutableRegistration, Resource resource, CapabilityServiceSupport capabilityServiceSupport, PathManager pathManager) { | ||
super(registration, mutableRegistration, resource, capabilityServiceSupport); | ||
public SubDeploymentUnitService(final Consumer<DeploymentUnit> deploymentUnitConsumer, ResourceRoot deploymentRoot, DeploymentUnit parent, ImmutableManagementResourceRegistration registration, final ManagementResourceRegistration mutableRegistration, Resource resource, CapabilityServiceSupport capabilityServiceSupport, PathManager pathManager) { | ||
super(deploymentUnitConsumer, registration, mutableRegistration, resource, capabilityServiceSupport); | ||
this.pathManager = pathManager; | ||
if (deploymentRoot == null) throw ServerLogger.ROOT_LOGGER.deploymentRootRequired(); | ||
this.deploymentRoot = deploymentRoot; | ||
|