4 Replies Latest reply on Jan 14, 2010 5:31 PM by Arbi Sookazian

    Can CDI offer magic for PhaseListener impl?

    Arbi Sookazian Master

      I have the following class which I want to be available/active during dev, not prod.

      public class LifeCycleListener implements PhaseListener {
           private static final long serialVersionUID = 7280794517722311938L;
           private static Logger log = Logger.getLogger(LifeCycleListener.class);
           public PhaseId getPhaseId() {
              return PhaseId.ANY_PHASE;
          public void beforePhase(PhaseEvent event) {
              log.info("LifeCycleListener: START PHASE " + event.getPhaseId());
          public void afterPhase(PhaseEvent event) {
               log.info("LifeCycleListener: END PHASE " + event.getPhaseId());

      Is there any way to refactor this in CDI/Weld such that I can achieve this?  The @Install(false) did not block the class from being active, all that does is block it from being scanned and installed/managed by the Seam container as a Seam component. 

      Or perhaps this is simply a build issue (i.e. have ant or maven not include this class in the WAR/EAR if the build mode is 'prod').  But I was hoping for an elegant programmatic solution.