users@javaserverfaces-spec-public.java.net

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

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

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