Class SimpleInjector

  extended by org.wamblee.inject.SimpleInjector
All Implemented Interfaces:

public class SimpleInjector
extends java.lang.Object
implements Injector

The main entry point for programmatic dependency injection. A different InjectorFactory can be plugged in for testing.

Given the following class:

   class Pojo {
     private Service service; 
injecting the EJB into a POJO is accomplished as follows:
 Pojo pojo = new Pojo();
 SimpleInjector injector = new SimpleInjector(InjectorFactoryBuilder
Of course, the above example assumes the the injector understands the @EJB annotation (which of course CDI does). The SimpleInjector should be cached. This is because the SimpleInjector caches the Injector objects that it uses internally for performance. This is done because creation of these internal Injector objects may be costly. Caching the simple injector makes sure that a class is not analysed again for annotations every time injection is used. For more advanced cases, the injector factory can also be directly constructed instead of being obtained through the InjectorBuilder.

Erik Brakkee

Constructor Summary
SimpleInjector(InjectorFactory aFactory)
          Constructs the injector.
Method Summary
 void inject(java.lang.Object aObject)
          Injects into a given object.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public SimpleInjector(InjectorFactory aFactory)
Constructs the injector.

aFactory - Factory to use.
Method Detail


public void inject(java.lang.Object aObject)
Injects into a given object.

Specified by:
inject in interface Injector
aObject - Object to inject into.

Copyright © 2022. All Rights Reserved.