Package org.jvnet.hk2.internal

Examples of org.jvnet.hk2.internal.Utilities$ScopeInfo


                Type genericType,
                Class<V> type) throws ComponentException {
        Inhabitant<?> lead = onBehalfOf.lead();
        if (lead==null) {
            // TODO: we should be able to check this error at APT, too.
            throw new ComponentException(component.getClass()+" requested @Lead injection but this is not a companion");
        }
       
        if(type==Inhabitant.class) {
            return type.cast(lead);
        }
View Full Code Here


    public T create(Inhabitant onBehalfOf) throws ComponentException {
        try {
            return type.newInstance();
        } catch (InstantiationException e) {
            throw new ComponentException("Failed to create "+type,e);
        } catch (IllegalAccessException e) {
            throw new ComponentException("Failed to create "+type,e);
        } catch (LinkageError e) {
            throw new ComponentException("Failed to create "+type,e);
        } catch (RuntimeException e) {
            throw new ComponentException("Failed to create "+type,e);
        }
    }
View Full Code Here

      }
 
      // other general case
      Scope scope = habitat.getByType(scopeClass);
      if (scope==null) {
          throw new ComponentException("Failed to look up %s", scopeClass);
      }
 
      return new ScopedInhabitant<T>(creator,scope);
  }
View Full Code Here

  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

      Integer planned = state.getPlannedRunLevel();
      planned = (null == planned) ? DefaultRunLevelService.KERNEL_RUNLEVEL : planned;
      Integer current = state.getCurrentRunLevel();
      current = (null == current) ? DefaultRunLevelService.KERNEL_RUNLEVEL : current;
      if (null == planned || runLevel > planned || runLevel > current + 1) {
        throw new ComponentException("unable to activate " + this + "; minimum expected RunLevel is: " + runLevel +
            "; planned is: " + planned + "; current is: " + current);
      }
    }
  }
View Full Code Here

    public WonderlandAppServer(Server server) {
        this.server = server;

        // add a module to properly specify the classpath
        Habitat h = server.getHabitat();
        ModulesRegistry mr = h.getComponent(ModulesRegistry.class);
        mr.add(new ClasspathModuleDefinition(WebServerLauncher.getClassLoader()));
    }
View Full Code Here

    public Habitat createHabitat() throws ComponentException {
        if (null != habitatFactory) {
          return habitatFactory.newHabitat();
        }
       
        return new Habitat();
    }
View Full Code Here

            if (replacements.containsKey(typeName)) {
                // create a replacement instead
                Class<?> target = replacements.get(typeName);
                if(target!=null) {
                    inhabitantParser.setImplName(target.getName());
                    Inhabitant i = null;
                    try {
                      i = Inhabitants.create(target,habitat,inhabitantParser.getMetaData());
                    } catch (Exception e) {
                      log(typeName, e);
                    }
View Full Code Here

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

  protected void notify(InhabitantListener.EventType eventType) {
    if (null != listeners) {
      Iterator<InhabitantListener> iter = listeners.iterator();
      while (iter.hasNext()) {
        InhabitantListener listener = iter.next();
        try {
          boolean keepListening = listener.inhabitantChanged(eventType, this);
          if (!keepListening) {
            removeInhabitantListener(listener);
          }
        } catch (Exception e) {
          // don't percolate the exception since it may negatively impact processing
View Full Code Here

TOP

Related Classes of org.jvnet.hk2.internal.Utilities$ScopeInfo

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.