Used to annotate a method as one that is used to inject a registered component into another component. The component
to be constructed must be built using the
method, or if your object
that needs components injected into it already exists, it can be built using the
public class MyClass
private TransactionManager tm;
private BuddyManager bm;
private Notifier n;
public void setTransactionManager(TransactionManager tm)
this.tm = tm;
public void injectMoreStuff(BuddyManager bm, Notifier n)
this.bm = bm;
this.n = n;
and an instance of this class can be constructed and wired using
MyClass myClass = componentFactory.construct(MyClass.class); // instance will have dependencies injected.
Methods annotated with this Inject annotation should *only* set class fields. They should do nothing else.
If you need to do some work to prepare the component for use, do it in a
method since this is only
called once when a component starts.