@Retention(value=RUNTIME) @Target(value=METHOD) public @interface Inject
ComponentFactory.construct(Class)
method, or if your object that needs
components injected into it already exists, it can be built using the ComponentRegistry.wireDependencies(Object)
method.
Usage example:
public class MyClass { private TransactionManager tm; private BuddyManager bm; private Notifier n; &Inject public void setTransactionManager(TransactionManager tm) { this.tm = tm; } &Inject 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.
Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.