org.apache.cayenne.di
Interface Injector

All Known Implementing Classes:
DefaultInjector

public interface Injector

A facade to the Cayenne DI container. To create an injector use DIBootstrap static methods.

Since:
3.1

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.
 

Method Detail

getInstance

<T> T getInstance(Class<T> type)
              throws ConfigurationException
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.

Throws:
ConfigurationException

getInstance

<T> T getInstance(Key<T> key)
              throws ConfigurationException
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.

Throws:
ConfigurationException

getProvider

<T> Provider<T> getProvider(Class<T> type)
                        throws ConfigurationException
Throws:
ConfigurationException

getProvider

<T> Provider<T> getProvider(Key<T> key)
                        throws ConfigurationException
Throws:
ConfigurationException

injectMembers

void injectMembers(Object object)
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.


shutdown

void shutdown()
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.



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