Package org.jboss.dependency.spi

Examples of org.jboss.dependency.spi.ControllerState


      // 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

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

      checkShutdown();

      context.setRequiredStage(stage);
      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) && current.getStateString().equals(context.getRequiredStage().getName()) == false)
               {
                  checkShutdown();
                  try
                  {
                     controller.change(deploymentControllerContext, state);
View Full Code Here

         Object contextName = context.getName();
         String name = contextName.toString();
         Set<MissingDependency> dependencies = new HashSet<MissingDependency>();

         DependencyInfo dependsInfo = context.getDependencyInfo();
         ControllerState currentState = context.getState();
         ControllerState nextState = states.getNextState(currentState);

         for (DependencyItem item : dependsInfo.getUnresolvedDependencies(nextState))
         {
            if (item.isResolved() == false)
            {
               ControllerState actualState = null;
               String actualStateString;

               Object iDependOn = item.getIDependOn();
               if (contextName.equals(iDependOn) == false && item.resolve(controller) == false)
               {
                  // some items might only set iDependOn later on
                  iDependOn = item.getIDependOn();

                  String dependency;
                  ControllerContext other = null;
                  if (iDependOn == null)
                  {
                     dependency = "<UNKNOWN " + item.getName() + ">";
                     actualStateString = "** UNRESOLVED " + item.toHumanReadableString() + " **";
                  }
                  else
                  {
                     dependency = iDependOn.toString();
                     other = controller.getContext(iDependOn, null);
                     if (other == null)
                        actualStateString = "** NOT FOUND " + item.toHumanReadableString() + " **";
                     else
                     {
                        actualState = other.getState();
                        actualStateString = actualState.getStateString();
                     }
                  }

                  ControllerState requiredState = item.getDependentState();
                  if (requiredState == null)
                     requiredState = (other != null) ? other.getRequiredState() : ControllerState.INSTALLED;

                  if (actualState == null || states.isBeforeState(actualState, requiredState))
                  {
                     String requiredStateString = requiredState.getStateString();
                     MissingDependency missing = new MissingDependency(name, dependency, requiredStateString, actualStateString);
                     dependencies.add(missing);
                  }
               }
            }
View Full Code Here

   /**
    * Create the dependencies for the module
    */
   protected void createDependencies()
   {
      ControllerState classLoaderState = getClassLoaderState();
     
      List<Requirement> requirements = getRequirements();
      if (requirements != null)
      {
         requirementDependencies = new ArrayList<RequirementDependencyItem>();
View Full Code Here

   protected void change(ControllerContext context, ControllerState state, boolean trace) throws Throwable
   {
      lockWrite();
      try
      {
         ControllerState fromState = context.getState();
         int currentIndex = states.indexOf(fromState);
         int requiredIndex = states.indexOf(state);
         if (requiredIndex == -1)
            throw new IllegalArgumentException("Unknown state: " + state);
View Full Code Here

    * @param trace whether trace is enabled
    * @return whether the suceeded
    */
   protected boolean incrementState(ControllerContext context, boolean trace)
   {
      ControllerState fromState = context.getState();

      Set fromContexts = null;

      int currentIndex = -1;
      if (ControllerState.ERROR.equals(fromState))
      {
         errorContexts.remove(context);
         Throwable error = null;
         unlockWrite();
         try
         {
            install(context, ControllerState.ERROR, ControllerState.NOT_INSTALLED);
         }
         catch (Throwable t)
         {
            error = t;
         }
         finally
         {
            lockWrite();
            if (error != null)
            {
               log.error("Error during initial installation: " + context.toShortString(), error);
               context.setError(error);
               errorContexts.put(context.getName(), context);
               return false;
            }
         }
         Set<ControllerContext> notInstalled = contextsByState.get(ControllerState.NOT_INSTALLED);
         notInstalled.add(context);
         context.setState(ControllerState.NOT_INSTALLED);
      }
      else
      {
         currentIndex = states.indexOf(fromState);
         fromContexts = contextsByState.get(fromState);
         if (fromContexts.contains(context) == false)
            throw new IllegalStateException("Context not found in previous state: " + context.toShortString());
      }

      int toIndex = currentIndex + 1;
      ControllerState toState = states.get(toIndex);
      Set<ControllerContext> toContexts = contextsByState.get(toState);

      unlockWrite();
      Throwable error = null;
      try
      {
         install(context, fromState, toState);
      }
      catch (Throwable t)
      {
         error = t;
      }
      finally
      {
         lockWrite();
         if (error != null)
         {
            log.error("Error installing to " + toState.getStateString() + ": " + context.toShortString(), error);
            uninstallContext(context, ControllerState.NOT_INSTALLED, trace);
            errorContexts.put(context.getName(), context);
            context.setError(error);
            return false;
         }
View Full Code Here

      {
         onDemandEnabled = false;
         resolutions = false;
         for (int i = 0; i < states.size()-1; ++i)
         {
            ControllerState fromState = states.get(i);
            ControllerState toState = states.get(i+1);
            if (resolveContexts(fromState, toState, trace))
            {
               resolutions = true;
               break;
            }
         }
      }

      if (trace)
      {
         for (int i = 0; i < states.size()-1; ++i)
         {
            ControllerState state = states.get(i);
            ControllerState nextState = states.get(i+1);
            Set<ControllerContext> stillUnresolved = contextsByState.get(state);
            if (stillUnresolved.isEmpty() == false)
            {
               for (Iterator j = stillUnresolved.iterator(); j.hasNext();)
               {
                  ControllerContext ctx = (ControllerContext) j.next();
                  if (advance(ctx))
                     log.trace("Still unresolved " + nextState.getStateString() + ": " + ctx);
               }
            }
         }
      }
   }
View Full Code Here

      if (targetState == -1)
         log.error("INTERNAL ERROR: unknown state " + toState + " states=" + states, new Exception("STACKTRACE"));

      while (true)
      {
         ControllerState fromState = context.getState();
         if (ControllerState.ERROR.equals(fromState))
            return;
         int currentState = states.indexOf(fromState);
         if (currentState == -1)
            log.error("INTERNAL ERROR: current state not found: " + context.toShortString(), new Exception("STACKTRACE"));
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.