|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Locator
The Locator
interface is used to locate resources
outside the scope of a Context
. This is required
so that various configuration files and other resources can be
located by the system. Resources such as XML files and Java
properties files required to configure various objects can be
discovered using an implementation of this interface.
This provides a set of methods similar to the methods provided
by the Context
object. However unlike that object
resources are located with more flexibility as it does not have
restricted scope. Also, this does not accept a URI target name
to locate the files, instead this will typically be given the
name of a resource. For example if an XML configuration file
named config.xml
was to be located then it could
be located using an alias like config
or possibly
with the file name itself, without any path information.
For simplicity and portability an implementation of this should
be able to cope with path information in the event that it is
supplied. Paths in URI format like /bin/config.xml
and also system dependant format (although not advisable) like
.\bin\config.xml
for a Windows system should be
acceptable to an implementation.
Method Summary | |
---|---|
java.io.File |
getFile(java.lang.String name)
This is used to produce a File object pointing
to the location of the named resource. |
java.lang.String |
getLocation(java.lang.String name)
This is used to discover the location of a resource using the name of the resource. |
java.util.Properties |
getProperties(java.lang.String name)
This is used to produce a Properties object
that contains the contents of the named Java properties file. |
java.net.URL |
getResource(java.lang.String name)
This is provided so that a ClassLoader can be
used to load the named resource. |
Method Detail |
---|
java.net.URL getResource(java.lang.String name) throws LocateException
ClassLoader
can be
used to load the named resource. This method enables the
configuration information to be loaded from the specified
class path, which enables the files to be stored within a
JAR resource or at any desired location. This only needs
the name of the resource, no path information is required,
this keeps the code portable and simple.
name
- the name of the resource that is to be located
URL
referencing the named resource
LocateException
- thrown if the named resource
could not be found after exhausting all lookup meansjava.lang.String getLocation(java.lang.String name) throws LocateException
Context.getRealPath
method, however it
should be supplied with only the name of the resource with
no path information, which keeps any code interacting with
this portable across systems using different path formats.
name
- the name of the resource that is to be located
LocateException
- thrown if the named resource
could not be found after exhausting all lookup meansjava.io.File getFile(java.lang.String name) throws LocateException
File
object pointing
to the location of the named resource. This method mirrors
the Context.getFile
method, however it should
be supplied with only the name of the resource with no path
information, which keeps any code interacting with this
portable across systems using different path formats.
name
- the name of the resource that is to be located
File
referencing the named resource
LocateException
- thrown if the named resource
could not be found after exhausting all lookup meansjava.util.Properties getProperties(java.lang.String name) throws LocateException
Properties
object
that contains the contents of the named Java properties file.
This mirrors the Context.getProperties
method,
however it should be supplied with only the name of the
resource with no path information, which keeps any code
interacting with this portable across different platforms.
name
- the name of the resource that is to be located
Properties
object for the resource
LocateException
- thrown if the named resource
could not be found after exhausting all lookup means
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |