use of jakarta.faces.lifecycle.LifecycleFactory in project myfaces by apache.
the class FacesServlet method init.
@Override
public void init(ServletConfig servletConfig) throws ServletException {
if (log.isLoggable(Level.FINEST)) {
log.finest("init begin");
}
_servletConfig = servletConfig;
_facesContextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
// Javadoc says: Lifecycle instance is shared across multiple simultaneous requests, it must be implemented in a
// thread-safe manner.
// So we can acquire it here once:
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
_lifecycle = lifecycleFactory.getLifecycle(getLifecycleId());
if (log.isLoggable(Level.FINEST)) {
log.finest("init end");
}
}
use of jakarta.faces.lifecycle.LifecycleFactory in project myfaces by apache.
the class UIViewRoot method createEvent.
private PhaseEvent createEvent(FacesContext context, PhaseId phaseId) {
if (_lifecycle == null) {
LifecycleFactory factory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
String id = context.getExternalContext().getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR);
if (id == null) {
id = LifecycleFactory.DEFAULT_LIFECYCLE;
}
_lifecycle = factory.getLifecycle(id);
}
return new PhaseEvent(context, phaseId, _lifecycle);
}
use of jakarta.faces.lifecycle.LifecycleFactory in project mojarra by eclipse-ee4j.
the class DefaultActionResponseHandler method getDefaultLifecycle.
/**
* Get the default lifecycle.
*
* <p>
* FIXME - This method lazily gets the default Lifecycle as FactoryFinder is
* not properly re-entrant. We should be able to initialize the
* defaultLifecycle variable in the constructor of this class.
* </p>
*
* @return the default lifecycle.
*/
private synchronized Lifecycle getDefaultLifecycle() {
if (defaultLifecycle == null) {
LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
defaultLifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
}
return defaultLifecycle;
}
use of jakarta.faces.lifecycle.LifecycleFactory in project mojarra by eclipse-ee4j.
the class LifecycleConfigProcessor method process.
// -------------------------------------------- Methods from ConfigProcessor
@Override
public void process(ServletContext servletContext, FacesContext facesContext, DocumentInfo[] documentInfos) throws Exception {
LifecycleFactory factory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
for (int i = 0; i < documentInfos.length; i++) {
if (LOGGER.isLoggable(FINE)) {
LOGGER.log(FINE, format("Processing lifecycle elements for document: ''{0}''", documentInfos[i].getSourceURI()));
}
Document document = documentInfos[i].getDocument();
String namespace = document.getDocumentElement().getNamespaceURI();
NodeList lifecycles = document.getElementsByTagNameNS(namespace, LIFECYCLE);
if (lifecycles != null) {
for (int c = 0, csize = lifecycles.getLength(); c < csize; c++) {
Node lifecyleNode = lifecycles.item(c);
if (lifecyleNode.getNodeType() == Node.ELEMENT_NODE) {
NodeList listeners = ((Element) lifecyleNode).getElementsByTagNameNS(namespace, PHASE_LISTENER);
addPhaseListeners(servletContext, facesContext, factory, listeners);
}
}
}
}
}
use of jakarta.faces.lifecycle.LifecycleFactory in project mojarra by eclipse-ee4j.
the class JUnitFacesTestCaseBase method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
// Set up Servlet API Objects
servletContext = new MockServletContext();
servletContext.addInitParameter("appParamName", "appParamValue");
servletContext.setAttribute("appScopeName", "appScopeValue");
config = new MockServletConfig(servletContext);
session = new MockHttpSession();
session.setAttribute("sesScopeName", "sesScopeValue");
request = new MockHttpServletRequest(session);
request.setAttribute("reqScopeName", "reqScopeValue");
response = new MockHttpServletResponse();
// Set up Faces API Objects
FactoryFinder.releaseFactories();
Method reInitializeFactoryManager = FactoryFinder.class.getDeclaredMethod("reInitializeFactoryManager", (Class<?>[]) null);
reInitializeFactoryManager.setAccessible(true);
reInitializeFactoryManager.invoke(null, (Object[]) null);
// Create something to stand-in as the InitFacesContext
new MockFacesContext(new MockExternalContext(servletContext, request, response), new MockLifecycle());
FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY, "com.sun.faces.mock.MockFacesContextFactory");
FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY, "com.sun.faces.mock.MockLifecycleFactory");
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY, "com.sun.faces.mock.MockApplicationFactory");
FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY, "com.sun.faces.mock.MockRenderKitFactory");
FacesContextFactory fcFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
LifecycleFactory lFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
lifecycle = (MockLifecycle) lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
facesContext = (MockFacesContext) fcFactory.getFacesContext(servletContext, request, response, lifecycle);
externalContext = (MockExternalContext) facesContext.getExternalContext();
Map map = new HashMap();
externalContext.setRequestParameterMap(map);
ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
application = (MockApplication) applicationFactory.getApplication();
facesContext.setApplication(application);
}
Aggregations