pt.digitalis.utils.ioc.guice
Class IoCRegistryGuiceImpl

java.lang.Object
  extended by pt.digitalis.utils.ioc.AbstractIoCRegistryImpl
      extended by pt.digitalis.utils.ioc.guice.IoCRegistryGuiceImpl
All Implemented Interfaces:
IIoCRegistry

public class IoCRegistryGuiceImpl
extends AbstractIoCRegistryImpl

The registry for IoC services and contributions. This is the central piece that manages all contributions.

Author:
Pedro Viegas pviegas@digitalis.pt, Rodrigo Gonçalves rgoncalves@digitalis.pt

Field Summary
 
Fields inherited from class pt.digitalis.utils.ioc.AbstractIoCRegistryImpl
instance
 
Method Summary
<T> T
getImplementation(Class<T> serviceClass)
          Returns the implementation of a given interface.
<T> T
getImplementation(Class<T> serviceClass, String id)
          Returns the implementation of a given interface with a given identification.
<T> Map<String,T>
getImplementationsMap(Class<T> serviceClass)
          Returns the list of implementations for the interface with the given ID.
static IIoCRegistry getRegistry()
          Getter for the instance of IIoCRegistry.
static IIoCRegistry getRegistry(Collection<Class<? extends com.google.inject.Module>> modules)
          Getter for the instance of IIoCRegistry.
static IIoCRegistry getRegistry(ModuleParser method)
          Getter for the instance of IIoCRegistry
 void injectDependencies(Object obj)
          Injects dependencies into an object.
 
Methods inherited from class pt.digitalis.utils.ioc.AbstractIoCRegistryImpl
discoverModules, getImplementations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRegistry

public static IIoCRegistry getRegistry()
                                throws IoCException
Getter for the instance of IIoCRegistry. Uses the FAST module parsing method by default.

Returns:
the registry instance
Throws:
IoCException - if the registry object can't be instantiated

getRegistry

public static IIoCRegistry getRegistry(Collection<Class<? extends com.google.inject.Module>> modules)
                                throws IoCException
Getter for the instance of IIoCRegistry. Uses the FAST module parsing method by default. passed.

Parameters:
modules - the IoC modules classes
Returns:
the registry instance
Throws:
IoCException - if the registry object can't be accessed

getRegistry

public static IIoCRegistry getRegistry(ModuleParser method)
                                throws IoCException
Getter for the instance of IIoCRegistry

Parameters:
method - the method for module discovery
Returns:
the registry instance
Throws:
IoCException - if the registry object can't be instantiated

getImplementation

public <T> T getImplementation(Class<T> serviceClass)
Description copied from interface: IIoCRegistry
Returns the implementation of a given interface.

Type Parameters:
T - the service's class
Parameters:
serviceClass - the service's interface type
Returns:
the instance for the service's implementation
See Also:
IIoCRegistry.getImplementation(java.lang.Class)

getImplementation

public <T> T getImplementation(Class<T> serviceClass,
                               String id)
Description copied from interface: IIoCRegistry
Returns the implementation of a given interface with a given identification.

Type Parameters:
T - the service's class
Parameters:
serviceClass - the service's interface type
id - the implementation's id
Returns:
the instance for the service's implementation
See Also:
IIoCRegistry.getImplementation(java.lang.Class, java.lang.String)

getImplementationsMap

public <T> Map<String,T> getImplementationsMap(Class<T> serviceClass)
Description copied from interface: IIoCRegistry
Returns the list of implementations for the interface with the given ID.

Type Parameters:
T - the service's class
Parameters:
serviceClass - the service's interface type
Returns:
a Map with all instances for each implementation of the service as V and the corresponding ID as K
See Also:
IIoCRegistry.getImplementationsMap(java.lang.Class)

injectDependencies

public void injectDependencies(Object obj)
Description copied from interface: IIoCRegistry
Injects dependencies into an object. Used to inject an implementation into an object not created through the IoC framework. Requires the object to be annotated with com.google.inject.Inject.

Parameters:
obj - the object to inject dependencies into
See Also:
IIoCRegistry.injectDependencies(java.lang.Object)


Copyright © 2012 Digitalis Informática Lda. All Rights Reserved.