Package org.jvnet.hk2.component

Examples of org.jvnet.hk2.component.ComponentException


    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

        } catch (Interrupt interrupt) {
          lastInterrupt = interrupt;
        } catch (Exception e) {
          // don't percolate the exception since it may negatively impact processing
          logger.log(Level.WARNING, "swallowing exception - " + getDescription(true),
              new ComponentException(e));
        }
      }
     
      if (null != lastInterrupt) {
        throw lastInterrupt;
      } else {
        if (null != error) {
          logger.log(Level.FINE, "swallowing exception - " + context, new ComponentException(error));
        }
      }
    }
  }
View Full Code Here

      if (null != next) {
        proceedTo(next);
      } else {
        // RLS must continue / fall out
        logger.log(Level.FINE, "swallowing exception - " + getDescription(true),
            new ComponentException(e));
      }
    }
View Full Code Here

    RunLevelService<?> theOne = null;
    for (RunLevelService<?> hrls : coll) {
      if (null != hrls.getState() &&
          hrls.getState().getEnvironment() == environment) {
        if (null != theOne) {
          throw new ComponentException("constraint violation - competing RunLevelServices: " +
              theOne + " and " + hrls);
        }
        theOne = hrls;
      }
    }
View Full Code Here

    if (null == habitat) {
      return;
    }
   
    if (habitat.isInitialized()) {
      throw new ComponentException("no RunLevelService found appropriate for RunLevel: " + rl);
    }
   
    habitat.addHabitatListener(new HabitatListener() {
      @Override
      public boolean inhabitantChanged(EventType eventType, Habitat habitat,
View Full Code Here

        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

     * Obtains a {@link ConfigModel} for the given class (Which should have {@link Configured} annotation on it.)
     */
    public ConfigModel buildModel(String fullyQualifiedClassName) {
        Inhabitant i = habitat.getInhabitantByAnnotation(InjectionTarget.class, fullyQualifiedClassName);
        if(i==null)
            throw new ComponentException("ConfigInjector for %s is not found, is it annotated with @Configured",fullyQualifiedClassName);
        return buildModel(i);
    }
View Full Code Here

TOP

Related Classes of org.jvnet.hk2.component.ComponentException

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.