Author: remy.maucherat(a)jboss.com
Date: 2009-05-15 12:25:46 -0400 (Fri, 15 May 2009)
New Revision: 1056
Modified:
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
Log:
- Fix the ordering fixmes. TLD processing should have no order.
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2009-05-15 02:45:56 UTC (rev 1055)
+++ trunk/java/org/apache/catalina/Context.java 2009-05-15 16:25:46 UTC (rev 1056)
@@ -66,6 +66,13 @@
public static final String RELOAD_EVENT = "reload";
+ /**
+ * The LifecycleEvent type sent to complete the configuration
+ * (called after running all listeners and other init callbacks).
+ */
+ public static final String COMPLETE_CONFIG_EVENT = "complete-config";
+
+
// ------------------------------------------------------------- Properties
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-05-15 02:45:56 UTC (rev
1055)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-05-15 16:25:46 UTC (rev
1056)
@@ -4127,7 +4127,16 @@
}
}
- // Start manager
+ if (ok) {
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(COMPLETE_CONFIG_EVENT, null);
+ }
+
+ if (!getConfigured()) {
+ ok = false;
+ }
+
+ // Start manager
if (ok && (manager != null) && (manager instanceof
Lifecycle)) {
ok = false;
((Lifecycle) getManager()).start();
@@ -4152,6 +4161,10 @@
loadOnStartup(findChildren());
}
+ } catch (Throwable t) {
+ // This can happen in rare cases with custom components
+ ok = false;
+ log.error(sm.getString("standardContext.startFailed", getName()),
t);
} finally {
// Unbinding thread
unbindThread(oldCCL);
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-15 02:45:56 UTC (rev
1055)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-15 16:25:46 UTC (rev
1056)
@@ -385,6 +385,25 @@
context.setDocBase(originalDocBase);
originalDocBase = docBase;
}
+ // Invoke Servlet container initializer: instantiate and call onStartup
+ if (ok) {
+ Iterator<ServletContainerInitializerInfo> initializers =
+ getServletContainerInitializerInfo().values().iterator();
+ while (initializers.hasNext()) {
+ ServletContainerInitializerInfo service = initializers.next();
+ try {
+ ServletContainerInitializer servletContainerInitializer =
+ (ServletContainerInitializer)
service.getServletContainerInitializer().newInstance();
+
servletContainerInitializer.onStartup(service.getStartupNotifySet(),
context.getServletContext());
+ } catch (Throwable t) {
+
log.error(sm.getString("contextConfig.servletContainerInitializer",
+ service.getServletContainerInitializer().getName()), t);
+ ok = false;
+ }
+ }
+ }
+ } else if (event.getType().equals(Context.COMPLETE_CONFIG_EVENT)) {
+ completeConfig();
} else if (event.getType().equals(Lifecycle.STOP_EVENT)) {
if (originalDocBase != null) {
String docBase = context.getDocBase();
@@ -569,7 +588,7 @@
}
- // FIXME: Do TLD parsing when found
+ // FIXME: Do TLD parsing when found ? (clarification from EG states there's no
order)
protected void applicationTldConfig() {
// Add all TLDs from explicit web config
@@ -1356,7 +1375,8 @@
}
servletContainerInitializerClassName =
servletContainerInitializerClassName.trim();
} catch (Exception e) {
- // FIXME: error message or exception
+
log.warn(sm.getString("contextConfig.servletContainerInitializer",
file.getName()), e);
+ return;
} finally {
try {
if (is != null) {
@@ -1378,7 +1398,8 @@
typesArray = handlesTypes.value();
}
} catch (Throwable t) {
- // FIXME: error message or exception
+
log.warn(sm.getString("contextConfig.servletContainerInitializer",
file.getName()), t);
+ return;
}
}
// Add in jarService map, and add in the local map used to speed up lookups
@@ -1765,49 +1786,7 @@
if (ok) {
applicationTldConfig();
}
- // Scan all Servlet API related annotations
- if (ok && !context.getIgnoreAnnotations()) {
- // FIXME: Moved to after running all listeners, as they can add servlets or
filters
- WebAnnotationSet.loadApplicationAnnotations(context);
- }
- if (ok) {
- validateSecurityRoles();
- }
- // Find webapp overlays
- if (ok) {
- JarRepository jarRepository = context.getJarRepository();
- JarFile[] jars = jarRepository.findJars();
- for (int i = 0; i < jars.length; i++) {
- if (jars[i].getEntry(Globals.OVERLAY_PATH) != null) {
- overlays.add(jars[i].getName());
- }
- }
- }
-
- // Invoke Servlet container initializer: instantiate and call onStartup
- if (ok) {
- Iterator<ServletContainerInitializerInfo> initializers =
- getServletContainerInitializerInfo().values().iterator();
- while (initializers.hasNext()) {
- ServletContainerInitializerInfo service = initializers.next();
- try {
- ServletContainerInitializer servletContainerInitializer =
- (ServletContainerInitializer)
service.getServletContainerInitializer().newInstance();
- servletContainerInitializer.onStartup(service.getStartupNotifySet(),
context.getServletContext());
- } catch (Throwable t) {
-
log.error(sm.getString("contextConfig.servletContainerInitializer",
- service.getServletContainerInitializer()), t);
- ok = false;
- }
- }
- }
-
- // Configure an authenticator if we need one
- if (ok) {
- authenticatorConfig();
- }
-
// Dump the contents of this pipeline if requested
if ((log.isDebugEnabled()) && (context instanceof ContainerBase)) {
log.debug("Pipeline Configuration:");
@@ -1833,7 +1812,44 @@
}
+ /**
+ * Process a "start" event for this Context.
+ */
+ protected void completeConfig() {
+ // Called from StandardContext.start()
+ // Scan all Servlet API related annotations
+ if (ok && !context.getIgnoreAnnotations()) {
+ WebAnnotationSet.loadApplicationAnnotations(context);
+ }
+ if (ok) {
+ validateSecurityRoles();
+ }
+
+ // Configure an authenticator if we need one
+ if (ok) {
+ authenticatorConfig();
+ }
+
+ // Find and configure webapp overlays
+ if (ok) {
+ JarRepository jarRepository = context.getJarRepository();
+ JarFile[] jars = jarRepository.findJars();
+ for (int i = 0; i < jars.length; i++) {
+ if (jars[i].getEntry(Globals.OVERLAY_PATH) != null) {
+ overlays.add(jars[i].getName());
+ }
+ }
+ }
+
+ // Make our application available if no problems were encountered
+ if (!ok) {
+ log.error(sm.getString("contextConfig.unavailable"));
+ context.setConfigured(false);
+ }
+
+ }
+
/**
* Process a "stop" event for this Context.
*/
Show replies by date