Package org.jboss.dependency.spi

Examples of org.jboss.dependency.spi.ControllerState


   public DeploymentStage getDeploymentStage(DeploymentContext context) throws DeploymentException
   {
      DeploymentControllerContext deploymentControllerContext = context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
      if (deploymentControllerContext == null)
         return null;
      ControllerState state = deploymentControllerContext.getState();
      if (ControllerState.ERROR.equals(state))
         return DeploymentStages.NOT_INSTALLED;
      return new DeploymentStage(state.getStateString());
   }
View Full Code Here


      if (deploymentControllerContext == null)
         throw new DeploymentException("Deployment " + context.getName() + " has no deployment controller context");

      checkShutdown();
     
      ControllerState state = new ControllerState(stageName);
      try
      {
         controller.change(deploymentControllerContext, state);
      }
      catch (Throwable t)
View Full Code Here

         // Go through the states in reverse order
         List<ControllerState> states = controller.getStates();
         for (int i = states.size()-1; i >= 0; --i)
         {
            ControllerState state = states.get(i);
            for (DeploymentControllerContext deploymentControllerContext : toUndeploy)
            {
               ControllerState current = deploymentControllerContext.getState();
               int currentIdx = states.indexOf(current);
               DeploymentContext context = deploymentControllerContext.getDeploymentContext();
               if (currentIdx != -1 && currentIdx > i)
               {
                  try
                  {
                     controller.change(deploymentControllerContext, state);
                  }
                  catch (Throwable t)
                  {
                     log.warn("Error during undeploy", t);
                     context.setState(DeploymentState.ERROR);
                     context.setProblem(t);
                  }
               }
               else
               {
                  if (trace)
                     log.trace("Not moving " + deploymentControllerContext + " to state " + state + " it is at " + current);
               }
            }
         }

         // Uninstall the contexts
         for (DeploymentControllerContext deploymentControllerContext : toUndeploy)
         {
            DeploymentContext context = deploymentControllerContext.getDeploymentContext();
            context.getTransientAttachments().removeAttachment(ControllerContext.class);
            try
            {
               controller.uninstall(deploymentControllerContext.getName());
               setState(context, DeploymentState.UNDEPLOYED, null);
               // This is now in the abstract classloader deployer.undeploy,
               // but left here in case somebody isn't using that.
               removeClassLoader(context);
               cleanup(context);
               log.debug("Fully Undeployed " + context.getName());
            }
            catch (Throwable t)
            {
               log.warn("Error during uninstall", t);
               context.setState(DeploymentState.ERROR);
               context.setProblem(t);
            }
         }
      }
     
      // There is something to deploy
      if (deploy != null && deploy.isEmpty() == false)
      {
         // Create the controller contexts
         for (DeploymentContext context : deploy)
         {
            checkShutdown();

            DeploymentControllerContext deploymentControllerContext = new DeploymentControllerContext(context, this);
            try
            {
               controller.install(deploymentControllerContext);
               context.setState(DeploymentState.DEPLOYING);
               log.debug("Deploying " + context.getName());
               context.getTransientAttachments().addAttachment(ControllerContext.class, deploymentControllerContext);
               if (scopeBuilder != null)
                  context.getTransientAttachments().addAttachment(ScopeBuilder.class, scopeBuilder);
               if (repository != null)
                  context.getTransientAttachments().addAttachment(MutableMetaDataRepository.class, repository);
            }
            catch (Throwable t)
            {
               // Set the error on the parent
               context.setState(DeploymentState.ERROR);
               context.setProblem(t);
               // Set the children to not deployed
               setState(context, DeploymentState.UNDEPLOYED, DeploymentState.DEPLOYING);
            }
         }

         // Go through the states in order
         List<ControllerState> states = controller.getStates();
         for (int i = 0; i < states.size(); ++i)
         {
            ControllerState state = states.get(i);
            for (DeploymentContext context : deploy)
            {
               DeploymentControllerContext deploymentControllerContext = context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
               ControllerState current = deploymentControllerContext.getState();
               int currentIdx = states.indexOf(current);
               if (currentIdx != -1 && currentIdx < i)
               {
                  checkShutdown();
                  try
View Full Code Here

         for (DependencyItem item : dependsInfo.getIDependOn(null))
         {
            if (item.isResolved() == false)
            {
               String dependency;
               ControllerState actualState = null;
               String actualStateString;
               Object iDependOn = item.getIDependOn();
               if (iDependOn == null)
               {
                  dependency = "<UNKNOWN>";
                  actualStateString = "** UNRESOLVED " + item.toHumanReadableString() + " **";
               }
               else
               {
                  dependency = iDependOn.toString();
                  ControllerContext other = controller.getContext(iDependOn, null);
                  if (other == null)
                     actualStateString = "** NOT FOUND **";
                  else
                  {
                     actualState = other.getState();
                     actualStateString = actualState.getStateString();
                  }
               }
               ControllerState requiredState = item.getWhenRequired();
               String requiredStateString = requiredState.getStateString();
               int required = states.indexOf(requiredState);
               int actual = actualState == null ? -1 : states.indexOf(actualState);
               if (required > actual)
               {
                  MissingDependency missing = new MissingDependency(name, dependency, requiredStateString, actualStateString);
View Full Code Here

    * @param transformer the transformer
    * @return the builder
    */
   public BeanMetaDataBuilder addDemand(Object demand, String whenRequired, String transformer)
   {
      ControllerState whenRequiredState = null;
      if (whenRequired != null)
         whenRequiredState = new ControllerState(whenRequired);
      return addDemand(demand, whenRequiredState, transformer);
   }
View Full Code Here

      // If we're checking for installed
      if (checkInstalled)
      {
         // Get State
         ControllerState state = context.getState();

         // If State is other than INSTALLED
         if (!state.equals(ControllerState.INSTALLED))
         {
            throw new NotBoundException("Object is bound at key " + name
                  + ", but is not fully installed, instead of state: " + state);
         }
View Full Code Here

      // Already done?
      String stageName = stage.getName();
      if (stages.containsKey(stageName))
         return;

      ControllerState preceeds = null;
      String before = stage.getBefore();
      String after = stage.getAfter();
      if (before != null || after != null)
      {
         // Determine where to put the stage
         ControllerStateModel states = controller.getStates();
         for (ControllerState state : states)
         {
            String stateName = state.getStateString();
            if (before != null && before.equals(stateName))
            {
               preceeds = state;
               break;
            }
            if (after != null && after.equals(stateName))
            {
               if (states.getNextState(state) != null)
               {
                  preceeds = states.getNextState(state);
                  break;
               }
            }
         }
      }

      controller.addState(new ControllerState(stageName), preceeds);
      stages.put(stageName, stage);
      log.debug("Added stage " + stageName + " before " + preceeds);
   }
View Full Code Here

   public DeploymentStage getDeploymentStage(DeploymentContext context) throws DeploymentException
   {
      DeploymentControllerContext deploymentControllerContext = context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
      if (deploymentControllerContext == null)
         return null;
      ControllerState state = deploymentControllerContext.getState();
      if (ControllerState.ERROR.equals(state))
         return DeploymentStages.NOT_INSTALLED;
      return new DeploymentStage(state.getStateString());
   }
View Full Code Here

      if (deploymentControllerContext == null)
         throw new DeploymentException("Deployment " + context.getName() + " has no deployment controller context");

      checkShutdown();

      ControllerState state = new ControllerState(stageName);
      try
      {
         controller.change(deploymentControllerContext, state);
      }
      catch (Throwable t)
View Full Code Here

         // Go through the states in reverse order
         ControllerStateModel states = controller.getStates();
         ListIterator<ControllerState> iter = states.listIteraror();
         while (iter.hasPrevious())
         {
            ControllerState state = iter.previous();
            for (DeploymentControllerContext deploymentControllerContext : toUndeploy)
            {
               ControllerState current = deploymentControllerContext.getState();
               if (ControllerState.ERROR.equals(current) == false && states.isAfterState(current, state))
               {
                  DeploymentContext context = deploymentControllerContext.getDeploymentContext();
                  try
                  {
                     controller.change(deploymentControllerContext, state);
                  }
                  catch (Throwable t)
                  {
                     log.warn("Error during undeploy", t);
                     context.setState(DeploymentState.ERROR);
                     context.setProblem(t);
                  }
               }
               else
               {
                  if (trace)
                     log.trace("Not moving " + deploymentControllerContext + " to state " + state + " it is at " + current);
               }
            }
         }

         // Uninstall the contexts
         for (DeploymentControllerContext deploymentControllerContext : toUndeploy)
         {
            DeploymentContext context = deploymentControllerContext.getDeploymentContext();
            context.getTransientAttachments().removeAttachment(ControllerContext.class);
            try
            {
               controller.uninstall(deploymentControllerContext.getName());
               setState(context, DeploymentState.UNDEPLOYED, null);
               // This is now in the abstract classloader deployer.undeploy,
               // but left here in case somebody isn't using that.
               unregisterMBean(context);
               removeClassLoader(context);
               cleanup(context);
               log.debug("Fully Undeployed " + context.getName());
            }
            catch (Throwable t)
            {
               log.warn("Error during uninstall", t);
               context.setState(DeploymentState.ERROR);
               context.setProblem(t);
            }
         }
      }

      // There is something to deploy
      if (deploy != null && deploy.isEmpty() == false)
      {
         // Create the controller contexts
         for (DeploymentContext context : deploy)
         {
            checkShutdown();

            DeploymentControllerContext deploymentControllerContext = new DeploymentControllerContext(context, this);
            context.getTransientAttachments().addAttachment(ControllerContext.class, deploymentControllerContext);
            try
            {
               controller.install(deploymentControllerContext);
               context.setState(DeploymentState.DEPLOYING);
               log.debug("Deploying " + context.getName());
               if (scopeBuilder != null)
                  context.getTransientAttachments().addAttachment(ScopeBuilder.class, scopeBuilder);
               if (repository != null)
                  context.getTransientAttachments().addAttachment(MutableMetaDataRepository.class, repository);
               registerMBean(context);
            }
            catch (Throwable t)
            {
               // Set the error on the parent
               context.setState(DeploymentState.ERROR);
               context.setProblem(t);
               // Set the children to not deployed
               setState(context, DeploymentState.UNDEPLOYED, DeploymentState.DEPLOYING);
               unregisterMBean(context);
            }
         }

         // Go through the states in order
         ControllerStateModel states = controller.getStates();
         for (ControllerState state : states)
         {
            for (DeploymentContext context : deploy)
            {
               DeploymentControllerContext deploymentControllerContext = context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
               ControllerState current = deploymentControllerContext.getState();
               if (ControllerState.ERROR.equals(current) == false && states.isBeforeState(current, state))
               {
                  checkShutdown();
                  try
                  {
View Full Code Here

TOP

Related Classes of org.jboss.dependency.spi.ControllerState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.