org.sakaiproject.component.impl
Class MockCompMgr

java.lang.Object
  extended by 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
 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
 
Fields inherited from interface org.sakaiproject.component.api.ComponentManager
SAKAI_COMPONENTS_ROOT_SYS_PROP
 
Constructor Summary
MockCompMgr(boolean loadMocks)
          Startup the CM as a mock system for unit tests
 
Method Summary
 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.
 Properties getConfig()
          Access the configuration properties used when configuring components.
 Set<String> 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 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.
 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

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

Constructor Detail

MockCompMgr

public MockCompMgr(boolean loadMocks)
Startup the CM as a mock system for unit tests

Method Detail

close

public void close()
Description copied from interface: ComponentManager
Close the component manager, shutting down any created singletons.

Specified by:
close 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.

contains

public boolean contains(Class iface)
Description copied from interface: ComponentManager
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)
Description copied from interface: ComponentManager
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.

get

public Object get(Class iface)
Description copied from interface: ComponentManager
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)
Description copied from interface: ComponentManager
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.

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

getRegisteredInterfaces

public Set<String> getRegisteredInterfaces()
Description copied from interface: ComponentManager
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.

loadComponent

public void loadComponent(Class iface,
                          Object component)
Description copied from interface: ComponentManager
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)
Description copied from interface: ComponentManager
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.

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


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