319370 WebAppClassLoaderContext

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2088 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-07-09 11:42:19 +00:00
parent 9f0a75da75
commit 16be43597f
5 changed files with 79 additions and 14 deletions

View File

@ -1,5 +1,6 @@
jetty-7.2-SNAPSHOT jetty-7.2-SNAPSHOT
+ 319334 Concurrent, sharable ResourceCache + 319334 Concurrent, sharable ResourceCache
+ 319370 WebAppClassLoader.Context
jetty-7.1.5.v20100705 jetty-7.1.5.v20100705
+ Update ecj to 3.6 Helios release drop + Update ecj to 3.6 Helios release drop

View File

@ -193,7 +193,7 @@ public class OSGiWebappClassLoader extends WebAppClassLoader implements BundleRe
} }
else else
{ {
__logger.info("Did not add " + path + " to the classloader of the webapp " + getContext().getContextPath()); __logger.info("Did not add " + path + " to the classloader of the webapp " + getContext());
} }
} }

View File

@ -1154,6 +1154,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
*/ */
public MimeTypes getMimeTypes() public MimeTypes getMimeTypes()
{ {
if (_mimeTypes==null)
_mimeTypes=new MimeTypes();
return _mimeTypes; return _mimeTypes;
} }
@ -1334,13 +1336,16 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** Convert URL to Resource /** Convert a URL or path to a Resource.
* wrapper for {@link Resource#newResource(String)} enables extensions to * The default implementation
* provide alternate resource implementations. * is a wrapper for {@link Resource#newResource(String)}.
* @param urlOrPath The URL or path to convert
* @return The Resource for the URL/path
* @throws IOException The Resource could not be created.
*/ */
public Resource newResource(String url) throws IOException public Resource newResource(String urlOrPath) throws IOException
{ {
return Resource.newResource(url); return Resource.newResource(urlOrPath);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */

View File

@ -56,14 +56,71 @@ import org.eclipse.jetty.util.resource.ResourceCollection;
public class WebAppClassLoader extends URLClassLoader public class WebAppClassLoader extends URLClassLoader
{ {
private String _name; private String _name;
private WebAppContext _context; private Context _context;
private ClassLoader _parent; private ClassLoader _parent;
private HashSet<String> _extensions; private HashSet<String> _extensions;
/* ------------------------------------------------------------ */
/** The Context in which the classloader operates.
*/
public interface Context
{
/* ------------------------------------------------------------ */
/** Convert a URL or path to a Resource.
* The default implementation
* is a wrapper for {@link Resource#newResource(String)}.
* @param urlOrPath The URL or path to convert
* @return The Resource for the URL/path
* @throws IOException The Resource could not be created.
*/
Resource newResource(String urlOrPath) throws IOException;
/* ------------------------------------------------------------ */
/**
* @return Returns the permissions.
*/
PermissionCollection getPermissions();
/* ------------------------------------------------------------ */
/** Is the class a System Class.
* A System class is a class that is visible to a webapplication,
* but that cannot be overridden by the contents of WEB-INF/lib or
* WEB-INF/classes
* @param clazz The fully qualified name of the class.
* @return True if the class is a system class.
*/
boolean isSystemClass(String clazz);
/* ------------------------------------------------------------ */
/** Is the class a Server Class.
* A Server class is a class that is part of the implementation of
* the server and is NIT visible to a webapplication. The web
* application may provide it's own implementation of the class,
* to be loaded from WEB-INF/lib or WEB-INF/classes
* @param clazz The fully qualified name of the class.
* @return True if the class is a server class.
*/
boolean isServerClass(String clazz);
/* ------------------------------------------------------------ */
/**
* @return True if the classloader should delegate first to the parent
* classloader (standard java behaviour) or false if the classloader
* should first try to load from WEB-INF/lib or WEB-INF/classes (servlet
* spec recommendation).
*/
boolean isParentLoaderPriority();
/* ------------------------------------------------------------ */
String getExtraClasspath();
}
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** Constructor. /** Constructor.
*/ */
public WebAppClassLoader(WebAppContext context) public WebAppClassLoader(Context context)
throws IOException throws IOException
{ {
this(null,context); this(null,context);
@ -72,7 +129,7 @@ public class WebAppClassLoader extends URLClassLoader
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** Constructor. /** Constructor.
*/ */
public WebAppClassLoader(ClassLoader parent, WebAppContext context) public WebAppClassLoader(ClassLoader parent, Context context)
throws IOException throws IOException
{ {
super(new URL[]{},parent!=null?parent super(new URL[]{},parent!=null?parent
@ -120,7 +177,7 @@ public class WebAppClassLoader extends URLClassLoader
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public ContextHandler getContext() public Context getContext()
{ {
return _context; return _context;
} }

View File

@ -57,10 +57,8 @@ import org.eclipse.jetty.util.resource.ResourceCollection;
* *
* @org.apache.xbean.XBean description="Creates a servlet web application at a given context from a resource base" * @org.apache.xbean.XBean description="Creates a servlet web application at a given context from a resource base"
* *
*
*
*/ */
public class WebAppContext extends ServletContextHandler public class WebAppContext extends ServletContextHandler implements WebAppClassLoader.Context
{ {
public static final String TEMPDIR = "javax.servlet.context.tempdir"; public static final String TEMPDIR = "javax.servlet.context.tempdir";
public static final String BASETEMPDIR = "org.eclipse.jetty.webapp.basetempdir"; public static final String BASETEMPDIR = "org.eclipse.jetty.webapp.basetempdir";
@ -522,6 +520,7 @@ public class WebAppContext extends ServletContextHandler
return _systemClasses.getPatterns(); return _systemClasses.getPatterns();
} }
/* ------------------------------------------------------------ */
public void addSystemClass(String classname) public void addSystemClass(String classname)
{ {
if (_systemClasses == null) if (_systemClasses == null)
@ -640,7 +639,10 @@ public class WebAppContext extends ServletContextHandler
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** /**
* @return Returns the java2compliant. * @return True if the classloader should delegate first to the parent
* classloader (standard java behaviour) or false if the classloader
* should first try to load from WEB-INF/lib or WEB-INF/classes (servlet
* spec recommendation).
*/ */
public boolean isParentLoaderPriority() public boolean isParentLoaderPriority()
{ {