Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent installation of a phase listener from included jar in jsf 2

Tags:

jsf

jsf-2

I have a JSF 2 application that includes a jar file which in turn contains a faces-config.xml in its META-INF directory. The faces-config.xml contains a declaration of a phase-listener. I would like to prevent the installation of this phase listener without modifying the jar file itself. Is this possible?

like image 429
cyberoblivion Avatar asked Mar 22 '13 14:03

cyberoblivion


1 Answers

You can't block specific parts of faces-config.xml in a 3rd party JAR from being interpreted.

You have basically 2 options:

  1. Block the whole faces-config.xml in a 3rd party JAR from being interpreted by adding metadata-complete="true" to webapp's own faces-config.xml.

    <faces-config ... metadata-complete="true">
    

    Note that this also skips annotation scans in classes of the 3rd party JAR. You'd basically need to redefine specific parts you'd like to use in webapp's own faces-config.xml.


  2. Provide a custom Lifecycle implementation via LifecycleFactory which you register in <factory><lifecycle-factory> of webapp's faces-config.xml. In that implementation, override addPhaseListener() accordingly to perform e.g. an instanceof check before skipping or continuing.

like image 95
BalusC Avatar answered Oct 07 '22 16:10

BalusC