Interface Configuration
- All Known Implementing Classes:
AbstractConfiguration,AggregateConfig,ConfigurationFile,EmptyConfiguration,PlainConfiguration
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.
- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns 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.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 notNO_DEFAULT.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 isNO_DATA), returning the default value if no matching entry is found and the default value is notNO_DEFAULT.
-
Field Details
-
NO_DEFAULT
An object to pass fordefaultValuein calls togetEntryto specify no default value. -
NO_DATA
An object to pass fordatain calls togetEntryto specify no data.
-
-
Method Details
-
getEntry
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. Iftypeis 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
componentidentifies the object whose behavior will be configured using the object returned. The value ofcomponentmust 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. Thenameidentifies which of possibly several entries are available for the given component. The value ofnamemust be an Identifier, as defined in the JLS.Calling this method is equivalent to calling
.getEntry(component, name, type,NO_DEFAULT,NO_DATA)- Parameters:
component- the component being configuredname- the name of the entry for the componenttype- the type of the object to be returned- Returns:
- an object created using the information in the entry matching
componentandname - Throws:
NoSuchEntryException- if no matching entry is foundConfigurationException- if a matching entry is found but a problem occurs creating the object for the entry, or iftypeis a reference type and the result for the matching entry is not eithernullor an instance oftype, or iftypeis a primitive type and the result is not an instance of the associated wrapper class. AnyErrorthrown while creating the object is propagated to the caller; it is not wrapped in aConfigurationException.IllegalArgumentException- ifcomponentis notnulland is not a valid QualifiedIdentifier, or ifnameis notnulland is not a valid IdentifierNullPointerException- if any argument isnull- See Also:
-
getEntry
Object getEntry(String component, String name, Class type, Object defaultValue) throws ConfigurationException 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 notNO_DEFAULT. Iftypeis 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
componentidentifies the object whose behavior will be configured using the object returned. The value ofcomponentmust be a QualifiedIdentifier, as defined in the Java Language Specification (JLS), and is typically the class or package name of the object being configured. Thenameidentifies which of possibly several entries are available for the given component. The value ofnamemust be an Identifier, as defined in the JLS.Calling this method is equivalent to calling
.getEntry(component, name, type, defaultValue,NO_DATA)- Parameters:
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, orNO_DEFAULTto specify no default- Returns:
- an object created using the information in the entry matching
componentandname, ordefaultValueif no matching entry is found anddefaultValueis notNO_DEFAULT - Throws:
NoSuchEntryException- if no matching entry is found anddefaultValueisNO_DEFAULTConfigurationException- if a matching entry is found but a problem occurs creating the object for the entry, or iftypeis a reference type and the result for the matching entry is not eithernullor an instance oftype, or iftypeis a primitive type and the result is not an instance of the associated wrapper class. AnyErrorthrown while creating the object is propagated to the caller; it is not wrapped in aConfigurationException.IllegalArgumentException- ifcomponentis notnulland is not a valid QualifiedIdentifier; or ifnameis notnulland is not a valid Identifier; or iftypeis a reference type anddefaultValueis notNO_DEFAULT,null, or an instance oftype; or iftypeis a primitive type anddefaultValueis notNO_DEFAULTor an instance of the associated wrapper classNullPointerException- ifcomponent,name, ortypeisnull- See Also:
-
getEntry
Object getEntry(String component, String name, Class type, Object defaultValue, Object data) throws ConfigurationException 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 isNO_DATA), returning the default value if no matching entry is found and the default value is notNO_DEFAULT. Iftypeis 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
componentidentifies the object whose behavior will be configured using the object returned. The value ofcomponentmust be a QualifiedIdentifier, as defined in the Java Language Specification (JLS), and is typically the class or package name of the object being configured. Thenameidentifies which of possibly several entries are available for the given component. The value ofnamemust be an Identifier, as defined in the JLS.- Parameters:
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, orNO_DEFAULTto specify no defaultdata- an object to use when computing the value of the entry, orNO_DATAto specify no data- Returns:
- an object created using the information in the entry matching
componentandname, and using the value ofdata(unless it isNO_DATA), ordefaultValueif no matching entry is found anddefaultValueis notNO_DEFAULT - Throws:
NoSuchEntryException- if no matching entry is found anddefaultValueisNO_DEFAULTConfigurationException- if a matching entry is found but a problem occurs creating the object for the entry, or iftypeis a reference type and the result for the matching entry is not eithernullor an instance oftype, or iftypeis a primitive type and the result is not an instance of the associated wrapper class. AnyErrorthrown while creating the object is propagated to the caller; it is not wrapped in aConfigurationException.IllegalArgumentException- ifcomponentis notnulland is not a valid QualifiedIdentifier; or ifnameis notnulland is not a valid Identifier; or iftypeis a reference type anddefaultValueis notNO_DEFAULT,null, or an instance oftype; or iftypeis a primitive type anddefaultValueis notNO_DEFAULTor an instance of the associated wrapper classNullPointerException- ifcomponent,name, ortypeisnull
-