public class FileResourceFactory extends Object implements IResourceFactory
IResourceFactory
that currently supports
only file resources.Modifier | Constructor and Description |
---|---|
|
FileResourceFactory() |
protected |
FileResourceFactory(ClassLoader classLoader)
This constructor is primarily used by tests to mock the
ClassLoader |
Modifier and Type | Method and Description |
---|---|
protected Class<?> |
getNIOFileResourceClass()
Utility method for acquiring a reference to the NIOFileResource class without
asking the class loader every single time after we know it's not there.
|
protected Constructor<?> |
getNIOFileResourceConstructor(Class<?>... args)
Utility method for acquiring a reference to the NIOFileResource class constructor
without asking the class loader every single time after we know it's not there.
|
protected Object |
getNIOInstance(Constructor<?> constructor,
Object... args)
Utility method to catch class loading issues and prevent repeated attempts to use reflection.
|
boolean |
handles(URI uri) |
IResource |
newResource(URI uri)
Creates a
IResource object for the specified URI. |
public FileResourceFactory()
protected FileResourceFactory(ClassLoader classLoader)
ClassLoader
classLoader
- The class loader to use when looking for NIOFileResourcepublic IResource newResource(URI uri)
IResourceFactory
IResource
object for the specified URI. This method
must not fail due to non-existence of the resource specified by the URL.
If the resource doesn't exist, a valid resource object that returns
exists() == false
and throws an IOException for other
methods that require existence of the resource should be returned.
This method is free to convert the provided URI as needed so that the URI
returned by IResource.getURI()
for the returned object does not
need to be the same as the provided URI. For example, the factory may
convert a bundleentry
URI into a file
uri, or
else it may need to convert a URI using a pseudo scheme such as
namedbundleentry
into a URI that is supported by the
platform.
newResource
in interface IResourceFactory
uri
- The resource URI. The concrete implementation of the returned
type is determined by the URI scheme.IResource
object for the specified URI. The returned
object MUST be serialiable.public boolean handles(URI uri)
handles
in interface IResourceFactory
protected Class<?> getNIOFileResourceClass()
protected Constructor<?> getNIOFileResourceConstructor(Class<?>... args)
args
- The constructor argument typesprotected Object getNIOInstance(Constructor<?> constructor, Object... args) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
constructor
- The constructor to invokeargs
- The args to pass the constructorInstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
Copyright © 2011-2015 IBM. All Rights Reserved.