- All Known Subinterfaces:
ResourceFactory.Closeable,ResourceFactory.LifeCycle
- All Known Implementing Classes:
MountedPathResourceFactory,PathResourceFactory,URLResourceFactory
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionstatic ResourceFactoryGet theResourceFactorythat is registered for the specific scheme.static ResourceFactory.CloseableA ResourceFactory that can close it's opened resources using the Java standardAutoCloseabletechniques.static ResourceMake a directory Resource containing a collection of other directoryResourcesstatic ResourceMake a directory Resource containing a collection of directoryResourcesstatic ResourceFactorygetBestByScheme(String scheme) Get the best ResourceFactory for the provided scheme.static ResourceFactory.LifeCycleA ResourceFactory that implements the Jetty LifeCycle.default ResourcenewClassPathResource(String resource) Find a classpath resource.default ResourcenewJarFileResource(URI uri) Construct aResourcefrom afile:based URI that is mountable (eg: a jar file)default ResourcenewMemoryResource(URL url) Load a URL into a memory resource.default ResourcenewResource(String resource) Construct a resource from a string.newResource(URI uri) Construct a resource from a uri.default ResourcenewResource(URL url) Construct aResourcefrom a provided URLdefault ResourcenewResource(Path path) Construct a Resource from provided pathdefault ResourcenewResource(List<URI> uris) Construct a possibleCombinedResourcefrom a list of URIsdefault ResourcenewSystemResource(String resource) Construct a system resource from a string.static ResourceFactoryA new ResourceFactory tied to a Jetty ComponentContainer, to allow its allocated resources to be cleaned up during the normal component lifecycle behavior.static ResourceFactoryA new ResourceFactory from a provided Resource, to basenewResource(URI)andnewResource(String)calls against.static voidregisterResourceFactory(String scheme, ResourceFactory resourceFactory) Register a new ResourceFactory that can handle the specific scheme for the Resource API.static ResourceFactoryroot()The JVM wide (root) ResourceFactory.static ResourceFactoryunregisterResourceFactory(String scheme) Unregister a scheme that is supported by the Resource API.
-
Method Details
-
combine
Make a directory Resource containing a collection of other directory
Resources- Parameters:
resources- multiple directoryResources to combine as a single resource. Order is significant.- Returns:
- A
CombinedResourcefor multiple resources; or a singleResourceif only 1 is passed; or null if none are passed. The returnedResourcewill always returntruefromResource.isDirectory() - Throws:
IllegalArgumentException- if a non-directory resource is passed.- See Also:
-
combine
Make a directory Resource containing a collection of directory
Resources- Parameters:
resources- multiple directoryResources to combine as a single resource. Order is significant.- Returns:
- A
CombinedResourcefor multiple resources; or a singleResourceif only 1 is passed; or null if none are passed. The returnedResourcewill always returntruefromResource.isDirectory() - Throws:
IllegalArgumentException- if a non-directory resource is passed.- See Also:
-
newResource
Construct a resource from a uri.- Parameters:
uri- A URI.- Returns:
- A Resource object.
-
newSystemResource
Construct a system resource from a string. The resource is tried as classloader resource before being treated as a normal resource.- Parameters:
resource- Resource as string representation- Returns:
- The new Resource
-
newClassPathResource
Find a classpath resource. TheClass.getResource(String)method is used to lookup the resource. If it is not found, then theLoader.getResource(String)method is used.- Parameters:
resource- the relative name of the resource- Returns:
- Resource or null
-
newMemoryResource
Load a URL into a memory resource.- Parameters:
url- the URL to load into memory- Returns:
- Resource or null
- See Also:
-
newResource
Construct a resource from a string.- Parameters:
resource- A URL or filename.- Returns:
- A Resource object.
-
newResource
Construct a Resource from provided path- Parameters:
path- the path- Returns:
- the Resource for the provided path
-
newResource
Construct a possibleCombinedResourcefrom a list of URIs- Parameters:
uris- the URIs- Returns:
- the Resource for the provided path
-
newResource
Construct aResourcefrom a provided URL- Parameters:
url- the URL- Returns:
- the Resource for the provided URL
-
newJarFileResource
Construct aResourcefrom afile:based URI that is mountable (eg: a jar file)- Parameters:
uri- the URI- Returns:
- the Resource, mounted as a
FileSystem
-
registerResourceFactory
Register a new ResourceFactory that can handle the specific scheme for the Resource API.This allows
- Parameters:
scheme- the scheme to support (eg: `ftp`, `http`, `resource`, etc)resourceFactory- the ResourceFactory to be responsible for the registered scheme.- See Also:
-
unregisterResourceFactory
Unregister a scheme that is supported by the Resource API.- Parameters:
scheme- the scheme to unregister- Returns:
- the existing
ResourceFactorythat was registered to that scheme. - See Also:
-
byScheme
Get theResourceFactorythat is registered for the specific scheme..byScheme("jar") == ResourceFactory supporting jar .byScheme("jar:file://foo.jar!/") == null // full url strings not supported)- Parameters:
scheme- the scheme to look up- Returns:
- the
ResourceFactoryresponsible for the scheme, null if noResourceFactoryhandles the scheme. - See Also:
-
getBestByScheme
Get the best ResourceFactory for the provided scheme.Unlike
byScheme(String), this supports arbitrary Strings, that might start with a supported scheme.- Parameters:
scheme- the scheme to look up- Returns:
- the ResourceFactory that best fits the provided scheme.
- See Also:
-
root
The JVM wide (root) ResourceFactory.Resources allocated this way are not released until the JVM is closed.
If you have a ResourceFactory need that needs to clean up it's resources at runtime, use
closeable()orlifecycle()instead.- Returns:
- the JVM wide ResourceFactory.
- See Also:
-
closeable
A ResourceFactory that can close it's opened resources using the Java standardAutoCloseabletechniques.- Returns:
- a ResourceFactory that can be closed in a try-with-resources code block
-
lifecycle
A ResourceFactory that implements the Jetty LifeCycle.This style of ResourceFactory can be attached to the normal Jetty LifeCycle to clean up it's allocated resources.
- Returns:
- the ResourceFactory that implements
LifeCycle
-
of
A new ResourceFactory from a provided Resource, to basenewResource(URI)andnewResource(String)calls against.- Parameters:
baseResource- the resource to base this ResourceFactory from- Returns:
- the ResourceFactory that builds from the Resource
-
of
A new ResourceFactory tied to a Jetty ComponentContainer, to allow its allocated resources to be cleaned up during the normal component lifecycle behavior.This is safe to call repeatedly against the same
Container, the first call will create a ResourceFactory fromlifecycle()and add it as managed to theContainer, subsequent calls will return the same ResourceFactory from the providedContainer.- Parameters:
container- the container this ResourceFactory belongs to- Returns:
- the ResourceFactory that belongs to this container
-