org.sakaiproject.component.kernel.component
Class SpringCompMgr

java.lang.Object
  extended byorg.sakaiproject.component.kernel.component.SpringCompMgr
All Implemented Interfaces:
ComponentManager

public class SpringCompMgr
extends Object
implements ComponentManager

SpringCompMgr manages API implementation components using the Springframework ApplicationContext.

See the ComponentManagerinterface for details.

Author:
Sakai Software Development Team

Field Summary
protected  ConfigurableApplicationContext m_ac
          The Spring Application Context.
protected  int m_childCount
          A count of the # of child AC's that call us parent.
protected  Properties m_config
          A set of properties used when configuring components.
protected  Set m_loadedComponents
          The already created components given to manage (their interface names).
 
Fields inherited from interface org.sakaiproject.api.kernel.component.ComponentManager
SAKAI_COMPONENTS_ROOT_SYS_PROP
 
Constructor Summary
SpringCompMgr(ComponentManager parent)
          Initialize.
 
Method Summary
 void addChildAc()
          Increment the count of ACs that call this one parent.
 void close()
          Close the component manager, shutting down any created singletons.
 boolean contains(Class iface)
          Check if this interface Class has a registered component.
 boolean contains(String ifaceName)
          Check if this interface Class name has a registered component.
protected  void finalize()
          Finalize.
 Object get(Class iface)
          Find a component that is registered to provide this interface.
 Object get(String ifaceName)
          Find a component that is registered to provide this interface.
 ConfigurableApplicationContext getApplicationContext()
          Access the ApplicationContext
protected  String getCatalina()
          Check the environment for catalina's base or home directory.
 Properties getConfig()
          Access the configuration properties used when configuring components.
 Set getRegisteredInterfaces()
          Get all interfaces registered in the component manager.
 void init()
          Initialize the component manager.
 void loadComponent(Class iface, Object component)
          Load a singleton already created component for this interface class as a singleton.
 void loadComponent(String ifaceName, Object component)
          Load a singleton already created component for this interface class as a singleton.
protected  void loadComponents()
          Locate the component loader, and load any available components.
protected  void promotePropertiesToSystem(Properties props)
          If the properties has any of the values we need to set as sakai system properties, set them.
 void removeChildAc()
          Decrement the count of ACs that call this one parent.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_ac

protected ConfigurableApplicationContext m_ac
The Spring Application Context.


m_loadedComponents

protected Set m_loadedComponents
The already created components given to manage (their interface names).


m_childCount

protected int m_childCount
A count of the # of child AC's that call us parent.


m_config

protected Properties m_config
A set of properties used when configuring components.

Constructor Detail

SpringCompMgr

public SpringCompMgr(ComponentManager parent)
Initialize.

Parameters:
parent - A ComponentManager in which this one gets nested, or NULL if this is this top one.
Method Detail

init

public void init()
Initialize the component manager.


getApplicationContext

public ConfigurableApplicationContext getApplicationContext()
Access the ApplicationContext

Returns:
the ApplicationContext

finalize

protected void finalize()
Finalize.


get

public Object get(Class iface)
Find a component that is registered to provide this interface.

Specified by:
get in interface ComponentManager
Parameters:
iface - The interface Class.
Returns:
a component instance, or null if not found.

get

public Object get(String ifaceName)
Find a component that is registered to provide this interface.

Specified by:
get in interface ComponentManager
Parameters:
ifaceName - The fully qualified interface Class name.
Returns:
a component instance, or null if not found.

contains

public boolean contains(Class iface)
Check if this interface Class has a registered component.

Specified by:
contains in interface ComponentManager
Parameters:
iface - The interface Class.
Returns:
true if this interface Class has a registered component, false if not.

contains

public boolean contains(String ifaceName)
Check if this interface Class name has a registered component.

Specified by:
contains in interface ComponentManager
Parameters:
ifaceName - The fully qualified interface Class name.
Returns:
true if this interface has a registered component, false if not.

getRegisteredInterfaces

public Set getRegisteredInterfaces()
Get all interfaces registered in the component manager.

Specified by:
getRegisteredInterfaces in interface ComponentManager
Returns:
A Set (String class name) of all interfaces registered in the component manager.

close

public void close()
Close the component manager, shutting down any created singletons.

Specified by:
close in interface ComponentManager

loadComponent

public void loadComponent(Class iface,
                          Object component)
Load a singleton already created component for this interface class as a singleton.

Specified by:
loadComponent in interface ComponentManager
Parameters:
iface - The interface class.
component - The alread created component.

loadComponent

public void loadComponent(String ifaceName,
                          Object component)
Load a singleton already created component for this interface class as a singleton.

Specified by:
loadComponent in interface ComponentManager
Parameters:
ifaceName - The fully qualified interface Class name.
component - The alread created component.

loadComponents

protected void loadComponents()
Locate the component loader, and load any available components.


addChildAc

public void addChildAc()
Increment the count of ACs that call this one parent.


removeChildAc

public void removeChildAc()
Decrement the count of ACs that call this one parent. When we reach 0,


getCatalina

protected String getCatalina()
Check the environment for catalina's base or home directory.

Returns:
Catalina's base or home directory.

promotePropertiesToSystem

protected void promotePropertiesToSystem(Properties props)
If the properties has any of the values we need to set as sakai system properties, set them.

Parameters:
props - The property override configurer with some override settings.

getConfig

public Properties getConfig()
Description copied from interface: ComponentManager
Access the configuration properties used when configuring components.

Specified by:
getConfig in interface ComponentManager
Returns:
The Properties with the configuration values used when configuring components.