org.jomc.ri
Class DefaultObjectManager

Package class diagram package DefaultObjectManager
java.lang.Object
  extended by org.jomc.ri.DefaultObjectManager
All Implemented Interfaces:
ObjectManager

@Generated(value="org.jomc.tools.JavaSources",
           comments="See http://jomc.sourceforge.net/jomc/1.0-alpha-3/jomc-tools")
public class DefaultObjectManager
extends Object
implements ObjectManager

Object management and configuration reference implementation.

Specifications

Version:
$Id: DefaultObjectManager.java 652 2009-10-02 17:49:00Z schulte2005 $
Author:
Christian Schulte 1.0

Field Summary
private  List<LogRecord> bootstrapLogRecords
          Bootstrap LogRecords.
private  Listener bootstrapObjectManagementListener
          Bootstrap ObjectManagementListener.
private  Boolean classpathAware
          Flag indicating classpath awareness.
private  DefaultModelManager.Listener defaultModelManagerListener
          DefaultModelManager.Listener of the instance.
private  boolean initialized
          Flag indicating that initialization has been performed.
private  List<Listener> listeners
          Listeners of the instance.
private  Map<String,Locator> locators
          Locators of the instance.
private  ModelManager modelManager
          The model manager of the instance.
private  Modules modules
          The modules of the instance.
private static URL[] NO_URLS
          Empty URL array.
private  Map<String,Scope> scopes
          Scopes of the instance.
private static ObjectManager singleton
          Singleton instance.
protected static String SINGLETON_SCOPE_IDENTIFIER
          Constant for the Singleton scope identifier.
 
Constructor Summary
DefaultObjectManager()
          Creates a new DefaultObjectManager instance.
 
Method Summary
private  StringBuilder appendImplementationInfo(Implementation i, StringBuilder b)
           
private  StringBuilder appendSpecificationInfo(Specification s, StringBuilder b)
           
private  Object createProxy(Specification specification, Instance instance, Object object)
          Creates a proxy for a given object.
private  String getArtifactNameMessage()
           
private  String getCannotProxySpecificationClassMessage(String specification, String instance)
           
 ClassLoader getClassLoader(Class clazz)
          Gets the class loader of a given class.
 Locator getDefaultLocator(URI location)
          Gets the default locator implementation for a given location URI.
private  String getDefaultLocatorInfoMessage(String scheme)
           
 Scope getDefaultScope(String modelScope)
          Gets the default scope implementation for a given model scope.
private  String getDefaultScopeInfoMessage(String modelScope, Map objects)
           
 Object getDependency(Object object, String dependencyName)
           
private  String getDependencyCycleMessage(String implementation)
           
private  String getImplementationInfoMessage(Long startMillis)
           
 List<Listener> getListeners()
          Gets the list of registered listeners.
 Locator getLocator(URI location)
          Gets a locator to use with a given location URI.
 String getMessage(Object object, String messageName, Locale locale, Object arguments)
           
private  String getMessage(String key, Object arguments)
           
private  String getMissingClassLoaderMessage()
           
private  String getMissingDependencyMessage(String dependency, String implementation)
           
private  String getMissingImplementationMessage(String implementationName, String specification)
           
private  String getMissingImplementationsMessage(String specification)
           
private  String getMissingInstanceMessage(String implementation, String implementationName)
           
private  String getMissingMessageMessage(String message, String implementation)
           
private  String getMissingObjectInstanceMessage(Object object)
           
private  String getMissingObjectMessage(String implementation, String implementationName)
           
private  String getMissingPropertyMessage(String property, String implementation)
           
private  String getMissingScopeMessage(String modelScope)
           
private  String getMissingSpecificationMessage(String specification)
           
 ModelManager getModelManager()
          Gets the model manager backing the instance.
 Modules getModules()
          Gets the modules of the instance.
private  String getModulesReport(Modules mods)
           
 Object getObject(Class specification)
           
 Object getObject(Class specification, String implementationName)
           
 Object getObject(Specification specification, Instance instance)
          Gets an object of a given instance.
 Object getObject(Specification specification, URI location, ClassLoader classLoader)
          Gets an object for a given location URI.
static ObjectManager getObjectManager()
          Default ObjectManagerFactory.getObjectManager() implementation backed by static field.
 Object getProperty(Object object, String propertyName)
           
private  String getRegisteredListenerMessage(String listener)
           
 Scope getScope(String modelScope)
          Gets the scope implementation for a given model scope.
private  String getUnsupportedMultiplicityMessage(Multiplicity multiplicity)
           
 void initialize()
          Initializes the instance.
 boolean isClasspathAware()
          Gets a flag indicating that classpath resolution is performed.
protected  void log(Level level, String message, Throwable throwable)
          Notifies registered listeners.
 void setClasspathAware(boolean value)
          Sets the flag indicating that classpath resolution should be performed.
 void setModules(Modules value)
          Sets the modules of the instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SINGLETON_SCOPE_IDENTIFIER

protected static final String SINGLETON_SCOPE_IDENTIFIER
Constant for the Singleton scope identifier.

See Also:
Constant Field Values

NO_URLS

private static final URL[] NO_URLS
Empty URL array.


singleton

private static final ObjectManager singleton
Singleton instance.


modules

private Modules modules
The modules of the instance.


modelManager

private ModelManager modelManager
The model manager of the instance.


scopes

private final Map<String,Scope> scopes
Scopes of the instance.


locators

private final Map<String,Locator> locators
Locators of the instance.


listeners

private List<Listener> listeners
Listeners of the instance.


initialized

private boolean initialized
Flag indicating that initialization has been performed.


classpathAware

private Boolean classpathAware
Flag indicating classpath awareness.


bootstrapLogRecords

private final List<LogRecord> bootstrapLogRecords
Bootstrap LogRecords.

See Also:
initialize()

defaultModelManagerListener

private final DefaultModelManager.Listener defaultModelManagerListener
DefaultModelManager.Listener of the instance.


bootstrapObjectManagementListener

private final Listener bootstrapObjectManagementListener
Bootstrap ObjectManagementListener.

Constructor Detail

DefaultObjectManager

@Generated(value="org.jomc.tools.JavaSources",
           comments="See http://jomc.sourceforge.net/jomc/1.0-alpha-3/jomc-tools")
public DefaultObjectManager()
Creates a new DefaultObjectManager instance.

Method Detail

getObject

public Object getObject(Class specification)
Specified by:
getObject in interface ObjectManager

getObject

public Object getObject(Class specification,
                        String implementationName)
Specified by:
getObject in interface ObjectManager

getDependency

public Object getDependency(Object object,
                            String dependencyName)
Specified by:
getDependency in interface ObjectManager

getProperty

public Object getProperty(Object object,
                          String propertyName)
Specified by:
getProperty in interface ObjectManager

getMessage

public String getMessage(Object object,
                         String messageName,
                         Locale locale,
                         Object arguments)
Specified by:
getMessage in interface ObjectManager

getObjectManager

public static ObjectManager getObjectManager()
Default ObjectManagerFactory.getObjectManager() implementation backed by static field.

Returns:
The default ObjectManager singleton instance.

isClasspathAware

public boolean isClasspathAware()
Gets a flag indicating that classpath resolution is performed.

Classpath resolution is performed by default. It can be disabled by setting the system property org.jomc.ri.DefaultObjectManager.classpathAware to false.

Returns:
true if the class loader of the instance is searched for resources; false if no classpath resolution is performed.

setClasspathAware

public void setClasspathAware(boolean value)
Sets the flag indicating that classpath resolution should be performed.

Parameters:
value - true if the class loader of the instance is searched for resources; false if no classpath resolution is performed.

getListeners

public List<Listener> getListeners()
Gets the list of registered listeners.

Returns:
The list of registered listeners.

getModules

public Modules getModules()
Gets the modules of the instance.

Returns:
The modules of the instance.

setModules

public void setModules(Modules value)
Sets the modules of the instance.

Parameters:
value - The new modules of the instance.

getModelManager

public ModelManager getModelManager()
Gets the model manager backing the instance.

Returns:
The model manager backing the instance.

getClassLoader

public ClassLoader getClassLoader(Class clazz)
Gets the class loader of a given class.

Parameters:
clazz - The class whose class loader to return.
Returns:
The class loader of clazz.
Throws:
NullPointerException - if clazz is null.

getObject

public Object getObject(Specification specification,
                        Instance instance)
                 throws InstantiationException
Gets an object of a given instance.

Parameters:
specification - The specification specifying the object to return.
instance - The instance of the object to get.
Returns:
An object of instance or null if nothing could be resolved.
Throws:
NullPointerException - if specification or instance is null.
InstantiationException - if getting an object fails.

getObject

public Object getObject(Specification specification,
                        URI location,
                        ClassLoader classLoader)
                 throws InstantiationException,
                        ClassNotFoundException,
                        IOException
Gets an object for a given location URI.

Parameters:
specification - The specification specifying the object to return.
location - The location URI of the object to return.
classLoader - The class loader of specification.
Returns:
An object located at location or null if nothing could be resolved.
Throws:
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.

getScope

public Scope getScope(String modelScope)
               throws InstantiationException
Gets the scope implementation for a given model scope.

Parameters:
modelScope - The scope to get an implementation of.
Returns:
The implementation of modelScope or null if no implementation is available implementing modelScope.
Throws:
NullPointerException - if modelScope is null.
InstantiationException - if instantiating a scope fails.

getDefaultScope

public Scope getDefaultScope(String modelScope)
Gets the default scope implementation for a given model scope.

Parameters:
modelScope - The scope to get the default implementation of.
Returns:
The default implementation of modelScope or null if no default implementation is available implementing modelScope.
Throws:
NullPointerException - if modelScope is null.

getLocator

public Locator getLocator(URI location)
                   throws InstantiationException
Gets a locator to use with a given location URI.

Parameters:
location - The location URI to get a locator for.
Returns:
The locator to use for locating objects at location or null if no locator is available.
Throws:
NullPointerException - if location is null.
InstantiationException - if instantiating a locator fails.

getDefaultLocator

public Locator getDefaultLocator(URI location)
Gets the default locator implementation for a given location URI.

Parameters:
location - The location URI to get a default locator implementation for.
Returns:
The default locator implementation for location or null if no default implementation is available for location.
Throws:
NullPointerException - if location is null.

initialize

public void initialize()
                throws InstantiationException
Initializes the instance.

This method is called once on first usage of a new instance.

Throws:
InstantiationException - if initialization fails.

log

protected void log(Level level,
                   String message,
                   Throwable throwable)
Notifies registered listeners.

Parameters:
level - The level of the event.
message - The message of the event or null.
throwable - The throwable of the event or null.

createProxy

private Object createProxy(Specification specification,
                           Instance instance,
                           Object object)
                    throws InstantiationException
Creates a proxy for a given object.

Parameters:
specification - The specification to create a proxy for.
instance - The instance of object.
object - The object to create a proxy for.
Returns:
A proxy for object.
Throws:
InstantiationException - if creating a proxy fails.

getMessage

private String getMessage(String key,
                          Object arguments)

getArtifactNameMessage

private String getArtifactNameMessage()

getMissingSpecificationMessage

private String getMissingSpecificationMessage(String specification)

getMissingImplementationsMessage

private String getMissingImplementationsMessage(String specification)

getMissingImplementationMessage

private String getMissingImplementationMessage(String implementationName,
                                               String specification)

getMissingObjectInstanceMessage

private String getMissingObjectInstanceMessage(Object object)

getMissingDependencyMessage

private String getMissingDependencyMessage(String dependency,
                                           String implementation)

getMissingPropertyMessage

private String getMissingPropertyMessage(String property,
                                         String implementation)

getMissingMessageMessage

private String getMissingMessageMessage(String message,
                                        String implementation)

getMissingClassLoaderMessage

private String getMissingClassLoaderMessage()

getMissingInstanceMessage

private String getMissingInstanceMessage(String implementation,
                                         String implementationName)

getMissingObjectMessage

private String getMissingObjectMessage(String implementation,
                                       String implementationName)

getDependencyCycleMessage

private String getDependencyCycleMessage(String implementation)

getImplementationInfoMessage

private String getImplementationInfoMessage(Long startMillis)

getDefaultScopeInfoMessage

private String getDefaultScopeInfoMessage(String modelScope,
                                          Map objects)

getMissingScopeMessage

private String getMissingScopeMessage(String modelScope)

getRegisteredListenerMessage

private String getRegisteredListenerMessage(String listener)

getUnsupportedMultiplicityMessage

private String getUnsupportedMultiplicityMessage(Multiplicity multiplicity)

getCannotProxySpecificationClassMessage

private String getCannotProxySpecificationClassMessage(String specification,
                                                       String instance)

getDefaultLocatorInfoMessage

private String getDefaultLocatorInfoMessage(String scheme)

getModulesReport

private String getModulesReport(Modules mods)

appendSpecificationInfo

private StringBuilder appendSpecificationInfo(Specification s,
                                              StringBuilder b)

appendImplementationInfo

private StringBuilder appendImplementationInfo(Implementation i,
                                               StringBuilder b)


Copyright © 2005-2009 The JOMC Project. All Rights Reserved.