users@javaserverfaces-spec-public.java.net

[jsr372-experts mirror] Re: CDI decorator support for FacesWrapper subclasses

From: Guillermo González de Agüero <z06.guillermo_at_gmail.com>
Date: Sat, 27 Aug 2016 16:34:17 +0200

Another benefit I forgot: with that kind of CDI integration we'd also get
an improved debugging experience, thaks to tools like Weld Probe [1]. A
common JSF application already has a component library (e.g. PrimeFaces)
and OmniFaces present. At the moment it is difficult to get an overview of
the "decorated" artifacts, and that could be handy when the user wants to
add another wrapping layer.


Regards,

Guillermo González de Agüero

[1]
https://developer.jboss.org/people/mkouba/blog/2015/02/05/weld-probe--inspect-your-cdi-application-at-runtime

On Sat, Aug 27, 2016 at 4:19 PM, Guillermo González de Agüero <
z06.guillermo_at_gmail.com> wrote:

> Hi all,
>
> As part of the CDI alignment effort for JSF 2.3, I'd like to propose
> another enhancement.
>
> Currently, there are a lot of artifacts that can be wrapped (decorated) by
> extending a FacesWrapper implementation and registering them at
> faces-config.xml [1].
>
> I'd like to be able to just use CDI decorators for this, like:
>
> @Priority(1000)
> @Decorator
> public abstract MyCustomResourceHandler extends ResourceHandler {
>
> @Inject
> @Delegate
> private ResourceHandler rh;
>
> @Override
> public Resource createResource(String resource) {
> // ..
> }
> }
>
> The only problem is that CDI requires the decorated artifact to be an
> interface instead of a class. So to achieve this. So methods would need to
> be extracted to new interfaces.
>
> The end user benefits would be a simplified and more standard way to
> decorate artifacts and less need for the faces-config.xml.
>
> What do you think?
>
>
> Regards,
>
> Guillermo González de Agüero.
>
> [1] https://javaserverfaces.java.net/docs/2.2/javadocs/javax/
> faces/FacesWrapper.html
>