Examples of RunLevel


Examples of org.jvnet.hk2.annotations.RunLevel

      Set<String> indicies) {
    AbstractInhabitantImpl<?> i = new LazyInhabitant(habitat, classLoader, typeName, metadata, lead);
    if (contains(indicies, RunLevel.class.getName())) {
      // this is a RunLevel service, we need to load type in order to get
      // more type information about it, namely it's environment and actual RunLevel id
      RunLevel rl = i.getAnnotation(RunLevel.class);
      assert(null != rl) : typeName + " is a problem; " + i + " has no RunLevel annotation";
      assert(!i.isInstantiated()) : "inhabitant should not be active: " + i;

      // get the appropriate RLS for this RunLevel
      RunLevelService<?> rls = runLevelServices.get(habitat, rl);
      InhabitantListener listener = InhabitantListener.class.isInstance(rls) ?
          InhabitantListener.class.cast(rls) : null;

      // wrap the inhabitant with a RunLevelInhabitant
      int runLevel = rl.value();
     
      // construct the runLevel inhabitant
      i = new RunLevelInhabitant(i, runLevel, rls.getState(), listener);
    }
   
View Full Code Here

Examples of org.jvnet.hk2.annotations.RunLevel

   * @param target
   * @param injectedVal
   */
  static void validate(Object target, Object injectedVal) {
      if (null != injectedVal) {
          RunLevel targetRL = AbstractInhabitantImpl.getAnnotation(target.getClass(), RunLevel.class, false);
          RunLevel injectedValRL = AbstractInhabitantImpl.getAnnotation(injectedVal.getClass(), RunLevel.class, false);
          if (null == targetRL && null != injectedValRL) {
              throw new ComponentException("invalid dependency from a non-RunLevel instance " +
                  target + " to a RunLevel instance " + injectedVal);
        }
    }
View Full Code Here

Examples of org.jvnet.hk2.annotations.RunLevel

      return InhabitantListener.class.cast(delegate).inhabitantChanged(
          eventType, inhabitant);
    }

    AbstractInhabitantImpl<?> ai = AbstractInhabitantImpl.class.cast(inhabitant);
    RunLevel rl = ai.getAnnotation(RunLevel.class);
    Integer activeRunLevel = (null == rl) ? null : rl.value();
   
    if (null != activeRunLevel) {
      // forward to the active recorder?
      if (InhabitantListener.EventType.INHABITANT_ACTIVATED == eventType) {
        Recorder activeRecorder;
View Full Code Here

Examples of org.jvnet.hk2.annotations.RunLevel

      // TODO: we could cache this in top-level proceedTo()
      Collection<Inhabitant<?>> runLevelInhabitants =
        habitat.getAllInhabitantsByContract(RunLevel.class.getName());
      for (Inhabitant<?> i : runLevelInhabitants) {
        AbstractInhabitantImpl<?> ai = AbstractInhabitantImpl.class.cast(i);
        RunLevel rl = ai.getAnnotation(RunLevel.class);
   
        if (accept(ai, rl, activeRunLevel)) {
          RunLevelInhabitant<?,?> rli = RunLevelInhabitant.class.cast(ai);
          checkBinding(rli);
          activations.add(rli);
View Full Code Here

Examples of org.jvnet.hk2.annotations.RunLevel

  public synchronized boolean inhabitantChanged(EventType eventType, Inhabitant<?> inhabitant) {
    if (EventType.INHABITANT_ACTIVATED == eventType) {
      assert(inhabitant.isInstantiated());
      assert(AbstractInhabitantImpl.class.isInstance(inhabitant));
  
      RunLevel rl = ((AbstractInhabitantImpl<?>)inhabitant).getAnnotation(RunLevel.class);
      // actually, it should really never be null (in real life we could consider tossing an exception)
      if (null != rl) {
        if (targetEnv == rl.environment()) {
          push(inhabitant);
         
          // verify it is not to a bad dependency
          if (rl.value() > runLevel) {
            throw new ComponentException("Invalid RunLevel dependency to: " + inhabitant);
          }
        }
      }
    }
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.