org.sakaiproject.component.impl
Class SpringCompMgr

java.lang.Object
  extended by org.sakaiproject.component.impl.SpringCompMgr
All Implemented Interfaces:
ComponentManager

public class SpringCompMgr
extends Object
implements ComponentManager

SpringCompMgr manages API implementation components using the Springframework ApplicationContext.

See the org.sakaiproject.api.kernel.component.ComponentManagerinterface for details.


Field Summary
protected static String CLOSE_ON_SHUTDOWN
          System property to control if we close on jvm shutdown (if set) or on the loss of our last child (if not set).
protected static String CONFIGURATION_COMPONENT_PACKAGE
          The Sakai configuration component package, which must be the last defined.
protected static String[] CONFIGURATION_COMPONENTS
          The Sakai configuration components, which must be the first loaded.
protected static String CONFIGURATION_FILE_NAME
           
protected static String DEFAULT_CONFIGURATION_FILE
           
protected  SakaiApplicationContext m_ac
          The Spring Application Context.
protected  int m_childCount
          A count of the # of child AC's that call us parent.
protected  boolean m_hasBeenClosed
          Records that close has been called.
protected  Set m_loadedComponents
          The already created components given to manage (their interface names).
protected static String SHUTDOWN_ON_ERROR
          System property to control if we close the jvm on a error occurring at startup.
 
Fields inherited from interface org.sakaiproject.component.api.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.
 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.
 org.springframework.context.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.
 boolean hasBeenClosed()
          Check if the ComponentManager has already been or is in the processing of being closed.
 void init(boolean lateRefresh)
          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.
 void removeChildAc()
          Decrement the count of ACs that call this one parent.
 void waitTillConfigured()
          Wait right here till the component manager is fully configured.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLOSE_ON_SHUTDOWN

protected static final String CLOSE_ON_SHUTDOWN
System property to control if we close on jvm shutdown (if set) or on the loss of our last child (if not set).

See Also:
Constant Field Values

SHUTDOWN_ON_ERROR

protected static final String SHUTDOWN_ON_ERROR
System property to control if we close the jvm on a error occurring at startup. This is useful to set in development so that it's clearer when the component manager failed to startup.

See Also:
Constant Field Values

CONFIGURATION_COMPONENT_PACKAGE

protected static final String CONFIGURATION_COMPONENT_PACKAGE
The Sakai configuration component package, which must be the last defined.

See Also:
Constant Field Values

CONFIGURATION_COMPONENTS

protected static final String[] CONFIGURATION_COMPONENTS
The Sakai configuration components, which must be the first loaded.


DEFAULT_CONFIGURATION_FILE

protected static final String DEFAULT_CONFIGURATION_FILE
See Also:
Constant Field Values

CONFIGURATION_FILE_NAME

protected static final String CONFIGURATION_FILE_NAME
See Also:
Constant Field Values

m_ac

protected SakaiApplicationContext 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_hasBeenClosed

protected boolean m_hasBeenClosed
Records that close has been called.

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(boolean lateRefresh)
Initialize the component manager.

Parameters:
lateRefresh - If true then don't refresh the application context but leave it up to the caller, this is useful when running tests as it means you can change the application context before everything gets setup. In production systems it should be false.

getApplicationContext

public org.springframework.context.ConfigurableApplicationContext getApplicationContext()
Access the ApplicationContext

Returns:
the ApplicationContext

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.


getCatalina

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

Returns:
Catalina's base or home directory.

getConfig

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

Specified by:
getConfig in interface ComponentManager
Returns:
null

waitTillConfigured

public void waitTillConfigured()
Description copied from interface: ComponentManager
Wait right here till the component manager is fully configured.

Specified by:
waitTillConfigured in interface ComponentManager

hasBeenClosed

public boolean hasBeenClosed()
Description copied from interface: ComponentManager
Check if the ComponentManager has already been or is in the processing of being closed.

Specified by:
hasBeenClosed in interface ComponentManager
Returns:
true if closed, false if not.


Copyright © 2003-2013 The Sakai Foundation. All Rights Reserved.