remm 01/05/30 20:53:58
Modified: catalina/src/share/org/apache/catalina/core
StandardContext.java
Log:
- The manager should be able to load classes from /WEB-INF/lib during start(),
stop() and reload().
- Filters will also be able to load classes from /WEB-INF/lib during stop().
Revision Changes Path
1.60 +55 -56
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java
Index: StandardContext.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- StandardContext.java 2001/05/16 17:56:04 1.59
+++ StandardContext.java 2001/05/31 03:53:49 1.60
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
1.59 2001/05/16 17:56:04 remm Exp $
- * $Revision: 1.59 $
- * $Date: 2001/05/16 17:56:04 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
1.60 2001/05/31 03:53:49 remm Exp $
+ * $Revision: 1.60 $
+ * $Date: 2001/05/31 03:53:49 $
*
* ====================================================================
*
@@ -141,7 +141,7 @@
*
* @author Craig R. McClanahan
* @author Remy Maucherat
- * @version $Revision: 1.59 $ $Date: 2001/05/16 17:56:04 $
+ * @version $Revision: 1.60 $ $Date: 2001/05/31 03:53:49 $
*/
public class StandardContext
@@ -2280,12 +2280,8 @@
// Stop accepting requests temporarily
setPaused(true);
- if (isUseNaming()) {
- try {
- ContextBindings.bindThread(this, this);
- } catch (NamingException e) {
- }
- }
+ // Binding thread
+ bindThread();
// Shut down the current version of all active servlets
Container children[] = findChildren();
@@ -2350,8 +2346,6 @@
}
}
- DirContextURLStreamHandler.bind(getResources());
-
// Restart our session manager (AFTER naming context recreated/bound)
if ((manager != null) && (manager instanceof Lifecycle)) {
try {
@@ -2375,16 +2369,6 @@
}
}
- if (isUseNaming()) {
- try {
- ContextBindings.bindThread(this, this);
- } catch (NamingException e) {
- log(sm.getString("standardContext.namingInitFailed",
- getName()));
- ok = false;
- }
- }
-
// Restart our currently defined servlets
for (int i = 0; i < children.length; i++) {
if (!ok)
@@ -2402,12 +2386,9 @@
}
}
- if (isUseNaming()) {
- ContextBindings.unbindThread(this, this);
- }
+ // Unbinding thread
+ unbindThread();
- DirContextURLStreamHandler.unbind();
-
// Start accepting requests again
if (ok) {
setPaused(false);
@@ -3177,6 +3158,8 @@
setManager(new StandardManager());
}
+ DirContextURLStreamHandler.bind(getResources());
+
// Initialize character set mapper
getCharsetMapper();
@@ -3211,7 +3194,8 @@
getServletContext().setAttribute
(Globals.RESOURCES_ATTR, getResources());
- DirContextURLStreamHandler.bind(getResources());
+ // Binding thread
+ bindThread();
// Configure and call application event listeners and filters
if (ok) {
@@ -3251,16 +3235,6 @@
list.add(wrapper);
}
- if (isUseNaming()) {
- try {
- ContextBindings.bindThread(this, this);
- } catch (NamingException e) {
- log(sm.getString("standardContext.namingInitFailed",
- getName()));
- ok = false;
- }
- }
-
// Load the collected "load on startup" servlets
if (debug >= 1)
log("Loading " + map.size() + " load-on-startup servlets");
@@ -3284,12 +3258,9 @@
}
}
}
-
- if (isUseNaming()) {
- ContextBindings.unbindThread(this, this);
- }
- DirContextURLStreamHandler.unbind();
+ // Unbinding thread
+ unbindThread();
if (ok) {
if (debug >= 1)
@@ -3316,19 +3287,13 @@
// Mark this application as unavailable while we shut down
setAvailable(false);
+ // Binding thread
+ bindThread();
+
// Stop our filters and application listeners
filterStop();
listenerStop();
- if (isUseNaming()) {
- try {
- ContextBindings.bindThread(this, this);
- } catch (NamingException e) {
- log(sm.getString("standardContext.namingInitFailed",
- getName()));
- }
- }
-
// Finalize our character set mapper
setCharsetMapper(null);
@@ -3337,9 +3302,8 @@
log("Processing standard container shutdown");
super.stop();
- if (isUseNaming()) {
- ContextBindings.unbindThread(this, this);
- }
+ // Unbinding thread
+ unbindThread();
if (debug >= 1)
log("Stopping complete");
@@ -3365,7 +3329,7 @@
}
- // -------------------------------------------------------- Private Methods
+ // ------------------------------------------------------ Protected Methods
/**
@@ -3432,6 +3396,41 @@
// -------------------------------------------------------- Private Methods
+
+
+ /**
+ * Bind current thread, both for CL purposes and for JNDI ENC support
+ * during : startup, shutdown and realoading of the context.
+ */
+ private void bindThread() {
+
+ DirContextURLStreamHandler.bind(getResources());
+
+ if (isUseNaming()) {
+ try {
+ ContextBindings.bindThread(this, this);
+ } catch (NamingException e) {
+ log(sm.getString("standardContext.namingInitFailed",
+ getName()));
+ }
+ }
+
+ }
+
+
+ /**
+ * Unbind thread.
+ */
+ private void unbindThread() {
+
+ if (isUseNaming()) {
+ ContextBindings.unbindThread(this, this);
+ }
+
+ DirContextURLStreamHandler.unbind();
+
+ }
+
/**