use of com.sun.faces.util.Timer in project mojarra by eclipse-ee4j.
the class DocumentOrderingWrapper method sort.
/**
* Sort the provided array of <code>Document</code>s per the requirements of the 2.0 specification. Note, that this
* method only provides partial ordering and not absolute ordering.
* @param documents the documents to sort
*/
public static void sort(DocumentOrderingWrapper[] documents) {
Timer t = Timer.getInstance();
if (t != null) {
t.startTiming();
}
try {
enhanceOrderingData(documents);
} catch (CircularDependencyException re) {
String msg = "Circular dependencies detected!\nDocument Info\n==================\n";
for (DocumentOrderingWrapper w : documents) {
msg += " " + w.toString() + '\n';
}
throw new ConfigurationException(msg);
}
// Sort the documents such that specified ordering will be considered.
//
// It turns out that some of the specified ordering, if it was not discovered by the sort routine
// until later in its processing, was not being considered correctly in the ordering algorithm.
//
// This preSort method puts all of the documents with specified ordering as early on in the
// list of documents as possible for Mojarra to consider it quickly, and be
// able to use its ordering algorithm to the best of its ability.
preSort(documents);
// original inner sort algorithm
int numberOfPasses = innerSort(documents);
// final sort
for (int i = 0; i < documents.length; i++) {
LinkedList<String> ids = getIds(documents);
if (done(documents, ids)) {
break;
}
}
if (t != null) {
t.stopTiming();
t.logResult("\"faces-config\" document sorting complete in " + numberOfPasses + '.');
}
}
use of com.sun.faces.util.Timer in project mojarra by eclipse-ee4j.
the class FindAnnotatedConfigClasses method call.
// ----------------------------------------------- Methods from Callable
@Override
public Map<Class<? extends Annotation>, Set<Class<?>>> call() throws Exception {
Timer t = Timer.getInstance();
if (t != null) {
t.startTiming();
}
// We are executing on a different thread.
facesContext.addInitContextEntryForCurrentThread();
Set<URI> scanUris = null;
com.sun.faces.spi.AnnotationScanner annotationScanner = metadataGetter.getAnnotationScanner();
// This is where we discover what kind of InjectionProvider we have.
if (provider instanceof FilterClassesFromFacesInitializerAnnotationProvider && annotationScanner != null) {
// This InjectionProvider is capable of annotation scanning *and* injection.
// Note that DelegatingAnnotationProvider itself doesn't use the provided scanner, but just uses the classes
// that were already scanned by the ServletContainerInitializer and stored there.
((FilterClassesFromFacesInitializerAnnotationProvider) provider).setAnnotationScanner(annotationScanner, metadataGetter.getJarNames(annotatedSet));
scanUris = emptySet();
} else {
// This InjectionProvider is capable of annotation scanning only
scanUris = metadataGetter.getAnnotationScanURIs(annotatedSet);
}
// Note that DelegatingAnnotationProvider itself ignores the scanUris and directly gets the classes from the
// ServletContext where they were stored by the ServletContainerInitializer
Map<Class<? extends Annotation>, Set<Class<?>>> annotatedClasses = provider.getAnnotatedClasses(scanUris);
if (t != null) {
t.stopTiming();
t.logResult("Configuration annotation scan complete.");
}
return annotatedClasses;
}
use of com.sun.faces.util.Timer in project mojarra by eclipse-ee4j.
the class ConfigureListener method contextInitialized.
// ------------------------------------------ ServletContextListener Methods
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
ServletContext servletContext = servletContextEvent.getServletContext();
Timer timer = Timer.getInstance();
if (timer != null) {
timer.startTiming();
}
ConfigManager configManager = ConfigManager.getInstance(servletContext);
if (configManager == null) {
configManager = ConfigManager.createInstance(servletContext);
}
if (configManager.hasBeenInitialized(servletContext)) {
return;
}
InitFacesContext initFacesContext = new InitFacesContext(servletContext);
LOGGER.log(FINE, () -> format("ConfigureListener.contextInitialized({0})", servletContext.getContextPath()));
webConfig = WebConfiguration.getInstance(servletContext);
// Check to see if the FacesServlet is present in the
// web.xml. If it is, perform faces configuration as normal,
// otherwise, simply return.
// If found by FacesInitializer.
Object facesServletRegistration = servletContext.getAttribute(FACES_SERVLET_REGISTRATION);
WebXmlProcessor webXmlProcessor = new WebXmlProcessor(servletContext);
if (facesServletRegistration == null) {
if (!webXmlProcessor.isFacesServletPresent()) {
if (!webConfig.isOptionEnabled(ForceLoadFacesConfigFiles)) {
LOGGER.log(FINE, "No FacesServlet found in deployment descriptor - bypassing configuration");
WebConfiguration.clear(servletContext);
configManager.destroy(servletContext, initFacesContext);
ConfigManager.removeInstance(servletContext);
InitFacesContext.cleanupInitMaps(servletContext);
return;
}
} else {
LOGGER.log(FINE, "FacesServlet found in deployment descriptor - processing configuration.");
}
}
if (webXmlProcessor.isDistributablePresent()) {
webConfig.setOptionEnabled(WebConfiguration.BooleanWebContextInitParameter.EnableDistributable, true);
servletContext.setAttribute(WebConfiguration.BooleanWebContextInitParameter.EnableDistributable.getQualifiedName(), TRUE);
}
// Bootstrap of faces required
webAppListener = new WebappLifecycleListener(servletContext);
webAppListener.contextInitialized(servletContextEvent);
ReflectionUtils.initCache(Thread.currentThread().getContextClassLoader());
Throwable caughtThrowable = null;
try {
if (LOGGER.isLoggable(INFO)) {
LOGGER.log(INFO, "faces.config.listener.version", servletContext.getContextPath());
}
if (webConfig.isOptionEnabled(VerifyFacesConfigObjects)) {
LOGGER.warning("JSF1059: WARNING! The com.sun.faces.verifyObjects feature is to aid developers not using tools. " + "It shouldn't be enabled if using an IDE, or if this application is being deployed for production as it " + "will impact application start times.");
// If we're verifying, force bean validation to occur at startup as well
webConfig.overrideContextInitParameter(EnableLazyBeanValidation, false);
Verifier.setCurrentInstance(new Verifier());
}
configManager.initialize(servletContext, initFacesContext);
if (shouldInitConfigMonitoring()) {
initConfigMonitoring(servletContext);
}
// Step 7, verify that all the configured factories are available
// and optionally that configured objects can be created.
Verifier verifier = Verifier.getCurrentInstance();
if (verifier != null && !verifier.isApplicationValid() && LOGGER.isLoggable(SEVERE)) {
LOGGER.severe("faces.config.verifyobjects.failures_detected");
StringBuilder sb = new StringBuilder(128);
for (String msg : verifier.getMessages()) {
sb.append(msg).append('\n');
}
LOGGER.severe(sb.toString());
}
ApplicationAssociate associate = ApplicationAssociate.getInstance(servletContext);
if (associate != null) {
associate.setExpressionFactory(ELManager.getExpressionFactory());
}
initFacesContext.setELContext(new ELContextImpl(initFacesContext));
if (associate != null) {
associate.setContextName(servletContext.getContextPath());
boolean isErrorPagePresent = webXmlProcessor.isErrorPagePresent();
associate.setErrorPagePresent(isErrorPagePresent);
servletContext.setAttribute(ERROR_PAGE_PRESENT_KEY_NAME, isErrorPagePresent);
}
// Note: websocket channel filter is registered in FacesInitializer.
if (webConfig.isOptionEnabled(EnableWebsocketEndpoint)) {
ServerContainer serverContainer = (ServerContainer) servletContext.getAttribute(ServerContainer.class.getName());
if (serverContainer == null) {
throw new UnsupportedOperationException("Cannot enable f:websocket." + " The current websocket container implementation does not support programmatically registering a container-provided endpoint.");
}
serverContainer.addEndpoint(ServerEndpointConfig.Builder.create(WebsocketEndpoint.class, URI_TEMPLATE).build());
}
webConfig.doPostBringupActions();
configManager.publishPostConfigEvent();
} catch (Throwable t) {
LOGGER.log(SEVERE, "Critical error during deployment: ", t);
caughtThrowable = t;
} finally {
servletContextEvent.getServletContext().removeAttribute(ANNOTATED_CLASSES);
servletContextEvent.getServletContext().removeAttribute(FACES_SERVLET_MAPPINGS);
Verifier.setCurrentInstance(null);
LOGGER.log(FINE, "faces.config.listener.version.complete");
if (timer != null) {
timer.stopTiming();
timer.logResult("Initialization of context " + servletContext.getContextPath());
}
if (caughtThrowable != null) {
throw new RuntimeException(caughtThrowable);
}
// Bug 20458755: The InitFacesContext was not being cleaned up, resulting in
// a partially constructed FacesContext being made available
// to other code that re-uses this Thread at init time.
initFacesContext.releaseCurrentInstance();
}
}
use of com.sun.faces.util.Timer in project mojarra by eclipse-ee4j.
the class Phase method doPhase.
// ---------------------------------------------------------- Public Methods
/**
* Performs PhaseListener processing and invokes the execute method of the Phase.
*
* @param context the FacesContext for the current request
* @param lifecycle the lifecycle for this request
*/
public void doPhase(FacesContext context, Lifecycle lifecycle, ListIterator<PhaseListener> listeners) {
context.setCurrentPhaseId(getId());
PhaseEvent event = null;
if (listeners.hasNext()) {
event = new PhaseEvent(context, getId(), lifecycle);
}
// start timing - include before and after phase processing
Timer timer = Timer.getInstance();
if (timer != null) {
timer.startTiming();
}
try {
handleBeforePhase(context, listeners, event);
if (!shouldSkip(context)) {
execute(context);
}
} catch (Throwable e) {
queueException(context, e);
} finally {
try {
handleAfterPhase(context, listeners, event);
} catch (Throwable e) {
queueException(context, e);
}
// stop timing
if (timer != null) {
timer.stopTiming();
timer.logResult("Execution time for phase (including any PhaseListeners) -> " + getId().toString());
}
context.getExceptionHandler().handle();
}
}
use of com.sun.faces.util.Timer in project mojarra by eclipse-ee4j.
the class ParseConfigResourceToDOMTask method call.
// ----------------------------------------------- Methods from Callable
/**
* @return the result of the parse operation (a DOM)
* @throws Exception if an error occurs during the parsing process
*/
@Override
public DocumentInfo call() throws Exception {
try {
Timer timer = Timer.getInstance();
if (timer != null) {
timer.startTiming();
}
Document document = getDocument();
if (timer != null) {
timer.stopTiming();
timer.logResult("Parse " + documentURI.toURL().toExternalForm());
}
return new DocumentInfo(document, documentURI);
} catch (Exception e) {
throw new ConfigurationException(format("Unable to parse document ''{0}'': {1}", documentURI.toURL().toExternalForm(), e.getMessage()), e);
}
}
Aggregations