Package org.sakaiproject.component.impl
Class SpringCompMgr
- java.lang.Object
-
- 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
ComponentManagerinterface for details.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringCLOSE_ON_SHUTDOWNSystem property to control if we close on jvm shutdown (if set) or on the loss of our last child (if not set).protected static StringCONFIGURATION_COMPONENT_PACKAGEThe Sakai configuration component package, which must be the last defined.protected static String[]CONFIGURATION_COMPONENTSThe Sakai configuration components, which must be the first loaded.protected static StringCONFIGURATION_FILE_NAMEprotected static StringDEFAULT_CONFIGURATION_FILEprotected booleanlateRefreshprotected SakaiApplicationContextm_acThe Spring Application Context.protected intm_childCountA count of the # of child AC's that call us parent.protected booleanm_hasBeenClosedRecords that close has been called.protected Setm_loadedComponentsThe already created components given to manage (their interface names).protected static StringSHUTDOWN_ON_ERRORSystem 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
Constructors Constructor Description SpringCompMgr(ComponentManager parent)Initialize.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChildAc()Increment the count of ACs that call this one parent.voidclose()Close the component manager, shutting down any created singletons.booleancontains(Class iface)Check if this interface Class has a registered component.booleancontains(String ifaceName)Check if this interface Class name has a registered component.<T> Tget(Class<T> iface)Find a component that is registered to provide this interface.Objectget(String ifaceName)Find a component that is registered to provide this interface.org.springframework.context.ConfigurableApplicationContextgetApplicationContext()Access the ApplicationContextprotected StringgetCatalina()Check the environment for catalina's base or home directory.PropertiesgetConfig()Access the configuration properties used when configuring components.SetgetRegisteredInterfaces()Get all interfaces registered in the component manager.booleanhasBeenClosed()Check if the ComponentManager has already been or is in the processing of being closed.voidinit(boolean lateRefresh)Initialize the component manager.voidloadComponent(Class iface, Object component)Load a singleton already created component for this interface class as a singleton.voidloadComponent(String ifaceName, Object component)Load a singleton already created component for this interface class as a singleton.protected voidloadComponents()Locate the component loader, and load any available components.voidremoveChildAc()Decrement the count of ACs that call this one parent.voidwaitTillConfigured()Wait right here till the component manager is fully configured.
-
-
-
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.
-
lateRefresh
protected boolean lateRefresh
-
-
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- Iftruethen 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 befalse.
-
getApplicationContext
public org.springframework.context.ConfigurableApplicationContext getApplicationContext()
Access the ApplicationContext- Returns:
- the ApplicationContext
-
get
public <T> T get(Class<T> iface)
Find a component that is registered to provide this interface.- Specified by:
getin interfaceComponentManager- 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:
getin interfaceComponentManager- 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:
containsin interfaceComponentManager- 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:
containsin interfaceComponentManager- 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:
getRegisteredInterfacesin interfaceComponentManager- 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:
closein interfaceComponentManager
-
loadComponent
public void loadComponent(Class iface, Object component)
Load a singleton already created component for this interface class as a singleton.- Specified by:
loadComponentin interfaceComponentManager- 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:
loadComponentin interfaceComponentManager- 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:ComponentManagerAccess the configuration properties used when configuring components.- Specified by:
getConfigin interfaceComponentManager- Returns:
- null
-
waitTillConfigured
public void waitTillConfigured()
Description copied from interface:ComponentManagerWait right here till the component manager is fully configured.- Specified by:
waitTillConfiguredin interfaceComponentManager
-
hasBeenClosed
public boolean hasBeenClosed()
Description copied from interface:ComponentManagerCheck if the ComponentManager has already been or is in the processing of being closed.- Specified by:
hasBeenClosedin interfaceComponentManager- Returns:
- true if closed, false if not.
-
-