Package org.jboss.dependency.spi

Examples of org.jboss.dependency.spi.ControllerState


      Throwable error = targetControllerContext.getError();
      if (error != null)
         throw new IllegalArgumentException("Target bean " + targetName + " is in Error state: " + error);

      ControllerState whenRequired;
      if (whenRequiredState == null)
         whenRequired = ControllerState.INSTALLED;
      else
         whenRequired = ControllerState.getInstance(whenRequiredState);

      ControllerState currentTargetState = targetControllerContext.getState();
      if (controller.getStates().isBeforeState(currentTargetState, whenRequired) == false)
         throw new IllegalArgumentException("Target bean " + targetName + " is already past " + whenRequiredState + " state: " + targetControllerContext);

      ControllerState dependent = null;
      if (dependentState != null)
         dependent = ControllerState.getInstance(dependentState);

      DependencyInfo di = targetControllerContext.getDependencyInfo();
      for (Object dependency : dependencies)
View Full Code Here


      KernelController controller = kernel.getController();
      ControllerContext context = controller.getContext(name, null);
      if (context == null)
         throw new IllegalStateException("Context not installed: " + name);

      ControllerState state = context.getState();
      return state.getStateString();
   }
View Full Code Here

      KernelController controller = kernel.getController();
      ControllerContext context = controller.getContext(name, null);
      if (context == null)
         throw new IllegalStateException("Context not installed: " + name);
     
      ControllerState requiredState = null;
      // FIXME
      if(context instanceof KernelRegistryEntry == false)
         requiredState = context.getRequiredState();
      return mapper.map(context.getState().getStateString(), requiredState != null ? requiredState.getStateString() : null);
   }
View Full Code Here

      if(name == null)
         throw new IllegalArgumentException("null name");
      if(mapper == null)
         throw new IllegalArgumentException("null mapper");

      ControllerState current = ControllerState.NOT_INSTALLED;
     
      try
      {
         if (mbeanServer.isRegistered(new ObjectName(name.toString())))
            current = ControllerState.INSTALLED;
      }
      catch (Exception e)
      {
         // Failure = Not installed
      }
     
      return mapper.map(current.getStateString(), ControllerState.INSTALLED.getStateString());
   }
View Full Code Here

            AbstractDemandMetaData demand = (AbstractDemandMetaData) o;
            for (int i = 0; i < attrs.getLength(); ++i)
            {
               String localName = attrs.getLocalName(i);
               if ("state".equals(localName))
                  demand.setWhenRequired(new ControllerState(attrs.getValue(i)));
            }
         }
        
         public Object endElement(Object o, QName qName, ElementBinding element)
         {
            AbstractDemandMetaData x = (AbstractDemandMetaData) o;
            String name = (String) x.getDemand();
            if (name == null || name.trim().length() == 0)
               throw new IllegalArgumentException("Null or empty demand.");
            return o;
         }
      });

      // demand can take a value
      demandType.setSimpleType(new CharactersHandler()
      {
         public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
         {
            return value;
         }

         public void setValue(QName qname, ElementBinding element, Object owner, Object value)
         {
            AbstractDemandMetaData demand = (AbstractDemandMetaData) owner;
            demand.setDemand(value);
         }
      });

      // supply binding
      TypeBinding supplyType = schemaBinding.getType(supplyTypeQName);
      supplyType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new AbstractSupplyMetaData();
         }
        
         public Object endElement(Object o, QName qName, ElementBinding element)
         {
            AbstractSupplyMetaData x = (AbstractSupplyMetaData) o;
            String name = (String) x.getSupply();
            if (name == null || name.trim().length() == 0)
               throw new IllegalArgumentException("Null or empty supply.");
            return o;
         }
      });

      // supply can take a value
      supplyType.setSimpleType(new CharactersHandler()
      {
         public Object unmarshal(QName qName, TypeBinding typeBinding, NamespaceContext nsCtx, org.jboss.xb.binding.metadata.ValueMetaData valueMetaData, String value)
         {
            return value;
         }

         public void setValue(QName qName, ElementBinding element, Object owner, Object value)
         {
            AbstractSupplyMetaData supply = (AbstractSupplyMetaData) owner;
            supply.setSupply(value);
         }
      });

      // dependency binding
      TypeBinding dependencyType = schemaBinding.getType(dependencyTypeQName);
      dependencyType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new AbstractDependencyValueMetaData();
         }

         public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
         {
            AbstractDependencyValueMetaData dependency = (AbstractDependencyValueMetaData) o;
            for (int i = 0; i < attrs.getLength(); ++i)
            {
               String localName = attrs.getLocalName(i);
               if ("bean".equals(localName))
                  dependency.setValue(attrs.getValue(i));
               else if ("property".equals(localName))
                  dependency.setProperty(attrs.getValue(i));
               else if ("state".equals(localName))
                  dependency.setDependentState(new ControllerState(attrs.getValue(i)));
            }
         }
        
         public Object endElement(Object o, QName qName, ElementBinding element)
         {
View Full Code Here

      return dependentState;
   }
  
   public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
   {
      ControllerState state = dependentState;
      if (state == null)
         state = ControllerState.INSTALLED;
      ControllerContext context = controller.getContext(value, dependentState);
      if (context == null)
         throw new Error("Should not be here - dependency failed! " + this);
View Full Code Here

   {
      KernelControllerContext controllerContext = visitor.getControllerContext();
      controller = (KernelController) controllerContext.getController();
      Object name = controllerContext.getName();
      Object iDependOn = getUnderlyingValue();
      ControllerState whenRequired = visitor.getContextState();

      DependencyItem item = new AbstractDependencyItem(name, iDependOn, whenRequired, dependentState);
      visitor.addDependency(item);

      super.visit(visitor);
View Full Code Here

        
         // Visit the children of this node
         Iterator children = node.getChildren();
         if (children != null)
         {
            ControllerState restoreState = contextState;
            while (children.hasNext())
            {
               MetaDataVisitorNode child = (MetaDataVisitorNode) children.next();
               try
               {
View Full Code Here

    * @param trace whether trace is enabled
    * @throws Throwable for any error
    */
   protected void change(ControllerContext context, ControllerState state, boolean trace) throws Throwable
   {
      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);
         try
         {
            install(context, ControllerState.ERROR, ControllerState.NOT_INSTALLED);
         }
         catch (Throwable t)
         {
            log.error("Error during initial installation: " + context.toShortString(), t);
            context.setError(t);
            errorContexts.add(context);
            return false;
           
         }
         Set notInstalled = (Set) contextsByState.get(ControllerState.NOT_INSTALLED);
         notInstalled.add(context);
      }
      else
      {
         currentIndex = states.indexOf(fromState);
         fromContexts = (Set) 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 = (ControllerState) states.get(toIndex);
      Set toContexts = (Set) contextsByState.get(toState);
     
      try
      {
         install(context, fromState, toState);
      }
      catch (Throwable t)
      {
         log.error("Error installing to " + toState.getStateString() + ": " + context.toShortString(), t);
         uninstallContext(context, ControllerState.NOT_INSTALLED, trace);
         context.setError(t);
         errorContexts.add(context);
         return false;
      }
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.