public interface Configuration
Exporter
or ProxyPreparer
instances, or other application-specific objects, from
configuration files, databases, or other sources. Configuration entries are identified by a
component
and a name
. Methods that retrieve entries can specify a
default value to return in case the entry is not found, and supply data to use when computing the
value of the entry.
Application developers are encouraged to use this interface, rather than explicitly constructing
instances of exporters and proxy preparers, so that applications can be customized without
requiring code modifications. Applications should normally use ConfigurationProvider
to
obtain Configuration
instances, rather than referencing implementation classes
directly, so that the interpretation of configuration options can be customized without requiring
code modifications.
Modifier and Type | Field and Description |
---|---|
static Object |
NO_DATA
An object to pass for
data in calls to getEntry to specify no
data. |
static Object |
NO_DEFAULT
An object to pass for
defaultValue in calls to getEntry to specify
no default value. |
Modifier and Type | Method and Description |
---|---|
Object |
getEntry(String component,
String name,
Class type)
Returns an object of the specified type created using the information in the entry matching
the specified component and name, which must be found, and supplying no data.
|
Object |
getEntry(String component,
String name,
Class type,
Object defaultValue)
Returns an object of the specified type created using the information in the entry matching
the specified component and name, and supplying no data, returning the default value if no
matching entry is found and the default value is not
NO_DEFAULT . |
Object |
getEntry(String component,
String name,
Class type,
Object defaultValue,
Object data)
Returns an object of the specified type created using the information in the entry matching
the specified component and name, and using the specified data (unless it is
NO_DATA ), returning the default value if no matching entry is found and the default value
is not NO_DEFAULT . |
static final Object NO_DEFAULT
defaultValue
in calls to getEntry
to specify
no default value.static final Object NO_DATA
data
in calls to getEntry
to specify no
data.Object getEntry(String component, String name, Class type) throws ConfigurationException
type
is a primitive type, then the result is returned as an instance of the
associated wrapper class. Repeated calls with the same arguments may or may not return the
identical object.
The component
identifies the object whose behavior will be configured using the
object returned. The value of component
must be a QualifiedIdentifier, as
defined in the Java(TM) Language Specification (JLS), and is typically the
class or package name of the object being configured. The name
identifies which
of possibly several entries are available for the given component. The value of
name
must be an Identifier, as defined in the JLS.
Calling this method is equivalent to calling
.getEntry
(component, name, type, NO_DEFAULT
, NO_DATA
)
component
- the component being configuredname
- the name of the entry for the componenttype
- the type of the object to be returnedcomponent
and name
NoSuchEntryException
- if no matching entry is foundConfigurationException
- if a matching entry is found but a problem occurs creating
the object for the entry, or if type
is a
reference type and the result for the matching entry is not
either null
or an instance of
type
, or if type
is a primitive
type and the result is not an instance of the associated
wrapper class. Any Error
thrown while creating
the object is propagated to the caller; it is not wrapped in
a ConfigurationException
.IllegalArgumentException
- if component
is not null
and is
not a valid QualifiedIdentifier, or if
name
is not null
and is not a
valid IdentifierNullPointerException
- if any argument is null
getEntry(String, String, Class, Object)
Object getEntry(String component, String name, Class type, Object defaultValue) throws ConfigurationException
NO_DEFAULT
. If
type
is a primitive type, then the result is returned as an instance of the
associated wrapper class. Repeated calls with the same arguments may or may not return the
identical object.
The component
identifies the object whose behavior will be configured using the
object returned. The value of component
must be a QualifiedIdentifier, as
defined in the Java Language Specification (JLS), and is typically the class or
package name of the object being configured. The name
identifies which of
possibly several entries are available for the given component. The value of
name
must be an Identifier, as defined in the JLS.
Calling this method is equivalent to calling
.getEntry
(component, name, type, defaultValue, NO_DATA
)
component
- the component being configuredname
- the name of the entry for the componenttype
- the type of the object to be returneddefaultValue
- the object to return if no matching entry is found, or
NO_DEFAULT
to specify no defaultcomponent
and name
, or defaultValue
if no matching entry is found and
defaultValue
is not NO_DEFAULT
NoSuchEntryException
- if no matching entry is found and defaultValue
is NO_DEFAULT
ConfigurationException
- if a matching entry is found but a problem occurs creating
the object for the entry, or if type
is a
reference type and the result for the matching entry is not
either null
or an instance of
type
, or if type
is a primitive
type and the result is not an instance of the associated
wrapper class. Any Error
thrown while creating
the object is propagated to the caller; it is not wrapped in
a ConfigurationException
.IllegalArgumentException
- if component
is not null
and is
not a valid QualifiedIdentifier; or if
name
is not null
and is not a
valid Identifier; or if type
is a
reference type and defaultValue
is not
NO_DEFAULT
, null
, or an instance
of type
; or if type
is a primitive
type and defaultValue
is not
NO_DEFAULT
or an instance of the associated
wrapper classNullPointerException
- if component
, name
, or
type
is null
getEntry(String, String, Class, Object, Object)
Object getEntry(String component, String name, Class type, Object defaultValue, Object data) throws ConfigurationException
NO_DATA
), returning the default value if no matching entry is found and the default value
is not NO_DEFAULT
. If type
is a primitive type, then the result is
returned as an instance of the associated wrapper class. Repeated calls with the same
arguments may or may not return the identical object.
The component
identifies the object whose behavior will be configured using the
object returned. The value of component
must be a QualifiedIdentifier, as
defined in the Java Language Specification (JLS), and is typically the class or
package name of the object being configured. The name
identifies which of
possibly several entries are available for the given component. The value of
name
must be an Identifier, as defined in the JLS.
component
- the component being configuredname
- the name of the entry for the componenttype
- the type of the object to be returneddefaultValue
- the object to return if no matching entry is found, or
NO_DEFAULT
to specify no defaultdata
- an object to use when computing the value of the entry, or
NO_DATA
to specify no datacomponent
and name
, and using the value of data
(unless it is
NO_DATA
), or defaultValue
if no matching entry is found and
defaultValue
is not NO_DEFAULT
NoSuchEntryException
- if no matching entry is found and defaultValue
is NO_DEFAULT
ConfigurationException
- if a matching entry is found but a problem occurs creating
the object for the entry, or if type
is a
reference type and the result for the matching entry is not
either null
or an instance of
type
, or if type
is a primitive
type and the result is not an instance of the associated
wrapper class. Any Error
thrown while creating
the object is propagated to the caller; it is not wrapped in
a ConfigurationException
.IllegalArgumentException
- if component
is not null
and is
not a valid QualifiedIdentifier; or if
name
is not null
and is not a
valid Identifier; or if type
is a
reference type and defaultValue
is not
NO_DEFAULT
, null
, or an instance
of type
; or if type
is a primitive
type and defaultValue
is not
NO_DEFAULT
or an instance of the associated
wrapper classNullPointerException
- if component
, name
, or
type
is null
Copyright © GigaSpaces.