When are aware interfaces used in Spring?

In the Spring Framework, there exists a plethora of "global" singleton entities (within a given scope) that are not beans. Naturally, not all of them are needed by any one bean, and the usual injection mechanisms do not work for them. However, there must be a way to utilize their functionality.

Aware marker interface serves as the parent for a large number of interfaces with names ending in *Aware. Each of these, when implemented, provides the bean with a specific entity unique to it. For example, a component that needs to access the application context should implement ApplicationContextAware.

Technically, the interfaces themselves do nothing. An interface like FooAware typically declares a single method, void setFoo(Foo value). Through this method, an associated BeanPostProcessor will pass the required entity to the bean.

If a bean implements ServletContextAware, then during the bean’s initialization, the ServletContextAwareProcessor will come along and invoke setServletContext with the servlet context as a parameter.