net.sf.mmm.util.component.impl
Class SpringContainer

java.lang.Object
  extended by net.sf.mmm.util.component.impl.SpringContainer
All Implemented Interfaces:
IocContainer

public class SpringContainer
extends Object
implements IocContainer

This is the implementation of the IocContainer using spring.
ATTENTION:
Please check your dependencies as spring is an optional dependency in mmm-util-core.

Since:
2.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
private  org.springframework.context.ConfigurableApplicationContext applicationContext
          The ConfigurableApplicationContext to delegate to.
 
Constructor Summary
SpringContainer()
          The constructor.
SpringContainer(org.springframework.context.ConfigurableApplicationContext applicationContext)
          The constructor.
SpringContainer(String... packages)
          The constructor.
 
Method Summary
 void dispose()
          This method disposes the container (performs a shutdown and destroys all components).
<COMPONENT_API>
COMPONENT_API
getComponent(Class<COMPONENT_API> apiClass)
          This method gets the component that realizes the given apiClass.
<COMPONENT_API>
COMPONENT_API
getComponent(Class<COMPONENT_API> apiClass, String componentId)
          This method gets the component that realizes the given apiClass and is registered under the given componentId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

applicationContext

private final org.springframework.context.ConfigurableApplicationContext applicationContext
The ConfigurableApplicationContext to delegate to.

Constructor Detail

SpringContainer

public SpringContainer()
The constructor.


SpringContainer

public SpringContainer(String... packages)
The constructor.

Parameters:
packages - are the Packages containing components to manage.

SpringContainer

public SpringContainer(org.springframework.context.ConfigurableApplicationContext applicationContext)
The constructor.

Parameters:
applicationContext - is the ConfigurableApplicationContext to adapt.
Method Detail

getComponent

public <COMPONENT_API> COMPONENT_API getComponent(Class<COMPONENT_API> apiClass)
This method gets the component that realizes the given apiClass.

Specified by:
getComponent in interface IocContainer
Type Parameters:
COMPONENT_API - is the generic type of the apiClass.
Parameters:
apiClass - is the class reflecting the API of the requested component. This should be an interface.
Returns:
the requested component.

getComponent

public <COMPONENT_API> COMPONENT_API getComponent(Class<COMPONENT_API> apiClass,
                                                  String componentId)
This method gets the component that realizes the given apiClass and is registered under the given componentId.

Specified by:
getComponent in interface IocContainer
Type Parameters:
COMPONENT_API - is the generic type of the apiClass.
Parameters:
apiClass - is the class reflecting the API of the requested component. This should be an interface.
componentId - is the unique ID under which the component is registered in this container.
Returns:
the requested component.

dispose

public void dispose()
This method disposes the container (performs a shutdown and destroys all components).

Specified by:
dispose in interface IocContainer


Copyright © 2001-2010 mmm-Team. All Rights Reserved.