Class ParamExtension

java.lang.Object
org.omnifaces.cdi.param.ParamExtension
All Implemented Interfaces:
Extension

public class ParamExtension extends Object implements Extension
CDI extension that works around the fact that CDI insists on doing absolutely guaranteed type safe injections. While generally applaudable this unfortunately impedes writing true generic producers that dynamically do conversion based on the target type.

This extension collects the target types of each injection point qualified with the @Param annotation and dynamically registers Beans that effectively represents producers for each type.

Since OmniFaces 3.6, this extension also scans for @Param without @Inject and manually takes care of them while creating the bean.

Since:
2.0
Author:
Arjan Tijms
  • Constructor Details

    • ParamExtension

      public ParamExtension()
  • Method Details

    • collectParams

      public <T> void collectParams(@Observes ProcessInjectionTarget<T> event)
      Collect fields annotated with Param.
      Type Parameters:
      T - The generic injection target type.
      Parameters:
      event - The process injection target event.
    • processParamsWithInject

      public void processParamsWithInject(@Observes AfterBeanDiscovery event)
      Process Param fields annotated with Inject.
      Parameters:
      event - The after bean discovery event.
    • processParamsWithoutInject

      public static <T> void processParamsWithoutInject(ProcessInjectionTarget<T> event, Set<AnnotatedField<?>> paramsWithoutInject)
      /** Process Param fields without Inject annotation.
      Type Parameters:
      T - The generic injection target type.
      Parameters:
      event - The process injection target event.
      paramsWithoutInject - The Param fields without Inject annotation.