public abstract class ServiceConfiguration
extends java.lang.Object
For the purposes of configuration, a service is normally represented as a client library that connects to a remote provider of business value. Typically the client library needs to be configured in some way in order to function at all. Instances of this class aim to provide such configuration in as automated a manner as possible.
ServiceConfiguration instances are typically produced by
ServiceConfigurationProvider instances. Obtaining a ServiceConfiguration by any other means may result in undefined
behavior.
getInstance(String),
ServiceConfigurationProvider| Modifier | Constructor and Description |
|---|---|
protected |
ServiceConfiguration(java.lang.String serviceIdentifier)
Creates a new
ServiceConfiguration. |
| Modifier and Type | Method and Description |
|---|---|
static ServiceConfiguration |
getInstance(java.lang.String serviceIdentifier)
Returns the sole
ServiceConfiguration implementation in
effect for the current
Systems and identified by the supplied serviceIdentifier, if there is one, or null if
there is no such ServiceConfiguration. |
static ServiceConfiguration |
getInstance(java.lang.String serviceIdentifier,
java.util.Properties coordinates)
Returns the sole
ServiceConfiguration implementation in
effect for the current
Systems and identified by the supplied serviceIdentifier and suitable for the supplied coordinates, if there is one, or null if there
is no such ServiceConfiguration. |
java.lang.String |
getProperty(java.lang.String propertyName)
Returns a value for the property described by the supplied
propertyName, or null if no such property value exists. |
abstract java.lang.String |
getProperty(java.lang.String propertyName,
java.lang.String defaultValue)
Returns a value for the property described by the supplied
propertyName, or the value of the supplied defaultValue
parameter if no such property value exists. |
abstract java.util.Set<java.lang.String> |
getPropertyNames()
Returns an unmodifiable and unchanging
Set of Strings
representing the names of properties whose values may be
retrieved with the getProperty(String) method. |
java.lang.String |
getServiceIdentifier()
Returns the identifier of the service this
ServiceConfiguration
implementation provides configuration for. |
protected ServiceConfiguration(java.lang.String serviceIdentifier)
ServiceConfiguration.serviceIdentifier - the identifier of the service this
ServiceConfiguration implementation will provide
configuration for; must not be nulljava.lang.NullPointerException - if serviceIdentifier is
nullgetServiceIdentifier()public final java.lang.String getServiceIdentifier()
ServiceConfiguration
implementation provides configuration for.
This method never returns null.
ServiceConfiguration implementation provides configuration for;
never nullServiceConfiguration(String)public abstract java.util.Set<java.lang.String> getPropertyNames()
Set of Strings
representing the names of properties whose values may be
retrieved with the getProperty(String) method.
Implementations of this method must not return null.
Implementations of this method must ensure that the Set returned may be used without the end user having to peform
explicit synchronization.
Implementations of this method may return the same Set
instance with each invocation, or different Set instances
with different contents.
Set of Strings
representing the names of properties whose values may be
retrieved with the getProperty(String) methodpublic final java.lang.String getProperty(java.lang.String propertyName)
propertyName, or null if no such property value exists.
This method may return null.
propertyName - the name of the property whose value should
be returned; must not be nullpropertyName, or nullgetProperty(String, String)public abstract java.lang.String getProperty(java.lang.String propertyName,
java.lang.String defaultValue)
propertyName, or the value of the supplied defaultValue
parameter if no such property value exists.
Implementations of this method may return null if defaultValue is null.
Implementations of this method may return the same or different values for each invocation with the same parameters.
propertyName - the name of the property whose value should
be returned; may be null in which case the value of the
supplied defaultValue parameter will be returned insteaddefaultValue - the value to return if a value for the named
property could not be found; may be nullpropertyName, or the value of the supplied defaultValue
parameterpublic static final ServiceConfiguration getInstance(java.lang.String serviceIdentifier)
ServiceConfiguration implementation in
effect for the current
Systems and identified by the supplied serviceIdentifier, if there is one, or null if
there is no such ServiceConfiguration.serviceIdentifier - the service identifier for which a ServiceConfiguration
should be sought; must not be nullServiceConfiguration implementation in
effect for the current
Systems and identified by the supplied serviceIdentifier, if there is one, or nulljava.lang.NullPointerException - if serviceIdentifier is
nulljava.util.ServiceConfigurationError - if there was a problem
loading Java servicesgetInstance(String, Properties)public static final ServiceConfiguration getInstance(java.lang.String serviceIdentifier, java.util.Properties coordinates)
ServiceConfiguration implementation in
effect for the current
Systems and identified by the supplied serviceIdentifier and suitable for the supplied coordinates, if there is one, or null if there
is no such ServiceConfiguration.
This method may—and often does—return null.
While the current implementation of this method performs no
caching other than that performed as a side effect by ServiceLoader method invocations, caching is deliberately not a
component of the specification of this method's behavior.
serviceIdentifier - the service identifier for which a ServiceConfiguration
should be sought; must not be nullcoordinates - a Properties object containing
coordinates that might assist a ServiceConfiguration
implementation in implementing its getPropertyNames()
and getProperty(String) methods; may be nullServiceConfiguration implementation in
effect for the current
Systems and identified by the supplied serviceIdentifier, if there is one, or nulljava.lang.NullPointerException - if serviceIdentifier is
nulljava.util.ServiceConfigurationError - if there was a problem
loading Java servicesCopyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.