de.upb.swtpra05.group03.shuttle
Class ModuleContainer

java.lang.Object
  extended byde.upb.swtpra05.group03.shuttle.ModuleContainer
All Implemented Interfaces:
ModuleContainerInterface

public class ModuleContainer
extends java.lang.Object
implements ModuleContainerInterface

This is the main class of the service / dependency mapping system of Modules, it's the container for objects to map them with their class, super classes and all interfaces so they can be used to fulfill service dependencies of Modules at their initialization to avoid circular dependencies. For each mapping key (class / interface) there is a list of all objects that are instances of them, the list is ordered by adding order.

Version:
$Revision: 1.3 $

Field Summary
private static java.util.logging.Logger log
          Logger for debugging
private  java.util.Map modules
          map of modules with their class, super classes and interfaces as key
 
Constructor Summary
ModuleContainer()
          Constructor
 
Method Summary
protected  void add(java.lang.Class c, java.lang.Object obj)
          For internal use only: Adds an object with an class as key.
 void add(java.lang.Object obj)
          Adds an object with its class, super classes and interfaces as key.
 java.lang.Object get(java.lang.Class aClass)
          Returns the instance of given class / interface or -- if more than one instance is present and a interface is given -- returns a java.lang.reflect.Proxy instance of given interface which delegates any method calls to all instances of given interface with the return value of the first instance.
 java.util.List getAll(java.lang.Class aClass)
          Returns all instances of given class / interface.
 java.lang.Object getFirst(java.lang.Class aClass)
          Returns the first instance of given class / interface.
 void init()
          Initializes all contained the Modules.
protected  void put(java.lang.Class c, java.lang.Object obj)
          For internal use only: Puts the object with the class as key in the internal map of modules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log
Logger for debugging


modules

private final java.util.Map modules
map of modules with their class, super classes and interfaces as key

Constructor Detail

ModuleContainer

public ModuleContainer()
Constructor

Method Detail

init

public void init()
Initializes all contained the Modules.


add

public void add(java.lang.Object obj)
Adds an object with its class, super classes and interfaces as key.

Parameters:
obj -

add

protected void add(java.lang.Class c,
                   java.lang.Object obj)
For internal use only: Adds an object with an class as key. This method is called recursively for all super classes and all interfaces.

Parameters:
c - class as key of the object
obj - object to add

put

protected void put(java.lang.Class c,
                   java.lang.Object obj)
For internal use only: Puts the object with the class as key in the internal map of modules.

Parameters:
c - class as key of the object
obj - object to add

get

public java.lang.Object get(java.lang.Class aClass)
Description copied from interface: ModuleContainerInterface
Returns the instance of given class / interface or -- if more than one instance is present and a interface is given -- returns a java.lang.reflect.Proxy instance of given interface which delegates any method calls to all instances of given interface with the return value of the first instance.

Specified by:
get in interface ModuleContainerInterface
Parameters:
aClass - class / interface of instance to return
Returns:
instance of given class / interface or proxy instance of given interface

getFirst

public java.lang.Object getFirst(java.lang.Class aClass)
Description copied from interface: ModuleContainerInterface
Returns the first instance of given class / interface.

Specified by:
getFirst in interface ModuleContainerInterface
Parameters:
aClass - class / interface of instance to return
Returns:
the first instance of given class / interface

getAll

public java.util.List getAll(java.lang.Class aClass)
Description copied from interface: ModuleContainerInterface
Returns all instances of given class / interface.

Specified by:
getAll in interface ModuleContainerInterface
Parameters:
aClass - class / interface of instances to return
Returns:
all instances of given class/interface as list