public void addInjectionTargetToBeInitialized(
     InjectionTargetInitializationContext<?> initializationContext) {
   if (container.getState().equals(ContainerState.VALIDATED)
       || container.getState().equals(ContainerState.INITIALIZED)) {
     // initialize now and don't store for later initialization as this has been created at runtime
     initializationContext.initialize();
   } else {
     injectionTargetsToInitialize.add(initializationContext);
   }
 }
 public void validateProducer(Producer<?> producer) {
   if (container.getState().equals(ContainerState.VALIDATED)
       || container.getState().equals(ContainerState.INITIALIZED)) {
     // We are past the bootstrap and therefore we can validate the producer immediately
     validator.validateProducer(producer, beanManager);
   } else {
     // Validate injection points for definition errors now
     for (InjectionPoint ip : producer.getInjectionPoints()) {
       validator.validateInjectionPointForDefinitionErrors(ip, ip.getBean(), beanManager);
       validator.validateEventMetadataInjectionPoint(ip);
     }
     // Schedule validation for deployment problems to be done later
     producersToValidate.add(producer);
   }
 }
Esempio n. 3
0
  /**
   * 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);
    }
  }