jeudi 23 juillet 2015

JSF @ManagedBeans, Dependency Injection, Mocking and Testing

My setup is a small JSF2.2 application. This application has two ManagedBean classes, which both implement the same Interface. One written in Mockito used for development and unit testing (we're using TestNG) and one written in ActiveMQ, used for Production and CI. How do I tell the Facelet which implementation to use? In spring I would use a different application-context, in Guice a different AbstractModule. Now before you say use CDI or EJB for this, there's a little catch, for various legacy reasons, beyond my control, or sphere of influence, we're not using a proper JavaEE container (we're using Jetty 9 (upgraded less than 2 months ago from Jetty 6, so yeah).

Now my first reaction would be "Go with what you know", but wiring Guice or Spring Beans into a JSF/PrimeFaces application just feels redundant and wrong.

So my somewhat long-winded question is, is there something I'm overlooking? What is the pure-JSF equivalent of a Spring @Configuration or Guice AbstractModule? Is Spring/Guice/CDI really a requirement for this?

Aucun commentaire:

Enregistrer un commentaire