コード例 #1
0
ファイル: XmlContext.java プロジェクト: krevelen/coala
  /** @return the cached ObjectMapper */
  @SuppressWarnings("unchecked")
  public synchronized T getObjectFactory() {
    if (this._ObjectMapper == null)
      try {
        this._ObjectMapper = (T) ClassUtil.instantiate(this.contextID.getObjectFactoryType());
      } catch (final CoalaException e) {
        throw CoalaExceptionFactory.INCONSTRUCTIBLE.createRuntime(
            e, this.contextID.getObjectFactoryType(), null);
      }

    return this._ObjectMapper;
  }
コード例 #2
0
ファイル: StageUtil.java プロジェクト: krevelen/coala-binder
  /**
   * @param provider
   * @param stageObserver
   * @return
   * @throws Throwable
   */
  public static <T> T inject(final Provider<T> provider, final Observer<StageChange> stageObserver)
      throws Throwable {
    @SuppressWarnings("unchecked")
    final Class<T> type =
        (Class<T>) ClassUtil.getTypeArguments(Provider.class, provider.getClass()).get(0);

    boolean success = true;

    if (stageObserver != null)
      stageObserver.onNext(new StageChangeImpl(type, null, Stage.PREPARING, null));

    success &= invokeEventHandlers(stageObserver, type, null, null, StageEvent.BEFORE_PROVIDE);

    success &=
        invokeStages(
            stageObserver, type, null, findStages(type, InjectStaged.BEFORE_PROVIDE_SELECTOR));

    if (stageObserver != null)
      stageObserver.onNext(new StageChangeImpl(type, null, Stage.PROVIDING, null));

    final FinalizeDecorator<T> subject =
        FinalizeDecorator.from(stageObserver, type, provider.get());

    if (stageObserver != null)
      stageObserver.onNext(new StageChangeImpl(type, subject.getTarget(), Stage.PROVIDED, null));
    success &=
        invokeEventHandlers(
            stageObserver, type, subject.getTarget(), null, StageEvent.AFTER_PROVIDE);

    success &=
        invokeStages(
            stageObserver,
            type,
            subject.getTarget(),
            findStages(type, InjectStaged.AFTER_PROVIDE_SELECTOR));

    if (stageObserver != null && success)
      stageObserver.onNext(new StageChangeImpl(type, subject.getTarget(), Stage.STOPPED, null));
    return subject.getTarget();
  }