Search in sources :

Example 1 with HttpMethodRestrictionsPhaseListener

use of com.sun.faces.lifecycle.HttpMethodRestrictionsPhaseListener in project mojarra by eclipse-ee4j.

the class WebConfiguration method doPostBringupActions.

public void doPostBringupActions() {
    if (deferredLoggingActions != null) {
        for (DeferredLoggingAction loggingAction : deferredLoggingActions) {
            loggingAction.log();
        }
    }
    // Add the HttpMethodRestrictionPhaseListener if the parameter is enabled.
    boolean enabled = isOptionEnabled(BooleanWebContextInitParameter.EnableHttpMethodRestrictionPhaseListener);
    if (enabled) {
        LifecycleFactory factory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
        PhaseListener listener = null;
        for (String lifecycleId : toIterable(factory.getLifecycleIds())) {
            Lifecycle lifecycle = factory.getLifecycle(lifecycleId);
            boolean foundExistingListenerInstance = false;
            for (PhaseListener curListener : lifecycle.getPhaseListeners()) {
                if (curListener instanceof HttpMethodRestrictionsPhaseListener) {
                    foundExistingListenerInstance = true;
                    break;
                }
            }
            if (!foundExistingListenerInstance) {
                if (listener == null) {
                    listener = new HttpMethodRestrictionsPhaseListener();
                }
                lifecycle.addPhaseListener(listener);
            }
        }
    }
    discoverResourceLibraryContracts();
}
Also used : PhaseListener(jakarta.faces.event.PhaseListener) HttpMethodRestrictionsPhaseListener(com.sun.faces.lifecycle.HttpMethodRestrictionsPhaseListener) LifecycleFactory(jakarta.faces.lifecycle.LifecycleFactory) Lifecycle(jakarta.faces.lifecycle.Lifecycle) HttpMethodRestrictionsPhaseListener(com.sun.faces.lifecycle.HttpMethodRestrictionsPhaseListener)

Aggregations

HttpMethodRestrictionsPhaseListener (com.sun.faces.lifecycle.HttpMethodRestrictionsPhaseListener)1 PhaseListener (jakarta.faces.event.PhaseListener)1 Lifecycle (jakarta.faces.lifecycle.Lifecycle)1 LifecycleFactory (jakarta.faces.lifecycle.LifecycleFactory)1