public abstract class ServiceEnvironment extends Object implements DDSObject
Modifier and Type | Class and Description |
---|---|
static interface |
ServiceEnvironment.ServiceProviderInterface
This interface is for the use of the DDS implementation, not of DDS
applications.
|
Modifier and Type | Field and Description |
---|---|
static String |
IMPLEMENTATION_CLASS_NAME_PROPERTY |
Constructor and Description |
---|
ServiceEnvironment() |
Modifier and Type | Method and Description |
---|---|
static ServiceEnvironment |
createInstance(ClassLoader classLoader)
Create and return a new instance of a concrete implementation of this
class with the given environment.
|
static ServiceEnvironment |
createInstance(String implClassNameProperty,
Map<String,Object> environment,
ClassLoader classLoader)
Look up the system property identified by the given string and load,
then instantiate, the ServiceEnvironment implementation class
identified by its value.
|
ServiceEnvironment |
getEnvironment() |
abstract ServiceEnvironment.ServiceProviderInterface |
getSPI()
This method is not intended for use by applications.
|
public static final String IMPLEMENTATION_CLASS_NAME_PROPERTY
public static ServiceEnvironment createInstance(ClassLoader classLoader)
createInstance(IMPLEMENTATION_CLASS_NAME_PROPERTY, null, classLoader);
public static ServiceEnvironment createInstance(String implClassNameProperty, Map<String,Object> environment, ClassLoader classLoader)
Map
. If
one is found, it will be called with the environment
map
provided to this method as its argument. If no such constructor is
found, a no-argument constructor will be used instead, and the
provided environment
, if any, will be ignored. If the
implementation class provides no public constructor with either of
these signatures, an exception will be thrown.
By default, the class loader for the ServiceEnvironment
class will be used to load the indicated class. If this class loader
is null -- for instance, if it is the bootstrap class loader -- then
the system class loader will be used in its place. If it is also null,
a ServiceConfigurationException
will be thrown.
Neither the class loader nor the loaded class will be cached between
invocations of this method. As a result, execution of this method is
expected to be relatively expensive. However, as any DDS object can
provide a reference to its creating ServiceEnvironment via
DDSObject.getEnvironment()
, executions of this method are also
expected to be rare.implClassNameProperty
- The name of a system property,
the value of which will be taken as the name of a
ServiceEnvironment implementation class to load.environment
- A collection of name-value pairs
to be provided to the concrete ServiceEnvironment subclass.
If that class does not provide a constructor that can accept
this environment, the environment will be ignored. This
argument may be null; a null environment shall be considered
equivalent to an empty map.classLoader
- The class loader to use to load
the service implementation class. If it is null, this class's
class loader will be used if it is accessible; otherwise, the
system class loader will be used.NullPointerException
- If the given property name is
null.IllegalArgumentException
- If the given property name
is the empty string.ServiceConfigurationException
- If the class could not be
loaded because of an issue with the the invocation of this
method or the configuration of the runtime environment. For
example, the class may not be on the class path, it may
require a native library that is not available, or an
inappropriate class may have been requested (e.g. one that is
not a ServiceEnvironment or that doesn't have a no-argument
constructor).ServiceInitializationException
- If the class was found but
could not be initialized and/or instantiated because of an
error that occurred within its implementation.createInstance(ClassLoader)
,
DDSObject.getEnvironment()
,
System.getProperty(String)
,
Class.getClassLoader()
,
ClassLoader.getSystemClassLoader()
,
ClassLoader.loadClass(String)
public abstract ServiceEnvironment.ServiceProviderInterface getSPI()
public final ServiceEnvironment getEnvironment()
getEnvironment
in interface DDSObject
ServiceEnvironment
object that directly or
indirectly was used to create this object.Copyright © 2014. All rights reserved.