Class CdiHelper

java.lang.Object
fr.paris.lutece.portal.service.util.CdiHelper

public class CdiHelper extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    getBean(Class<T> clazz)
    Obtains a contextual reference for a certain bean type of the bean.
    static <T> T
    getReference(Type beanType, String name)
    Obtains a contextual reference for a certain EL name and a certain bean type of the bean.
    static <T> T
    resolve(jakarta.enterprise.inject.Instance<T> instance, String serviceName)
    Generic service resolution using CDI Instance<T>.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CdiHelper

      public CdiHelper()
  • Method Details

    • getReference

      public static <T> T getReference(Type beanType, String name)

      Obtains a contextual reference for a certain EL name and a certain bean type of the bean.

      Parameters:
      beanType - a bean type that must be implemented by any client proxy that is returned
      name - the EL name
      Returns:
      a contextual reference
      Throws:
      IllegalArgumentException - if the given type is not a bean type of the given bean
      IllegalStateException - if called during application initialization, before the AfterDeploymentValidation event is fired.
    • getBean

      public static <T> T getBean(Class<T> clazz)

      Obtains a contextual reference for a certain bean type of the bean.

      Parameters:
      clazz - the class of the bean
      Returns:
      a contextual reference
    • resolve

      public static <T> T resolve(jakarta.enterprise.inject.Instance<T> instance, String serviceName)
      Generic service resolution using CDI Instance<T>. Provides proper error handling and logging for missing services.
      Type Parameters:
      T - Service type
      Parameters:
      instance - CDI Instance container
      serviceName - Name/qualifier of the service to resolve
      Returns:
      resolved service instance
      Throws:
      IllegalStateException - if service cannot be resolved