org.apache.cayenne.di.spi
Class DefaultInjector

java.lang.Object
  extended by org.apache.cayenne.di.spi.DefaultInjector
All Implemented Interfaces:
Injector

public class DefaultInjector
extends Object
implements Injector

A default Cayenne implementations of a DI injector.

Since:
3.1

Constructor Summary
DefaultInjector(Module... modules)
           
 
Method Summary
<T> T
getInstance(Class<T> type)
          Returns a service instance bound in the container for a specific type.
<T> T
getInstance(Key<T> key)
          Returns a service instance bound in the container for a specific binding key.
<T> Provider<T>
getProvider(Class<T> type)
           
<T> Provider<T>
getProvider(Key<T> key)
           
 void injectMembers(Object object)
          Performs field injection on a given object, ignoring constructor injection.
 void shutdown()
          A lifecycle method that let's the injector's services to clean up their state and release resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultInjector

public DefaultInjector(Module... modules)
                throws ConfigurationException
Throws:
ConfigurationException
Method Detail

getInstance

public <T> T getInstance(Class<T> type)
              throws ConfigurationException
Description copied from interface: Injector
Returns a service instance bound in the container for a specific type. Throws ConfigurationException if the type is not bound, or an instance can not be created.

Specified by:
getInstance in interface Injector
Throws:
ConfigurationException

getInstance

public <T> T getInstance(Key<T> key)
              throws ConfigurationException
Description copied from interface: Injector
Returns a service instance bound in the container for a specific binding key. Throws ConfigurationException if the key is not bound, or an instance can not be created.

Specified by:
getInstance in interface Injector
Throws:
ConfigurationException

getProvider

public <T> Provider<T> getProvider(Class<T> type)
                        throws ConfigurationException
Specified by:
getProvider in interface Injector
Throws:
ConfigurationException

getProvider

public <T> Provider<T> getProvider(Key<T> key)
                        throws ConfigurationException
Specified by:
getProvider in interface Injector
Throws:
ConfigurationException

injectMembers

public void injectMembers(Object object)
Description copied from interface: Injector
Performs field injection on a given object, ignoring constructor injection. Since Cayenne DI injector returns fully injected objects, this method is rarely used directly. One possible use is in custom DI providers, another is in unit tests to initialize tested objects that are relying on field injecton.

Specified by:
injectMembers in interface Injector

shutdown

public void shutdown()
Description copied from interface: Injector
A lifecycle method that let's the injector's services to clean up their state and release resources. This method would normally generate a scope end event for the injector's one and only singleton scope.

Specified by:
shutdown in interface Injector


Copyright © 2001-2010 Apache Cayenne. All Rights Reserved.