use of jakarta.faces.lifecycle.Lifecycle in project mojarra by eclipse-ee4j.
the class CdiLifecycleFactory method getLifecycleIds.
@Override
public Iterator<String> getLifecycleIds() {
ArrayList<String> lifecycleIds = new ArrayList<>();
getWrapped().getLifecycleIds().forEachRemaining(lifecycleIds::add);
BeanManager beanManager = getBeanManager();
AnnotatedType<Lifecycle> type = beanManager.createAnnotatedType(Lifecycle.class);
Set<Bean<?>> beans = beanManager.getBeans(type.getBaseType());
Iterator<Bean<?>> iterator = beans.iterator();
while (iterator.hasNext()) {
Bean<?> bean = iterator.next();
if (bean.getBeanClass().isAnnotationPresent(Named.class)) {
Named named = bean.getBeanClass().getAnnotation(Named.class);
lifecycleIds.add(named.value());
}
}
return lifecycleIds.iterator();
}
use of jakarta.faces.lifecycle.Lifecycle in project mojarra by eclipse-ee4j.
the class LifecycleConfigProcessor method addPhaseListeners.
// --------------------------------------------------------- Private Methods
private void addPhaseListeners(ServletContext sc, FacesContext facesContext, LifecycleFactory factory, NodeList phaseListeners) {
if (phaseListeners != null && phaseListeners.getLength() > 0) {
for (int i = 0, size = phaseListeners.getLength(); i < size; i++) {
Node phaseListenerNode = phaseListeners.item(i);
String phaseListenerClassName = getNodeText(phaseListenerNode);
if (phaseListenerClassName != null) {
boolean[] didPerformInjection = { false };
PhaseListener phaseListener = (PhaseListener) createInstance(sc, facesContext, phaseListenerClassName, PhaseListener.class, null, phaseListenerNode, true, didPerformInjection);
if (phaseListener != null) {
if (didPerformInjection[0]) {
appPhaseListeners.add(phaseListener);
}
for (Iterator<String> t = factory.getLifecycleIds(); t.hasNext(); ) {
String lfId = t.next();
Lifecycle lifecycle = factory.getLifecycle(lfId);
if (LOGGER.isLoggable(FINE)) {
LOGGER.log(FINE, format("Adding PhaseListener ''{0}'' to lifecycle ''{0}}", phaseListenerClassName, lfId));
}
lifecycle.addPhaseListener(phaseListener);
}
}
}
}
}
}
use of jakarta.faces.lifecycle.Lifecycle 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();
}
use of jakarta.faces.lifecycle.Lifecycle in project mojarra by eclipse-ee4j.
the class LifecycleFactoryImpl method getLifecycle.
@Override
public Lifecycle getLifecycle(String lifecycleId) throws FacesException {
if (lifecycleId == null) {
throw new NullPointerException(MessageUtils.getExceptionMessageString(NULL_PARAMETERS_ERROR_MESSAGE_ID, "lifecycleId"));
}
if (lifecycleMap.get(lifecycleId) == null) {
Object[] params = { lifecycleId };
String message = MessageUtils.getExceptionMessageString(CANT_CREATE_LIFECYCLE_ERROR_MESSAGE_ID, params);
throw new IllegalArgumentException(message);
}
Lifecycle result = lifecycleMap.get(lifecycleId);
if (LOGGER.isLoggable(FINE)) {
LOGGER.fine("getLifecycle: " + lifecycleId + " " + result);
}
return result;
}
use of jakarta.faces.lifecycle.Lifecycle in project faces by jakartaee.
the class TestServlet method initFacesContext.
private FacesContext initFacesContext(HttpServletRequest request, HttpServletResponse response) {
LifecycleFactory lifeFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
Lifecycle lifecycle = lifeFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
FacesContextFactory facesFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
return facesFactory.getFacesContext(servletContext, request, response, lifecycle);
}
Aggregations