Annotation Type Inject

  • @Retention(CLASS)
    public @interface Inject
    Used to annotate a method or field as an injection point.

    The method or field must not be private, usually it's best to have it package-private.

    Usage example:

           public class MyClass
              private TransactionManager tm;
              private BuddyManager bm;
              private Notifier n;
              public void setTransactionManager(TransactionManager tm)
        = tm;
              public void injectMoreStuff(BuddyManager bm, Notifier n)
        = bm;
                 this.n = n;
    and an instance of this class can be constructed and wired using
           MyClass myClass = componentRegistry.getComponent(MyClass.class);
    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 Start method since this is only called once when a component starts.
    Manik Surtani