You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@locus.apache.org on 2000/02/09 21:36:12 UTC
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/servlets InvokerServlet.java
costin 00/02/09 12:36:12
Modified: src/share/org/apache/jasper/runtime TomcatServletEngine.java
src/share/org/apache/tomcat/context AutoSetup.java
BaseContextInterceptor.java DefaultCMSetter.java
src/share/org/apache/tomcat/core Context.java
ContextInterceptor.java ContextManager.java
src/share/org/apache/tomcat/loader AdaptiveClassLoader.java
ServletClassLoaderImpl.java
src/share/org/apache/tomcat/service/connector
Ajp12ConnectionHandler.java
src/share/org/apache/tomcat/servlets InvokerServlet.java
Log:
- Added engine start/stop and context add/remove notifications to
ContextInterceptor
- Removed exit() from ContextManger.stop(). It is now part of Ajp12 ( and
will be implemented in the "Web connector API", since it's used to control
shutdown from the web server)
- Removed Context.getClassLoader() - no code sets it up and it was
very unclear what it does. Equivalent functionality will be part of
the ServletLoader interface.
- Removed Context.loadServlet() - it is equivalent to new ServletWrapper()
and addServlet(). The original function didn't load anything anyway.
- Added a XXX to AdaptiveClassLoader - that portion of code is specific to
JServ, but it shoulnd't affect us too much.
Revision Changes Path
1.3 +4 -4 jakarta-tomcat/src/share/org/apache/jasper/runtime/TomcatServletEngine.java
Index: TomcatServletEngine.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/TomcatServletEngine.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TomcatServletEngine.java 1999/10/15 00:35:32 1.2
+++ TomcatServletEngine.java 2000/02/09 20:36:09 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/TomcatServletEngine.java,v 1.2 1999/10/15 00:35:32 akv Exp $
- * $Revision: 1.2 $
- * $Date: 1999/10/15 00:35:32 $
+ * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/TomcatServletEngine.java,v 1.3 2000/02/09 20:36:09 costin Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/02/09 20:36:09 $
*
* ====================================================================
*
@@ -72,6 +72,6 @@
*/
public class TomcatServletEngine extends ServletEngine {
public ClassLoader getClassLoader(ServletContext ctx) {
- return ((ServletContextFacade) ctx).getRealContext().getClassLoader();
+ return null;// XXX (ClassLoader)((ServletContextFacade) ctx).getRealContext().getLoader();
}
}
1.3 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/context/AutoSetup.java
Index: AutoSetup.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/AutoSetup.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AutoSetup.java 2000/02/08 18:50:43 1.2
+++ AutoSetup.java 2000/02/09 20:36:09 1.3
@@ -84,7 +84,7 @@
public AutoSetup() {
}
- public int handleContextManagerInit(ContextManager cm) {
+ public int engineInit(ContextManager cm) {
String home=cm.getHome();
File webappD=new File(home + "/webapps");
if (! webappD.exists() || ! webappD.isDirectory())
1.3 +27 -0 jakarta-tomcat/src/share/org/apache/tomcat/context/BaseContextInterceptor.java
Index: BaseContextInterceptor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/BaseContextInterceptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BaseContextInterceptor.java 2000/02/08 23:52:46 1.2
+++ BaseContextInterceptor.java 2000/02/09 20:36:09 1.3
@@ -107,5 +107,32 @@
return 0;
}
+ /** Called when the ContextManger is started
+ */
+ public int engineInit(ContextManager cm) {
+ return 0;
+ }
+
+ /** Called before the ContextManager is stoped.
+ * You need to stop any threads and remove any resources.
+ */
+ public int engineShutdown(ContextManager cm) {
+ return 0;
+ }
+
+
+ /** Called when a context is added to a CM
+ */
+ public int addContext( ContextManager cm, Context ctx ) {
+ return 0;
+ }
+
+ /** Called when a context is removed from a CM
+ */
+ public int removeContext( ContextManager cm, Context ctx ) {
+ return 0;
+ }
+
+
}
1.4 +6 -13 jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java
Index: DefaultCMSetter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/DefaultCMSetter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultCMSetter.java 2000/02/08 23:52:46 1.3
+++ DefaultCMSetter.java 2000/02/09 20:36:09 1.4
@@ -75,12 +75,12 @@
*
* @author costin@dnt.ro
*/
-public class DefaultCMSetter { // implements TomcatHandler
+public class DefaultCMSetter extends BaseContextInterceptor {
public DefaultCMSetter() {
}
- public int handleContextManagerInit(ContextManager cm) throws TomcatException {
+ public int engineInit(ContextManager cm) {
// set a default connector ( http ) if none defined yet
Enumeration conn=cm.getConnectors();
if( ! conn.hasMoreElements() ) {
@@ -88,14 +88,7 @@
cm.addServerConnector( new org.apache.tomcat.service.http.HttpAdapter() );
}
- // Verify default context
- Context defaultContext=cm.getContext("");
- if (defaultContext == null ||
- defaultContext.getDocumentBase() == null) {
- throw new TomcatException("No default context " + defaultContext);
- }
-
- Enumeration riE=cm.getRequestInterceptors();
+ Enumeration riE=cm.getRequestInterceptors();
if( ! riE.hasMoreElements() ) {
// nothing set up by starter, add default ones
if(cm.getDebug()>0) cm.log("Setting default interceptors ");
@@ -147,14 +140,14 @@
ctx.addContextInterceptor(new LoadOnStartupInterceptor());
}
- // XXX Loader properties - need to be set on loader!!
ctx.addClassPath("WEB-INF/classes");
ctx.addLibPath("WEB-INF/lib");
+ // XXX Loader properties - need to be set on loader!!
if(ctx.getLoader() == null) {
- ctx.setLoader( new org.apache.tomcat.loader.ServletClassLoaderImpl(ctx));
+ ctx.setLoader( new org.apache.tomcat.loader.ServletClassLoaderImpl());
+ // ctx.setLoader( new org.apache.tomcat.loader.AdaptiveServletLoader());
}
-
return 0;
}
1.41 +0 -35 jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
Index: Context.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- Context.java 2000/02/08 23:52:47 1.40
+++ Context.java 2000/02/09 20:36:10 1.41
@@ -121,7 +121,6 @@
private boolean isWARValidated = false;
// Class Loading
- // XXX Nobody sets it private ClassLoader classLoader;
private String classPath = ""; // classpath used by the classloader.
private Vector classPaths = new Vector();
private Vector libPaths = new Vector();
@@ -850,25 +849,6 @@
return (ServletWrapper)servlets.get(servletName);
}
- /** @deprecated Create a ServletWrapper and add it.
- This allows you to set other Wrapper properties
- */
- public ServletWrapper loadServlet(String servletClassName) {
- // XXX
- // check for duplicates!
-
- // XXX
- // maybe dispatch to addServlet?
-
- ServletWrapper wrapper = new ServletWrapper(this);
-
- wrapper.setServletClass(servletClassName);
-
- servlets.put(servletClassName, wrapper);
-
- return wrapper;
- }
-
/**
* Add a servlet with the given name to the container. The
* servlet will be loaded by the container's class loader
@@ -951,21 +931,6 @@
}
// -------------------- Class Loading --------------------
-
- // XXX I have no ideea how it works !
- // Used by JSP and loader
- /** ClassLoader used to load this servlet.
- */
- public ClassLoader getClassLoader() {
- // Doesn't work: return (ClassLoader)servletLoader;
-
- // ClassLoader is allways null, nobody sets it
- return null;
- }
-
- // public void setClassLoader(ClassLoader classLoader) {
- // this.classLoader = classLoader;
- // }
public void setLoader(ServletClassLoader loader ) {
this.servletLoader=loader;
1.4 +30 -5 jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java
Index: ContextInterceptor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ContextInterceptor.java 2000/02/08 23:52:47 1.3
+++ ContextInterceptor.java 2000/02/09 20:36:10 1.4
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java,v 1.3 2000/02/08 23:52:47 costin Exp $
- * $Revision: 1.3 $
- * $Date: 2000/02/08 23:52:47 $
+ * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextInterceptor.java,v 1.4 2000/02/09 20:36:10 costin Exp $
+ * $Revision: 1.4 $
+ * $Date: 2000/02/09 20:36:10 $
*
* ====================================================================
*
@@ -66,7 +66,8 @@
import javax.servlet.Servlet;
/**
- * Called to set up and destroy a context.
+ * Notifications for all context events.
+ *
* Example: expand WAR, move files in the right directories ( Apache ?),
* read web.xml or check for a serialized form for faster init, etc.
*
@@ -74,11 +75,35 @@
*/
public interface ContextInterceptor {
public static final int OK=0;
+
+ /** Called when the ContextManger is started
+ */
+ public int engineInit(ContextManager cm);
+
+ /** Called before the ContextManager is stoped.
+ * You need to stop any threads and remove any resources.
+ */
+ public int engineShutdown(ContextManager cm);
+
+
+ /** Called when a context is added to a CM
+ */
+ public int addContext( ContextManager cm, Context ctx );
+
+ /** Called when a context is removed from a CM
+ */
+ public int removeContext( ContextManager cm, Context ctx );
+
+ /** Notification when a context is initialized
+ */
public int contextInit(Context ctx);
-
+
+ /** Called when a context is stoped.
+ */
public int contextShutdown(Context ctx);
+
/** Notify when a new servlet is added
*/
public int addServlet( Context ctx, ServletWrapper sw);
1.35 +6 -7 jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
Index: ContextManager.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- ContextManager.java 2000/02/08 23:52:47 1.34
+++ ContextManager.java 2000/02/09 20:36:10 1.35
@@ -136,11 +136,13 @@
}
public void init() throws TomcatException {
-
long time=System.currentTimeMillis();
- (new AutoSetup()).handleContextManagerInit(this);
+
+ (new DefaultCMSetter()).engineInit(this);
+
+
+ (new AutoSetup()).engineInit(this);
// Initialize and check Context Manager
- (new DefaultCMSetter()).handleContextManagerInit(this);
// init contexts
Enumeration enum = getContextNames();
@@ -148,6 +150,7 @@
Context context = getContext((String)enum.nextElement());
context.init();
}
+
System.out.println("Init time " + ( System.currentTimeMillis() - time ));
@@ -190,10 +193,6 @@
context.shutdown();
}
- // same behavior as in past, because it seems that
- // stopping everything doesn't work - need to figure
- // out what happens with the threads ( XXX )
- System.exit(0);
}
/**
1.3 +2 -1 jakarta-tomcat/src/share/org/apache/tomcat/loader/AdaptiveClassLoader.java
Index: AdaptiveClassLoader.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/loader/AdaptiveClassLoader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AdaptiveClassLoader.java 2000/02/08 20:37:14 1.2
+++ AdaptiveClassLoader.java 2000/02/09 20:36:11 1.3
@@ -116,7 +116,7 @@
* @author Martin Pool
* @author Jim Heintz
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version $Revision: 1.2 $ $Date: 2000/02/08 20:37:14 $
+ * @version $Revision: 1.3 $ $Date: 2000/02/09 20:36:11 $
* @see java.lang.ClassLoader
*/
public class AdaptiveClassLoader extends ClassLoader {
@@ -618,6 +618,7 @@
s = loadResourceFromDirectory(file, name);
}
else if(name.endsWith(".initArgs")) {
+ // XXX XXX XXX What is this ?
File dir = new File(file.getParent());
s = loadResourceFromDirectory(dir, name);
} else {
1.5 +4 -3 jakarta-tomcat/src/share/org/apache/tomcat/loader/ServletClassLoaderImpl.java
Index: ServletClassLoaderImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/loader/ServletClassLoaderImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServletClassLoaderImpl.java 2000/02/08 21:53:52 1.4
+++ ServletClassLoaderImpl.java 2000/02/09 20:36:11 1.5
@@ -66,7 +66,7 @@
/**
* This class now extends NetworkClassLoader. Previous
- * implementation of ServletClassLoader was called ServletLoader.
+ * implementation of GenericClassLoader was called ServletLoader.
* This implementation is a complete rewrite of the earlier
* class loader. This should speed up performance compared
* to the earlier class loader.
@@ -81,7 +81,8 @@
private Context context;
public ServletClassLoaderImpl(Context context) {
- super(context.getClassLoader());
+ super(null);
+ // XXX Hangs up: super((ClassLoader)context.getLoader());
this.context = context;
initURLs();
}
@@ -141,7 +142,7 @@
throws ClassNotFoundException {
// This is a bad idea. Unfortunately the class loader may
// be set on the context at any point.
- setParent(context.getClassLoader());
+ setParent(null); // XXX that hangs up tomcat: (ClassLoader)context.getLoader());
return super.loadClass(name, resolve);
}
1.12 +5 -0 jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp12ConnectionHandler.java
Index: Ajp12ConnectionHandler.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp12ConnectionHandler.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Ajp12ConnectionHandler.java 2000/02/03 23:05:27 1.11
+++ Ajp12ConnectionHandler.java 2000/02/09 20:36:11 1.12
@@ -293,6 +293,11 @@
if ( signal== 15 ) {
// Shutdown - probably apache was stoped with apachectl stop
contextM.stop();
+ // same behavior as in past, because it seems that
+ // stopping everything doesn't work - need to figure
+ // out what happens with the threads ( XXX )
+ System.exit(0);
+
shutdown=true;
return;
}
1.3 +21 -9 jakarta-tomcat/src/share/org/apache/tomcat/servlets/InvokerServlet.java
Index: InvokerServlet.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/servlets/InvokerServlet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InvokerServlet.java 2000/01/12 19:54:03 1.2
+++ InvokerServlet.java 2000/02/09 20:36:12 1.3
@@ -172,22 +172,34 @@
}
// try the easy one -- lookup by name
-
+
ServletWrapper wrapper = context.getServletByName(servletName);
+ // System.out.println("Invoker: getServletByName " + servletName + "=" + wrapper);
if (wrapper == null) {
- // try the more forceful approach
+ // Moved loadServlet here //loadServlet(servletName);
+ wrapper = new ServletWrapper();
+ wrapper.setContext(context);
+ wrapper.setServletClass(servletName);
+ wrapper.setServletName(servletName); // XXX it can create a conflict !
+
+ context.addServlet( wrapper );
- wrapper = context.loadServlet(servletName);
- }
+ // XXX add mapping - if the engine supports dynamic changes in mappings,
+ // we'll avoid the extra parsing in Invoker !!!
- if (wrapper == null) {
- // we are out of luck
+ // XXX Invoker can be avoided easily - it's a special mapping, easy to
+ // support
+ }
- doError(response, "Wrapper is null - " + servletName);
+
- return;
- }
+ // Can't be null - loadServlet creates a new wrapper .
+ // if (wrapper == null) {
+ // // we are out of luck
+ // doError(response, "Wrapper is null - " + servletName);
+ // return;
+ // }
HttpServletRequestFacade requestfacade =
(HttpServletRequestFacade)request;