Package org.jboss.dependency.spi

Examples of org.jboss.dependency.spi.ControllerStateModel


      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;
               }
            }
         }
      }
View Full Code Here


               toUndeploy.add(deploymentControllerContext);
            }
         }

         // 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.
               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
         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
                  {
                     controller.change(deploymentControllerContext, state);
View Full Code Here

            if (context.getState().equals(context.getRequiredState()))
               i.remove();
         }
         if (notInstalled.isEmpty() == false)
         {
            ControllerStateModel states = controller.getStates();
            contextsInError = new HashMap<String, Throwable>();
            contextsMissingDependencies = new HashMap<String, Set<MissingDependency>>();
            for (ControllerContext context : notInstalled)
            {
               checkControllerContext(context, contextsInError, contextsMissingDependencies, states);
View Full Code Here

            deploymentsMissingDeployer.add(context.getName());

         if (checkContexts)
         {
            Set<ControllerContext> notInstalled = controller.getNotInstalled();
            ControllerStateModel states = controller.getStates();
            checkComplete(context, contextsInError, contextsMissingDependencies, notInstalled, states);
         }
      }

      // reset if not used
View Full Code Here

      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;
               }
            }
         }
      }
View Full Code Here

      List<DeploymentControllerContext> toAdvance = null;

      boolean trace = log.isTraceEnabled();
     
      // Work out what we are going to do
      ControllerStateModel states = controller.getStates();
      for (DeploymentContext context : contexts)
      {
         if (context == null)
            throw new DeploymentException("Null context in " + Arrays.asList(contexts));
         DeploymentControllerContext deploymentControllerContext = context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
         if (deploymentControllerContext == null)
            throw new DeploymentException("Deployment " + context.getName() + " has no deployment controller context");
         ControllerState current = deploymentControllerContext.getState();
         if (ControllerState.ERROR.equals(current))
         {
            // Ignore contexts in error
            if (trace)
               log.trace("Not moving " + deploymentControllerContext + " to state " + requiredState + " it is currently in **ERROR**.");
         }
         else
         {
            // This is beyond the required state
            if (states.isAfterState(current, requiredState))
            {
               if (toRetreat == null)
                  toRetreat = new ArrayList<DeploymentControllerContext>();
               toRetreat.add(deploymentControllerContext);
            }
            // This needs advancing
            else if (states.isBeforeState(current, requiredState))
            {
               if (toAdvance == null)
                  toAdvance = new ArrayList<DeploymentControllerContext>();
               toAdvance.add(deploymentControllerContext);
            }
            // It is already in the required state
            else
            {
               if (trace)
                  log.trace("Not moving " + deploymentControllerContext + " to state " + requiredState + " it is already there.");
            }
         }
         context.setRequiredStage(stage);
      }

      checkShutdown();
     
      // First move those contexts that are beyond the required state
      if (toRetreat != null)
      {
         ListIterator<ControllerState> iter = states.listIteraror();
         while (iter.hasPrevious())
         {
            ControllerState state = iter.previous();
           
            for (DeploymentControllerContext deploymentControllerContext : toRetreat)
            {
               ControllerState current = deploymentControllerContext.getState();
               if (ControllerState.ERROR.equals(current) == false && states.isAfterState(current, state))
                  change(deploymentControllerContext, state);
               else if (trace)
                  log.trace("Not moving " + deploymentControllerContext + " to state " + state + " it is at " + current);
            }
            if (requiredState.equals(state))
               break;
         }
      }
     
      // Now move those contexts that are before the required state
      if (toAdvance != null)
      {
         for (ControllerState state : states)
         {
            for (DeploymentControllerContext deploymentControllerContext : toAdvance)
            {
               ControllerState current = deploymentControllerContext.getState();
               if (ControllerState.ERROR.equals(current) == false && states.isBeforeState(current, state))
               {
                  change(deploymentControllerContext, state, true);
               }
               else if (trace)
                  log.trace("Not moving " + deploymentControllerContext + " to state " + state + " it is at " + current);
View Full Code Here

      Map<DeploymentControllerContext, ControllerState> toBounce = null;

      boolean trace = log.isTraceEnabled();
     
      // Work out what we are going to do
      ControllerStateModel states = controller.getStates();
      for (DeploymentContext context : contexts)
      {
         if (context == null)
            throw new DeploymentException("Null context in " + Arrays.asList(contexts));
         DeploymentControllerContext deploymentControllerContext = context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
         if (deploymentControllerContext == null)
            throw new DeploymentException("Deployment " + context.getName() + " has no deployment controller context");
         ControllerState current = deploymentControllerContext.getState();
         if (ControllerState.ERROR.equals(current))
         {
            // Ignore contexts in error
            if (trace)
               log.trace("Not moving " + deploymentControllerContext + " to state " + bounceState + " it is currently in **ERROR**.");
         }
         else
         {
            // This is beyond the required state
            if (states.isAfterState(current, bounceState))
            {
               if (toBounce == null)
                  toBounce = new LinkedHashMap<DeploymentControllerContext, ControllerState>();
               ControllerState requiredState = ControllerState.getInstance(context.getRequiredStage().getName());
               toBounce.put(deploymentControllerContext, requiredState);
               context.setRequiredStage(stage);
            }
            // Ignore before the required state
            else if (states.isBeforeState(current, bounceState))
            {
               if (trace)
                  log.trace("Not moving " + deploymentControllerContext + " to state " + bounceState + " it has not reached that state.");
            }
            // It is already in the required state
            else
            {
               if (trace)
                  log.trace("Not moving " + deploymentControllerContext + " to state " + bounceState + " it is already there.");
            }
         }
      }

      checkShutdown();
     
      // First move the contexts back to the bounce state
      if (toBounce != null)
      {
         ListIterator<ControllerState> iter = states.listIteraror();
         while (iter.hasPrevious())
         {
            ControllerState state = iter.previous();
           
            for (DeploymentControllerContext deploymentControllerContext : toBounce.keySet())
            {
               ControllerState current = deploymentControllerContext.getState();
               if (ControllerState.ERROR.equals(current) == false && states.isAfterState(current, state))
                  change(deploymentControllerContext, state);
               else if (trace)
                  log.trace("Not moving " + deploymentControllerContext + " to state " + state + " it is at " + current);
            }
            if (bounceState.equals(state))
               break;
         }
         // Now move the contexts back to their original state
         for (ControllerState state : states)
         {
            if (states.isAfterState(state, bounceState))
            {
               for (Entry<DeploymentControllerContext, ControllerState> entry : toBounce.entrySet())
               {
                  DeploymentControllerContext deploymentControllerContext = entry.getKey();
                  ControllerState requiredState = entry.getValue();
                  ControllerState current = deploymentControllerContext.getState();
                  if (ControllerState.ERROR.equals(current) == false && states.isBeforeState(current, requiredState) && states.isBeforeState(current, state))
                  {
                     change(deploymentControllerContext, state, true);
                  }
                  else if (trace)
                     log.trace("Not moving " + deploymentControllerContext + " to state " + state + " it is at " + current);
View Full Code Here

               toUndeploy.add(deploymentControllerContext);
            }
         }

         // 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))
               {
                  change(deploymentControllerContext, state);
               }
               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.debugf("Fully Undeployed %1s", 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.debugf("Deploying %1s", 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) && current.getStateString().equals(context.getRequiredStage().getName()) == false)
               {
                  checkShutdown();
                  change(deploymentControllerContext, state, false);
               }
               else
View Full Code Here

            if (context.getState().equals(context.getRequiredState()))
               i.remove();
         }
         if (notInstalled.isEmpty() == false)
         {
            ControllerStateModel states = controller.getStates();
            contextsInError = new HashMap<String, Throwable>();
            contextsMissingDependencies = new HashMap<String, Set<MissingDependency>>();
            for (ControllerContext context : notInstalled)
            {
               checkControllerContext(context, contextsInError, contextsMissingDependencies, states);
View Full Code Here

            deploymentsMissingDeployer.add(context.getName());

         if (checkContexts)
         {
            Set<ControllerContext> notInstalled = controller.getNotInstalled();
            ControllerStateModel states = controller.getStates();
            checkComplete(context, contextsInError, contextsMissingDependencies, notInstalled, states);
         }
      }

      // reset if not used
View Full Code Here

TOP

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

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.