Index > Features > Annotation based Dependency Injection > Other Annotations

Optional Annotations

In addition to those defined in JSR 250, the following annotations MAY be handled by the container.


Indicates that a method call could actually be performed asynchronously in the background using a proxy of some kind to avoid blocking the calling thread.


Allow POJOs to be marked as being singletons so that an IoC container does not create multiple instances of them.


Used to mark a property or field as optional; but also allow indication of the name you'd like to use in JNDI to look it up if it is available.


In most containers; Spring, SCA, JNDI, EJB3 - there is typically a logical name of a POJO; so we should be able to mark a String setter as being @NameAware so that the name can be injected


The following are just ideas for future consideration


Various things like JNDI contexts or MBeanServer and the like are often singletons for a given POJOs context. We could have annotations like @ContextAware and @ApplicationContextAware and @MBeanServerAware; but maybe we just need to mark things as being auto-wired by default by the container? This could be very useful to deal with

  • JNDI Context
  • JMX MBeanServer
  • Spring ApplicationContext


Used to indicate that a POJO is really a factory bean in the Spring sense; the @Factory annotation is applied to a public method on the POJO indicating that the factory method should be called to actually create the object.