Top Description Fields Constructors Methods
org.eclipse.jetty.ee10.webapp

public Class CachingWebAppClassLoader

extends WebAppClassLoader
Class Inheritance
Annotations
@ManagedObject
Imports
java.io.IOException, java.net.URL, java.util.Set, java.util.concurrent.ConcurrentHashMap, org.eclipse.jetty.util.annotation.ManagedObject, .ManagedOperation, org.slf4j.Logger, .LoggerFactory

A WebAppClassLoader that caches getResource(String) results. Specifically this ClassLoader caches not found classes and resources, which can greatly increase performance for applications that search for resources.

Field Summary

Modifier and TypeField and Description
private final ConcurrentHashMap<String, URL>
private final Set<String>
private static final Logger

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public void
public URL
getResource(String
The resource name
name
)

Overrides org.eclipse.jetty.ee10.webapp.WebAppClassLoader.getResource.

Get a resource from the classloader NOTE: this method provides a convenience of hacking off a leading / should one be present.
public Class<?>
loadClass(String
The binary name of the class
name
)

Overrides java.lang.ClassLoader.loadClass.

Loads the class with the specified binary name.
public String
toString()

Overrides org.eclipse.jetty.ee10.webapp.WebAppClassLoader.toString.

Returns a string representation of the object.
Inherited from org.eclipse.jetty.ee10.webapp.WebAppClassLoader:
addClassPathaddClassPathaddJarsaddTransformerclosefindClassfoundClassgetContextgetNamegetPermissionsgetResourcesisServerClassisSystemClassloadAsResourceloadClassremoveTransformerrunWithServerClassAccesssetName

Field Detail

_cacheback to summary
private final ConcurrentHashMap<String, URL> _cache
_notFoundback to summary
private final Set<String> _notFound
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.ee10.webapp.WebAppClassLoader.LOG.

Constructor Detail

CachingWebAppClassLoaderback to summary
public CachingWebAppClassLoader(ClassLoader parent, WebAppClassLoader.Context context) throws IOException
CachingWebAppClassLoaderback to summary
public CachingWebAppClassLoader(WebAppClassLoader.Context context) throws IOException

Method Detail

clearCacheback to summary
public void clearCache()
Annotations
@ManagedOperation
getResourceback to summary
public URL getResource(String name)

Overrides org.eclipse.jetty.ee10.webapp.WebAppClassLoader.getResource.

Doc from org.eclipse.jetty.ee10.webapp.WebAppClassLoader.getResource.

Get a resource from the classloader NOTE: this method provides a convenience of hacking off a leading / should one be present. This is non-standard and it is recommended to not rely on this behavior

Parameters
name:String

Doc from java.lang.ClassLoader.getResource.

The resource name

Returns:URL

Doc from java.lang.ClassLoader.getResource.

URL object for reading the resource; null if the resource could not be found, a URL could not be constructed to locate the resource, the resource is in a package that is not opened unconditionally, or access to the resource is denied by the security manager.

Annotations
@Override
loadClassback to summary
public Class<?> loadClass(String name) throws ClassNotFoundException

Overrides java.lang.ClassLoader.loadClass.

Doc from java.lang.ClassLoader.loadClass.

Loads the class with the specified binary name. This method searches for classes in the same manner as the loadClass(String, boolean) method. It is invoked by the Java virtual machine to resolve class references. Invoking this method is equivalent to invoking loadClass(name, false).

Parameters
name:String

The binary name of the class

Returns:Class<?>

The resulting Class object

Annotations
@Override
Exceptions
ClassNotFoundException:
If the class was not found
toStringback to summary
public String toString()

Overrides org.eclipse.jetty.ee10.webapp.WebAppClassLoader.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override