Class 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 Detail

      • ParamExtension

        public ParamExtension()
    • Method Detail

      • 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.