コード例 #1
0
ファイル: BeanManagerProxy.java プロジェクト: weld/core
  /**
   * When in portable mode (default) this method verifies that the container has reached the
   * specified minimal state. If it hasn't, an {@link IllegalStateException} is thrown. When in
   * non-portable mode this method is no-op.
   *
   * @param methodName
   * @param minimalState the minimal state
   * @throws IllegalStateException If the application initialization is not finished yet
   */
  private void checkContainerState(String methodName, ContainerState minimalState) {
    if (nonPortableMode) {
      return;
    }
    if (this.container == null) {
      this.container = Container.instance(manager);
    }

    ContainerState state = container.getState();
    if (SHUTDOWN.equals(state)) {
      throw BeanManagerLogger.LOG.methodNotAvailableAfterShutdown(methodName);
    }
    if (state.compareTo(minimalState) < 0) {
      throw BeanManagerLogger.LOG.methodNotAvailableDuringInitialization(methodName, state);
    }
  }