public class ConfigurationProvider extends Object
Configuration instances, using a configurable
provider. This class cannot be instantiated. The configuration provider can be specified by
providing a resource named "META-INF/services/net.jini.config.Configuration" containing the name
of the provider class. If multiple resources with that name are available, then the one used will
be the last one returned by ClassLoader.getResources. If the
resource is not found, the ConfigurationFile class is used.
Downloaded code can specify its own class loader in a call to getInstance(String[], ClassLoader) in order to use the configuration provider
specified in the JAR file from which it was downloaded.
The provider class must be a public, non-abstract class that implements
Configuration, and has a public constructor that has String[] and
ClassLoader parameters. The String[] parameter supplies
provider-specific options, for example specifying a source location or values for particular
entries. The constructor should throw ConfigurationNotFoundException if the configuration
specified by the String[] options argument cannot be found, or if null
was specified for the options argument and the class does not provide defaults. The constructor
should use the class loader argument when loading resources and classes, and should interpret a
null class loader argument as signifying the context class loader.
The resource file should contain the fully qualified name of the provider class. Space and tab characters surrounding each name, as well as blank lines, are ignored. The comment character is '#' (0x23); on each line, all characters following the first comment character are ignored. The resource file must be encoded in UTF-8.
Logger named net.jini.config to log information
at the following logging levels:
| Level | Description |
|---|---|
FINE | problems getting a configuration |
| Modifier and Type | Field and Description |
|---|---|
static boolean |
disableServicesConfig |
| Modifier and Type | Method and Description |
|---|---|
static Configuration |
getInstance(String[] options)
Creates and returns an instance of the configuration provider, using the specified options.
|
static Configuration |
getInstance(String[] options,
ClassLoader cl)
Creates and returns an instance of the configuration provider, using the specified options
and class loader.
|
public static Configuration getInstance(String[] options) throws ConfigurationException
null for options uses provider-specific default options,
if available. Uses the current thread's context class loader to load resources and classes,
and supplies null as the class loader to the provider constructor.options - values to use when constructing the configuration, or null if
default options should be usednull for the class loaderConfigurationNotFoundException - if options specifies a source location
that cannot be found, or if options is
null and the provider does not supply
default optionsConfigurationException - if an I/O exception occurs; if there are problems with
the options argument or the format of the
contents of any source location it specifies; if there
is a problem with the contents of the resource file
that names the configuration provider; if the
configured provider class does not exist, is not
public, is abstract, does not implement
Configuration, or does not have a public
constructor that has String[] and
ClassLoader parameters; if the calling
thread does not have permission to obtain information
from the specified source; or if the provider does not
have permission to access the context class loader.
Any Error thrown while creating the
provider instance is propagated to the caller; it is
not wrapped in a ConfigurationException.public static Configuration getInstance(String[] options, ClassLoader cl) throws ConfigurationException
null for options uses
provider-specific default options, if available. Uses the specified class loader to load
resources and classes, or the current thread's context class loader if cl is
null. Supplies cl as the class loader to the provider constructor.
Downloaded code can specify its own class loader in a call to this method in order to use the configuration provider specified in the JAR file from which it was downloaded.
options - values to use when constructing the configuration, or null if
default options should be usedcl - the class loader to load resources and classes, and to pass when constructing
the provider. If null, uses the context class loader.ConfigurationNotFoundException - if options specifies a source location
that cannot be found, or if options is
null and the provider does not supply
default optionsConfigurationException - if an I/O exception occurs; if there are problems with
the options argument or the format of the
contents of any source location it specifies; if there
is a problem with the contents of the resource file
that names the configuration provider; if the
configured provider class does not exist, is not
public, is abstract, does not implement
Configuration, or does not have a public
constructor that has String[] and
ClassLoader parameters; if the calling
thread does not have permission to obtain information
from the specified source; or if cl is
null and the provider does not have
permission to access the context class loader. Any
Error thrown while creating the provider
instance is propagated to the caller; it is not
wrapped in a ConfigurationException.Copyright © GigaSpaces.