costin 00/08/14 11:40:35
Modified: src/share/org/apache/tomcat/context LoaderInterceptor1.java
src/share/org/apache/tomcat/core Context.java
src/share/org/apache/tomcat/request ReloadInterceptor.java
src/share/org/apache/tomcat/service/http
HttpResponseAdapter.java
src/share/org/apache/tomcat/util URLUtil.java
Added: src/share/org/apache/tomcat/util/depend
DependClassLoader.java DependManager.java
Dependency.java package.html
Removed: src/share/org/apache/tomcat/depend DependClassLoader.java
DependManager.java Dependency.java package.html
src/share/org/apache/tomcat/protocol WARConnection.java
WARManager.java
src/share/org/apache/tomcat/protocol/jar Handler.java
src/share/org/apache/tomcat/protocol/war Handler.java
src/share/org/apache/tomcat/util BufferEvent.java
BufferListener.java ByteBuffer.java Queue.java
WARUtil.java
Log:
Removed unused code.
Moved depend to tomcat/util ( it's independent of tomcat, all general utils should
be in the same package )
Revision Changes Path
1.4 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/context/LoaderInterceptor1.java
Index: LoaderInterceptor1.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/context/LoaderInterceptor1.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LoaderInterceptor1.java 2000/07/28 17:21:30 1.3
+++ LoaderInterceptor1.java 2000/08/14 18:40:29 1.4
@@ -64,7 +64,7 @@
import org.apache.tomcat.core.Constants;
import org.apache.tomcat.request.*;
import org.apache.tomcat.util.*;
-import org.apache.tomcat.depend.*;
+import org.apache.tomcat.util.depend.*;
import java.io.*;
import java.net.*;
import java.util.*;
1.109 +1 -1 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.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- Context.java 2000/08/14 17:49:12 1.108
+++ Context.java 2000/08/14 18:40:30 1.109
@@ -62,7 +62,7 @@
import org.apache.tomcat.context.*;
import org.apache.tomcat.facade.*;
-import org.apache.tomcat.depend.*;
+import org.apache.tomcat.util.depend.*;
import org.apache.tomcat.util.*;
import java.security.*;
import java.lang.reflect.*;
1.3 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/request/ReloadInterceptor.java
Index: ReloadInterceptor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/request/ReloadInterceptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ReloadInterceptor.java 2000/07/28 17:21:40 1.2
+++ ReloadInterceptor.java 2000/08/14 18:40:33 1.3
@@ -62,7 +62,7 @@
import org.apache.tomcat.core.*;
import org.apache.tomcat.util.*;
-import org.apache.tomcat.depend.*;
+import org.apache.tomcat.util.depend.*;
import java.io.*;
import java.net.*;
import java.util.*;
1.16 +5 -6 jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpResponseAdapter.java
Index: HttpResponseAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpResponseAdapter.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- HttpResponseAdapter.java 2000/08/12 04:55:48 1.15
+++ HttpResponseAdapter.java 2000/08/14 18:40:33 1.16
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpResponseAdapter.java,v
1.15 2000/08/12 04:55:48 costin Exp $
- * $Revision: 1.15 $
- * $Date: 2000/08/12 04:55:48 $
+ * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpResponseAdapter.java,v
1.16 2000/08/14 18:40:33 costin Exp $
+ * $Revision: 1.16 $
+ * $Date: 2000/08/14 18:40:33 $
*
* ====================================================================
*
@@ -200,7 +200,6 @@
}
buffer[bufferCount] = (byte)c;
bufferCount++;
- }
- }
-
+ }
+ }
}
1.8 +11 -49 jakarta-tomcat/src/share/org/apache/tomcat/util/URLUtil.java
Index: URLUtil.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/URLUtil.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- URLUtil.java 2000/05/01 23:07:48 1.7
+++ URLUtil.java 2000/08/14 18:40:34 1.8
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/URLUtil.java,v 1.7
2000/05/01 23:07:48 costin Exp $
- * $Revision: 1.7 $
- * $Date: 2000/05/01 23:07:48 $
+ * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/URLUtil.java,v 1.8
2000/08/14 18:40:34 costin Exp $
+ * $Revision: 1.8 $
+ * $Date: 2000/08/14 18:40:34 $
*
* ====================================================================
*
@@ -76,7 +76,7 @@
public class URLUtil {
- public static URL resolve(String s)
+ public static URL resolve(String s, String baseDir)
throws MalformedURLException
{
URL resolve = null;
@@ -98,10 +98,10 @@
// } else if (url != null) {
// resolve = new URL(url, s);
} else if (s.startsWith(File.separator) ||
- s.startsWith("/") ||
- (s.length() >= 2 &&
- Character.isLetter(s.charAt(0)) &&
- s.charAt(1) == ':')) {
+ s.startsWith("/") ||
+ (s.length() >= 2 &&
+ Character.isLetter(s.charAt(0)) &&
+ s.charAt(1) == ':')) {
String fName = s;
try {
@@ -112,42 +112,16 @@
resolve = new URL("file", "", fName);
} else {
- String path = System.getProperty("user.dir") +
- File.separator + s;
+ String path = (baseDir.endsWith("/")) ?
+ baseDir + s :
+ baseDir + File.separator + s;
resolve = new URL("file", "", path);
}
- if (! resolve.getProtocol().equalsIgnoreCase("war") &&
- resolve.getFile().toLowerCase().endsWith(
- "." + "war")) {
- URL u = new URL("war" + ":" +
- resolve.toString());
-
- resolve = u;
- }
-
- resolve = new URL(trim(resolve.toString(), ".", ".."));
- resolve = new URL(trim(resolve.toString(), "./"));
-
return resolve;
}
- private static String trim(String s, String t) {
- return trim(s, t, null);
- }
-
- private static String trim(String s, String r, String t) {
- while (s.endsWith(r) &&
- ((t == null) ? true : (! s.endsWith(t)))) {
- int i = s.length() - r.length();
-
- s = s.substring(0, i);
- }
-
- return s;
- }
-
public static String removeLast( String s) {
int i = s.lastIndexOf("/");
@@ -159,18 +133,6 @@
s = "";
}
return s;
- }
-
- public static String getFirst( String path ) {
- if (path.startsWith("/"))
- path = path.substring(1);
-
- int i = path.indexOf("/");
- if (i > -1) {
- path = path.substring(0, i);
- }
-
- return "/" + path;
}
public static String getExtension( String path ) {
1.1 jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependClassLoader.java
Index: DependClassLoader.java
===================================================================
/*
* Copyright (c) 1997-1999 The Java Apache Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Java Apache
* Project for use in the Apache JServ servlet engine project
* <http://java.apache.org/>."
*
* 4. The names "Apache JServ", "Apache JServ Servlet Engine" and
* "Java Apache Project" must not be used to endorse or promote products
* derived from this software without prior written permission.
*
* 5. Products derived from this software may not be called "Apache JServ"
* nor may "Apache" nor "Apache JServ" appear in their names without
* prior written permission of the Java Apache Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Java Apache
* Project for use in the Apache JServ servlet engine project
* <http://java.apache.org/>."
*
* THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Java Apache Group. For more information
* on the Java Apache Project and the Apache JServ Servlet Engine project,
* please see <http://java.apache.org/>.
*
*/
package org.apache.tomcat.util.depend;
import java.io.*;
import java.lang.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.util.zip.*;
import java.security.*;
/**
* This is a wrapper class loader that will delegate all calls to
* the parent. It will also generate events for every loaded class,
* for use in maintaining dependencies.
*
* In order to keep this generic we'll use findResource() to find the
* source of the class, and then forward to the class loader - that
* means we duplicate the search operation.
*
* Class loading happens only once per request, and this will have probably
* little effect.
* Also, the alternative is to use custom class loaders - there are many
* reasons to avoid this.
*
* In "production" sites reloading should be turned off anyway, so the
* class loader will not be "wrapped"
*
*/
public class DependClassLoader extends ClassLoader {
protected ClassLoader parent;
final static int debug=0;
DependManager dependM;
public DependClassLoader( DependManager depM, ClassLoader parent ) {
super(); // will check permissions
this.parent=parent;
dependM=depM;
}
// debug only
final void log( String s ) {
System.out.println("DependClassLoader: " + s );
}
/**
* Resolves the specified name to a Class. The method loadClass()
* is called by the virtual machine. As an abstract method,
* loadClass() must be defined in a subclass of ClassLoader.
*
* @param name the name of the desired Class.
* @param resolve true if the Class needs to be resolved;
* false if the virtual machine just wants to determine
* whether the class exists or not
* @return the resulting Class.
* @exception ClassNotFoundException if the class loader cannot
* find a the requested class.
*/
protected synchronized Class loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
if( debug>0) log( "loadClass() " + name + " " + resolve);
// The class object that will be returned.
Class c = null;
// check if we already loaded this class
c = findLoadedClass( name );
if (c!= null ) {
if(resolve) resolveClass(c);
return c;
}
String classFileName = name.replace('.', '/' ) + ".class";
URL res=getResource( classFileName );
if( res==null ) {
if( debug >0 ) log( "Resource not found !!! " + name + " " + classFileName);
}
try {
c = parent.loadClass(name);
if (c != null) {
if (resolve) resolveClass(c);
dependency( c, res );
return c;
}
} catch (Exception e) {
c = null;
}
throw new ClassNotFoundException(name);
}
public URL getResource(String name) {
return parent.getResource(name);
}
public InputStream getResourceAsStream(String name) {
return parent.getResourceAsStream( name );
}
private void dependency( Class c, URL res ) {
if( res==null) return;
File f=null;
if( "file".equals( res.getProtocol() )) {
f=new File( res.getFile());
if( debug > 0 ) log( "File dep " +f );
if( ! f.exists()) f=null;
}
if( "jar".equals( res.getProtocol() )) {
String fileN=res.getFile();
int idx=fileN.indexOf( "!" );
if( idx>=0 )
fileN=fileN.substring( 0, idx) ;
f=new File( fileN );
if( debug > 0 ) log( "Jar dep " +f );
if( ! f.exists()) f=null;
}
if( f==null ) return;
Dependency dep=new Dependency();
dep.setLastModified( System.currentTimeMillis() );
dep.setTarget( c );
dep.setOrigin( f );
dependM.addDependency( dep );
}
}
1.1 jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependManager.java
Index: DependManager.java
===================================================================
/*
* Copyright (c) 1997-1999 The Java Apache Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Java Apache
* Project for use in the Apache JServ servlet engine project
* <http://java.apache.org/>."
*
* 4. The names "Apache JServ", "Apache JServ Servlet Engine" and
* "Java Apache Project" must not be used to endorse or promote products
* derived from this software without prior written permission.
*
* 5. Products derived from this software may not be called "Apache JServ"
* nor may "Apache" nor "Apache JServ" appear in their names without
* prior written permission of the Java Apache Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Java Apache
* Project for use in the Apache JServ servlet engine project
* <http://java.apache.org/>."
*
* THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Java Apache Group. For more information
* on the Java Apache Project and the Apache JServ Servlet Engine project,
* please see <http://java.apache.org/>.
*
*/
package org.apache.tomcat.util.depend;
import java.io.*;
import java.lang.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.util.zip.*;
import java.security.*;
/** How it works:
- A DependManager gets loaded with a number of Dependency
- each Dependency includes a File and a timestamp.
- If any of the Files is changed after timestamp this DependManager
will set "expired" to true
- One check at a time, but without sync
- if a check was done recently ( delay property ) - assume nothing changed
It is also possible to do the checks in background, but for big
servers ( with many contexts) it have scalability problems.
*/
public class DependManager {
int delay=4000;
Dependency deps[]=new Dependency[32];
int depsCount=0;
long lastCheck=0;
boolean checking=false;
long checkTime=0;
int checkCount=0;
boolean expired=false;
public DependManager() {
}
public void setDelay( int d ) {
delay=d;
}
// statistics
public long getCheckTime() {
return checkTime;
}
public long getCheckCount() {
return checkCount;
}
// Not synchronized - we do that inside
public boolean shouldReload() {
// somebody else is checking, so we don't know yet.
// assume we're fine - reduce the need for sync
if( checking ) return expired;
synchronized(this) {
try {
// someone else got here and did it before me
if( checking ) return expired;
// did a check in the last N seconds
long startCheck=System.currentTimeMillis();
if( startCheck - lastCheck < delay )
return expired;
checking=true;
// it's ok if a new dep is added - this is not
//exact science ( and no dep can be removed)
for( int i=0; i<depsCount; i++ ) {
Dependency d=deps[i];
long lm=d.getLastModified();
File f=d.getOrigin();
if( lm < f.lastModified() ) {
// something got modified
expired=true;
}
}
checkTime += lastCheck-startCheck;
checkCount++;
lastCheck=startCheck;
} finally {
checking=false;
}
return expired;
}
}
public synchronized void addDependency( Dependency dep ) {
if( depsCount >= deps.length ) {
Dependency deps1[]=new Dependency[ deps.length *2 ];
System.arraycopy( deps, 0, deps1, 0 , depsCount );
deps=deps1;
}
deps[depsCount++]= dep ;
if( debug>2) log( "Added " + dep.getOrigin() + " " + dep.getTarget());
}
// -------------------- Private
private static final int debug=0;
void log( String s ) {
System.out.println("DependManager: " + s );
}
}
1.1 jakarta-tomcat/src/share/org/apache/tomcat/util/depend/Dependency.java
Index: Dependency.java
===================================================================
/*
* Copyright (c) 1997-1999 The Java Apache Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the Java Apache
* Project for use in the Apache JServ servlet engine project
* <http://java.apache.org/>."
*
* 4. The names "Apache JServ", "Apache JServ Servlet Engine" and
* "Java Apache Project" must not be used to endorse or promote products
* derived from this software without prior written permission.
*
* 5. Products derived from this software may not be called "Apache JServ"
* nor may "Apache" nor "Apache JServ" appear in their names without
* prior written permission of the Java Apache Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the Java Apache
* Project for use in the Apache JServ servlet engine project
* <http://java.apache.org/>."
*
* THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Java Apache Group. For more information
* on the Java Apache Project and the Apache JServ Servlet Engine project,
* please see <http://java.apache.org/>.
*
*/
package org.apache.tomcat.util.depend;
import java.io.*;
import java.lang.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.util.zip.*;
import java.security.*;
/**
*/
public class Dependency {
public Dependency() {
}
long lastModified;
/**
* Get the value of lastModified.
* @return Value of lastModified.
*/
public long getLastModified() {return lastModified;}
/**
* Set the value of lastModified.
* @param v Value to assign to lastModified.
*/
public void setLastModified(long v) {this.lastModified = v;}
File origin;
/**
* Get the value of origin.
* @return Value of origin.
*/
public File getOrigin() {return origin;}
/**
* Set the value of origin.
* @param v Value to assign to origin.
*/
public void setOrigin(File v) {this.origin = v;}
Object target;
/**
* Get the value of target.
* @return Value of target.
*/
public Object getTarget() {return target;}
/**
* Set the value of target.
* @param v Value to assign to target.
*/
public void setTarget(Object v) {this.target = v;}
}
1.1 jakarta-tomcat/src/share/org/apache/tomcat/util/depend/package.html
Index: package.html
===================================================================
<h2>org.apache.tomcat.depend</h2>
This package will implement a (generic) dependency manager that
can be used in tomcat or other projects that need to maintain
a list of dependencies.
|