|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jomc.ri.DefaultObjectManager
@Generated(value="org.jomc.tools.JavaSources", comments="See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools") public class DefaultObjectManager
Object management and configuration reference implementation.
Specifications
org.jomc.ObjectManager
1.0
Singleton
Field Summary | |
---|---|
protected static String |
SINGLETON_SCOPE_IDENTIFIER
Constant for the Singleton scope identifier. |
Constructor Summary | |
---|---|
DefaultObjectManager()
Creates a new DefaultObjectManager instance. |
Method Summary | ||
---|---|---|
static String |
getBootstrapClassLoaderClassName()
Gets the name of the platform's bootstrap class loader class. |
|
static ClassLoader |
getClassLoader(Class clazz)
Gets the class loader of a given class. |
|
static ClassLoader |
getClassLoader(ClassLoader classLoader)
Gets the parent class loader of a given class loader recursively. |
|
org.jomc.spi.Locator |
getDefaultLocator(URI location)
Gets the default locator implementation for a given location URI. |
|
static Level |
getDefaultLogLevel()
Gets the default log level events are logged at. |
|
org.jomc.spi.Scope |
getDefaultScope(String identifier)
Gets the default scope implementation for a given identifier. |
|
Object |
getDependency(Object object,
String dependencyName)
|
|
org.jomc.spi.Invocation |
getInvocation(Object object,
org.jomc.model.Instance instance,
Method method,
Object[] arguments)
Gets an invocation for a given object, instance, method and arguments. |
|
org.jomc.spi.Invoker |
getInvoker(ClassLoader classLoader)
Gets the invoker of the given class loader. |
|
List<org.jomc.spi.Listener> |
getListeners()
Gets the list of registered listeners. |
|
org.jomc.spi.Locator |
getLocator(ClassLoader classLoader,
URI location)
Gets a locator to use with a given location URI. |
|
Level |
getLogLevel()
Gets the log level of the instance. |
|
String |
getMessage(Object object,
String messageName,
Locale locale,
Object arguments)
|
|
org.jomc.model.Modules |
getModules(ClassLoader classLoader)
Gets the modules of a given class loader. |
|
Object |
getObject(Class specification)
|
|
|
getObject(Class<T> specification,
URI location,
ClassLoader classLoader)
Gets an object for a given location URI. |
|
Object |
getObject(Class specification,
String implementationName)
|
|
Object |
getObject(org.jomc.spi.Scope scope,
org.jomc.model.Instance instance,
ClassLoader classLoader)
Gets an object of a given instance from a given scope. |
|
static org.jomc.ObjectManager |
getObjectManager(ClassLoader classLoader)
Default ObjectManagerFactory.getObjectManager(ClassLoader) implementation. |
|
Object |
getProperty(Object object,
String propertyName)
|
|
org.jomc.spi.Scope |
getScope(ClassLoader classLoader,
String identifier)
Gets the scope implementation for a given scope identifier. |
|
void |
initialize()
Initializes the instance. |
|
boolean |
isLoggable(Level level)
Checks if a message at a given level is provided to the listeners of the instance. |
|
protected void |
log(Level level,
String message,
Throwable throwable)
Notifies registered listeners. |
|
static void |
setBootstrapClassLoaderClassName(String value)
Sets the name of the platform's bootstrap class loader class. |
|
static void |
setDefaultLogLevel(Level value)
Sets the default log level events are logged at. |
|
void |
setLogLevel(Level value)
Sets the log level of the instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String SINGLETON_SCOPE_IDENTIFIER
Singleton
scope identifier.
Constructor Detail |
---|
@Generated(value="org.jomc.tools.JavaSources", comments="See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools") public DefaultObjectManager()
DefaultObjectManager
instance.
Method Detail |
---|
public Object getObject(Class specification)
getObject
in interface org.jomc.ObjectManager
public Object getObject(Class specification, String implementationName)
getObject
in interface org.jomc.ObjectManager
public Object getDependency(Object object, String dependencyName)
getDependency
in interface org.jomc.ObjectManager
public Object getProperty(Object object, String propertyName)
getProperty
in interface org.jomc.ObjectManager
public String getMessage(Object object, String messageName, Locale locale, Object arguments)
getMessage
in interface org.jomc.ObjectManager
public static org.jomc.ObjectManager getObjectManager(ClassLoader classLoader)
ObjectManagerFactory.getObjectManager(ClassLoader)
implementation.
ObjectManager
singleton instance.ObjectManagerFactory.getObjectManager(ClassLoader)
public List<org.jomc.spi.Listener> getListeners()
This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
to the returned list will be present inside the object. This is why there is no set
method for the
listeners property.
public static Level getDefaultLogLevel()
The default log level is controlled by system property
org.jomc.ri.DefaultObjectManager.defaultLogLevel
holding the log level to log events at by default.
If that property is not set, the WARNING
default is returned.
getLogLevel()
,
Level.parse(java.lang.String)
public static void setDefaultLogLevel(Level value)
value
- The new default level events are logged at or null
.getDefaultLogLevel()
public Level getLogLevel()
getDefaultLogLevel()
,
setLogLevel(java.util.logging.Level)
,
isLoggable(java.util.logging.Level)
public void setLogLevel(Level value)
value
- The new log level of the instance or null
.getLogLevel()
,
isLoggable(java.util.logging.Level)
public boolean isLoggable(Level level)
level
- The level to test.
true
if messages at level
are provided to the listeners of the instance;
false
if messages at level
are not provided to the listeners of the instance.
NullPointerException
- if level
is null
.getLogLevel()
,
setLogLevel(java.util.logging.Level)
,
log(java.util.logging.Level, java.lang.String, java.lang.Throwable)
public static String getBootstrapClassLoaderClassName()
The name of the platform's bootstrap class loader class is controlled by system property
org.jomc.ri.DefaultObjectManager.bootstrapClassLoaderClassName
holding the name of the platform's
bootstrap class loader class. If that property is not set, the bootstrap class loader is assumed to be
represented by a null
parent class loader.
null
.getClassLoader(java.lang.ClassLoader)
public static void setBootstrapClassLoaderClassName(String value)
value
- The new name of the platform's bootstrap class loader class or null
.getBootstrapClassLoaderClassName()
public org.jomc.model.Modules getModules(ClassLoader classLoader)
classLoader
- The class loader to get the modules of.
NullPointerException
- if classLoader
is null
,public static ClassLoader getClassLoader(Class clazz)
clazz
- The class whose class loader to return.
clazz
.
NullPointerException
- if clazz
is null
.public static ClassLoader getClassLoader(ClassLoader classLoader)
This method recursively finds the parent class loader of the given class loader. Recursion stops at the
platform's bootstrap class loader. That class loader is detected when either the current class loader has no
parent (a call to the getParent()
method returns null
) or when the class name of the
current class loader's parent class loader is equal to the name returned by method
getBootstrapClassLoaderClassName()
. Configuration of the name of the platform's bootstrap class loader
class is needed when the platform's getParent()
method of the ClassLoader
class does not return
null
to indicate the bootstrap class loader but instead returns an instance of ClassLoader
.
classLoader
- The class loader whose parent class loader to return or null
to return a
ClassLoader
instance representing the platform's bootstrap class loader.
classLoader
.
NullPointerException
- if classLoader
is null
.getBootstrapClassLoaderClassName()
,
ClassLoader.getParent()
public Object getObject(org.jomc.spi.Scope scope, org.jomc.model.Instance instance, ClassLoader classLoader) throws InstantiationException
scope
- The scope to get the object from or null
.instance
- The instance of the object to get.classLoader
- The class loader to use for creating the object.
instance
from scope
or null
if no such object is found.
NullPointerException
- if instance
or classLoader
is null
.
InstantiationException
- if creating an object fails.public <T> T getObject(Class<T> specification, URI location, ClassLoader classLoader) throws InstantiationException, ClassNotFoundException, IOException
T
- The type of the object.specification
- The specification class of the object to locate.location
- The location URI of the object to locate.classLoader
- The class loader to use for loading locator classes.
location
or null
if no such object is found.
NullPointerException
- if specification
, location
or classLoader
is null
.
InstantiationException
- if instantiating a locator fails.
ClassNotFoundException
- if the class of specification
is not found.
IOException
- if locating the object fails.public org.jomc.spi.Scope getScope(ClassLoader classLoader, String identifier) throws InstantiationException
classLoader
- The class loader to use for loading scope implementations.identifier
- The identifier of the scope to get an implementation of.
identifier
or null
if no such
scope implementation is found.
NullPointerException
- if classLoader
or identifier
is null
.
InstantiationException
- if instantiating a scope fails.getDefaultScope(java.lang.String)
public org.jomc.spi.Scope getDefaultScope(String identifier)
identifier
- The identifier of the scope to get a default implementation of.
identifier
or null
if no such
default implementation is available.
NullPointerException
- if identifier
is null
.getScope(java.lang.ClassLoader, java.lang.String)
public org.jomc.spi.Locator getLocator(ClassLoader classLoader, URI location) throws InstantiationException
classLoader
- The class loader to use for loading locator implementations.location
- The location URI to get a locator for.
location
or null
if no such locator is
available.
NullPointerException
- if classLoader
or location
is null
.
InstantiationException
- if instantiating a locator fails.getDefaultLocator(java.net.URI)
public org.jomc.spi.Locator getDefaultLocator(URI location)
location
- The location URI to get a default locator implementation for.
location
or null
if no default implementation is
available for location
.
NullPointerException
- if location
is null
.getLocator(java.lang.ClassLoader, java.net.URI)
public org.jomc.spi.Invoker getInvoker(ClassLoader classLoader) throws InstantiationException
classLoader
- The class loader to use for loading invoker implementations.
NullPointerException
- if classLoader
is null
.
InstantiationException
- if instantiating a new invoker fails.public org.jomc.spi.Invocation getInvocation(Object object, org.jomc.model.Instance instance, Method method, Object[] arguments) throws InstantiationException
object
- The object to invoke.instance
- The instance of the object to invoke.method
- The method to invoke on object
.arguments
- The arguments of the invocation or null
.
object
, instance
, method
and arguments
.
NullPointerException
- if object
, instance
or method
is null
.
InstantiationException
- if instantiating a new invocation fails.public void initialize() throws InstantiationException
This method is called once on first usage of a new instance.
InstantiationException
- if initialization fails.protected void log(Level level, String message, Throwable throwable)
level
- The level of the event.message
- The message of the event or null
.throwable
- The throwable of the event or null
.
NullPointerException
- if level
is null
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |