Examples of ServiceContext


Examples of org.jboss.system.ServiceContext

         log.warn("Ignoring request to create null service: ", new Exception("STACKTRACE"));
         return;
      }
     
      log.debug("Creating service " + serviceName);
      ServiceContext ctx = createServiceContext(serviceName);

      // Register the context and its dependencies if necessary
      register(ctx, depends);

      // If we are already created (can happen in dependencies) or failed just return
      if (ctx.state == ServiceContext.CREATED
            || ctx.state == ServiceContext.RUNNING
            || ctx.state == ServiceContext.FAILED)
      {
         log.debug("Ignoring create request for service: " + ctx.objectName);
         return;
      }

      // JSR 77, and to avoid circular dependencies
      int oldState = ctx.state;
      ctx.state = ServiceContext.CREATED;

      // Are all the mbeans I depend on created?   if not just return
      for (Iterator iterator = ctx.iDependOn.iterator(); iterator.hasNext();)
      {
         ServiceContext sc = (ServiceContext) iterator.next();
         int state = sc.state;

         // A dependent is not created or running
         if (!(state == ServiceContext.CREATED || state == ServiceContext.RUNNING))
         {
            log.debug("waiting in create of " + serviceName +
                  " waiting on " + sc.objectName);
            ctx.state = oldState;
            return;
         }
      }

      // Call create on the service Proxy
      try
      {
         ctx.proxy.create();
         sendControllerNotification(ServiceMBean.CREATE_EVENT, serviceName);           
      }
      catch (Throwable e)
      {
         ctx.state = ServiceContext.FAILED;
         ctx.problem = e;
         log.warn("Problem creating service " + serviceName, e);
         return;
      }

      // Those that depend on me are waiting for my creation, recursively create them
      log.debug("Creating dependent components for: " + serviceName
            + " dependents are: " + ctx.dependsOnMe);
      ArrayList<ServiceContext> tmp = new ArrayList<ServiceContext>(ctx.dependsOnMe);
      for (int n = 0; n < tmp.size(); n++)
      {
         // marcf fixme circular dependencies?
         ServiceContext ctx2 = tmp.get(n);
         create(ctx2.objectName);
      }
      tmp.clear();
   }
View Full Code Here

Examples of org.jboss.system.ServiceContext

         return;
      }

      log.debug("starting service " + serviceName);

      ServiceContext ctx = createServiceContext(serviceName);

      if (!installedServices.contains(ctx))
         installedServices.add(ctx);

      // If we are already started (can happen in dependencies) just return
      if (ctx.state == ServiceContext.RUNNING || ctx.state == ServiceContext.FAILED)
      {
         log.debug("Ignoring start request for service: " + ctx.objectName);
         return;
      }

      // Start() is called before create(), so call create() to compensate
      if (ctx.state != ServiceContext.CREATED && ctx.state != ServiceContext.STOPPED)
      {
         log.debug("Start requested before create, calling create now for service: " + serviceName);
         create(serviceName);
      }
     
      // Get the fancy service proxy (for the lifecycle API)
      if (ctx.proxy == null)
         ctx.proxy = getServiceProxy(ctx.objectName, null);

      // JSR 77, and to avoid circular dependencies
      int oldState = ctx.state;
      ctx.state = ServiceContext.RUNNING;

      // Are all the mbeans I depend on started?   if not just return
      for (Iterator iterator = ctx.iDependOn.iterator(); iterator.hasNext();)
      {
         ServiceContext sctx = (ServiceContext) iterator.next();

         int state = sctx.state;

         // A dependent is not running
         if (!(state == ServiceContext.RUNNING))
         {
            log.debug("waiting in start " + serviceName + " on " + sctx.objectName);
            ctx.state = oldState;
            return;
         }
      }

      // Call start on the service Proxy
      try
      {
         ctx.proxy.start();
         sendControllerNotification(ServiceMBean.START_EVENT, serviceName);           
      }
      catch (Throwable e)
      {
         ctx.state = ServiceContext.FAILED;
         ctx.problem = e;
         log.warn("Problem starting service " + serviceName, e);
         return;
      }
      // Those that depend on me are waiting for my start, recursively start them
      log.debug("Starting dependent components for: " + serviceName
            + " dependent components: " + ctx.dependsOnMe);
      ArrayList<ServiceContext> tmp = new ArrayList<ServiceContext>(ctx.dependsOnMe);
      for (int n = 0; n < tmp.size(); n++)
      {
         // marcf fixme circular dependencies?
         ServiceContext ctx2 = tmp.get(n);
         start(ctx2.objectName);
      }
      tmp.clear();
   }
View Full Code Here

Examples of org.jboss.system.ServiceContext

      {
         log.warn("Ignoring request to stop null service: ", new Exception("STACKTRACE"));
         return;
      }

      ServiceContext ctx = nameToServiceMap.get(serviceName);
      log.debug("stopping service: " + serviceName);

      if (ctx == null)
      {
         log.warn("Ignoring request to stop nonexistent service: " + serviceName);
         return;
      }

      // If we are already stopped (can happen in dependencies) just return
      if (ctx.state != ServiceContext.RUNNING) return;

      // JSR 77 and to avoid circular dependencies
      ctx.state = ServiceContext.STOPPED;

      log.debug("stopping dependent services for: " + serviceName
            + " dependent services are: " + ctx.dependsOnMe);
     
      ArrayList<ServiceContext> tmp = new ArrayList<ServiceContext>(ctx.dependsOnMe);
      for (int n = 0; n < tmp.size(); n++)
      {
         // stop all the mbeans that depend on me
         ServiceContext ctx2 = tmp.get(n);
         ObjectName other = ctx2.objectName;
         stop(other);
      }
      tmp.clear();
View Full Code Here

Examples of org.jboss.system.ServiceContext

      {
         log.warn("Ignoring request to destroy null service: ", new Exception("STACKTRACE"));
         return;
      }

      ServiceContext ctx = nameToServiceMap.get(serviceName);
      log.debug("destroying service: " + serviceName);

      if (ctx == null)
      {
         log.warn("Ignoring request to destroy nonexistent service: " + serviceName);
         return;
      }

      // If we are already destroyed (can happen in dependencies) just return
      if (ctx.state == ServiceContext.DESTROYED ||
          ctx.state == ServiceContext.NOTYETINSTALLED)
         return;
     
      // If we are still running, stop service first
      if (ctx.state == ServiceContext.RUNNING)
      {
         log.debug("Destroy requested before stop, calling stop now for service: " + serviceName);
         stop(serviceName);
      }

      // JSR 77, and to avoid circular dependencies
      ctx.state = ServiceContext.DESTROYED;

      log.debug("destroying dependent services for: " + serviceName
            + " dependent services are: " + ctx.dependsOnMe);
     
      ArrayList<ServiceContext> tmp = new ArrayList<ServiceContext>(ctx.dependsOnMe);
      for (int n = 0; n < tmp.size(); n++)
      {
         // destroy all the mbeans that depend on me
         ServiceContext ctx2 = tmp.get(n);
         ObjectName other = ctx2.objectName;
         destroy(other);
      }
      tmp.clear();
View Full Code Here

Examples of org.jboss.system.ServiceContext

      {
         log.warn("Ignoring request to remove null service: ", new Exception("STACKTRACE"));
         return;
      }

      ServiceContext ctx = nameToServiceMap.get(objectName);
      if (ctx == null)
      {
         log.debug("Ignoring request to remove nonexistent service: " + objectName);
         return;
      }
      log.debug("removing service: " + objectName);

      // Notify those that think I depend on them
      Iterator iterator = ctx.iDependOn.iterator();
      while (iterator.hasNext())
      {
         ServiceContext iDependOnContext = (ServiceContext) iterator.next();
         iDependOnContext.dependsOnMe.remove(ctx);

         // Remove any context whose only reason for existence is that
         // we depend on it, i.e. it otherwise unknown to the system
         if (iDependOnContext.state == ServiceContext.NOTYETINSTALLED
View Full Code Here

Examples of org.jboss.system.ServiceContext

    *
    * @jmx.managed-operation
    */
   public ServiceContext getServiceContext(ObjectName serviceName)
   {
      ServiceContext ctx = nameToServiceMap.get(serviceName);
      return ctx;
   }
View Full Code Here

Examples of org.jboss.system.ServiceContext

      ObjectName name = null;

      ListIterator i = servicesCopy.listIterator(servicesCopy.size());
      while (i.hasPrevious())
      {
         ServiceContext ctx = (ServiceContext) i.previous();
         name = ctx.objectName;

         // Go through the full stop/destroy cycle
         try
         {
View Full Code Here

Examples of org.jboss.system.ServiceContext

      creator = new OldServiceCreator(server);
      configurator = new OldServiceConfigurator(server, this, creator);

      // Register the ServiceController as a running service
      ServiceContext sc = this.createServiceContext(name);
      sc.state = ServiceContext.RUNNING;

      log.debug("Controller MBean online");
      return name == null ? OBJECT_NAME : name;
   }
View Full Code Here

Examples of org.jboss.system.ServiceContext

      // If it is already there just return it
      if (nameToServiceMap.containsKey(objectName))
         return nameToServiceMap.get(objectName);

      // If not create it, add it and return it
      ServiceContext ctx = new ServiceContext();
      ctx.objectName = objectName;

      // we keep track of these here
      nameToServiceMap.put(objectName, ctx);
View Full Code Here

Examples of org.jboss.system.ServiceContext

   }

   void registerDependency(ObjectName needs, ObjectName used)
   {
      log.debug("recording that " + needs + " depends on " + used);
      ServiceContext needsCtx = createServiceContext(needs);
      ServiceContext usedCtx = createServiceContext(used);


      if (!needsCtx.iDependOn.contains(usedCtx))
      {
         // needsCtx depends on usedCtx
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.