Package org.sakaiproject.component.impl
Class MockCompMgr
- java.lang.Object
-
- org.sakaiproject.component.impl.MockCompMgr
-
- All Implemented Interfaces:
ComponentManager
public class MockCompMgr extends Object implements ComponentManager
This is a totally fake component manager which is just going to pretend to try to find services, maybe later this could try to use the sakai mock stuff but for now it is just here to stop the CM from firing up during unit tests
-
-
Field Summary
Fields Modifier and Type Field Description ConcurrentHashMap<String,Object>componentsNot really needed but this allows us to at least put fake ones into this CM for tests if we like-
Fields inherited from interface org.sakaiproject.component.api.ComponentManager
SAKAI_COMPONENTS_ROOT_SYS_PROP
-
-
Constructor Summary
Constructors Constructor Description MockCompMgr(boolean loadMocks)Startup the CM as a mock system for unit tests
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.PropertiesgetConfig()Access the configuration properties used when configuring components.Set<String>getRegisteredInterfaces()Get all interfaces registered in the component manager.booleanhasBeenClosed()Check if the ComponentManager has already been or is in the processing of being closed.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.voidwaitTillConfigured()Wait right here till the component manager is fully configured.
-
-
-
Field Detail
-
components
public ConcurrentHashMap<String,Object> components
Not really needed but this allows us to at least put fake ones into this CM for tests if we like
-
-
Method Detail
-
close
public void close()
Description copied from interface:ComponentManagerClose the component manager, shutting down any created singletons.- Specified by:
closein 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.
-
contains
public boolean contains(Class iface)
Description copied from interface:ComponentManagerCheck 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)
Description copied from interface:ComponentManagerCheck 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.
-
get
public <T> T get(Class<T> iface)
Description copied from interface:ComponentManagerFind 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)
Description copied from interface:ComponentManagerFind 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.
-
getConfig
public Properties getConfig()
Description copied from interface:ComponentManagerAccess the configuration properties used when configuring components.- Specified by:
getConfigin interfaceComponentManager- Returns:
- null
-
getRegisteredInterfaces
public Set<String> getRegisteredInterfaces()
Description copied from interface:ComponentManagerGet 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.
-
loadComponent
public void loadComponent(Class iface, Object component)
Description copied from interface:ComponentManagerLoad 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)
Description copied from interface:ComponentManagerLoad 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.
-
waitTillConfigured
public void waitTillConfigured()
Description copied from interface:ComponentManagerWait right here till the component manager is fully configured.- Specified by:
waitTillConfiguredin interfaceComponentManager
-
-