public void deploy(final DeploymentPhaseContext phaseContext)
      throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final List<ResourceRoot> childRoots = deploymentUnit.getAttachment(Attachments.RESOURCE_ROOTS);

    if (childRoots != null) {
      final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
      for (final ResourceRoot childRoot : childRoots) {
        if (!SubDeploymentMarker.isSubDeployment(childRoot)) {
          continue;
        }
        final SubDeploymentUnitService service =
            new SubDeploymentUnitService(childRoot, deploymentUnit);
        final ServiceName serviceName =
            deploymentUnit.getServiceName().append(childRoot.getRootName());

        serviceTarget
            .addService(serviceName, service)
            .addDependency(
                Services.JBOSS_DEPLOYMENT_CHAINS,
                DeployerChains.class,
                service.getDeployerChainsInjector())
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();
        phaseContext.addDeploymentDependency(serviceName, Attachments.SUB_DEPLOYMENTS);
      }
    }
  }
 private void removeExtraUnits() {
   // delete units
   int i = this.healthyUnits.size() - 1;
   while (this.healthyUnits.size() > this.requestedScale) {
     DeploymentUnit toRemove = this.healthyUnits.get(i);
     toRemove.remove();
     this.healthyUnits.remove(i);
     i--;
   }
 }
Ejemplo n.º 3
0
 public ServiceName getServiceName() {
   if (parent != null) {
     return Services.deploymentUnitName(parent.getName(), name);
   } else {
     return Services.deploymentUnitName(name);
   }
 }
 public void undeploy(DeploymentUnit deploymentUnit) {
   final List<ResourceRoot> childRoots = deploymentUnit.getAttachment(Attachments.RESOURCE_ROOTS);
   if (childRoots != null) {
     final ServiceRegistry serviceRegistry = deploymentUnit.getServiceRegistry();
     for (final ResourceRoot childRoot : childRoots) {
       if (!SubDeploymentMarker.isSubDeployment(childRoot)) {
         continue;
       }
       final ServiceName serviceName =
           deploymentUnit.getServiceName().append(childRoot.getRootName());
       final ServiceController<?> serviceController = serviceRegistry.getService(serviceName);
       if (serviceController != null) {
         serviceController.setMode(ServiceController.Mode.REMOVE);
       }
     }
   }
 }
  protected DeploymentUnit createAndInitializeDeploymentUnit(final ServiceRegistry registry) {
    final DeploymentUnit deploymentUnit = new DeploymentUnitImpl(parent, name, registry);
    deploymentUnit.putAttachment(Attachments.RUNTIME_NAME, name);
    deploymentUnit.putAttachment(Attachments.MANAGEMENT_NAME, managementName);
    deploymentUnit.putAttachment(Attachments.DEPLOYMENT_CONTENTS, contentsInjector.getValue());
    deploymentUnit.putAttachment(DeploymentModelUtils.REGISTRATION_ATTACHMENT, registration);
    deploymentUnit.putAttachment(DeploymentModelUtils.DEPLOYMENT_RESOURCE, resource);
    deploymentUnit.putAttachment(
        Attachments.SERVICE_VERIFICATION_HANDLER, serviceVerificationHandler);

    // Attach the deployment repo
    deploymentUnit.putAttachment(
        Attachments.SERVER_DEPLOYMENT_REPOSITORY, serverDeploymentRepositoryInjector.getValue());

    return deploymentUnit;
  }