资 源 简 介
Publish-Subscribe pattern with annotations for Spring Framework
Summary
Inspired by CDI events, simple Spring library that support bean events. An event object can be any Java object and it is used to propagate state from producer to consumer. Consumer - @Observes events of a specific type and it will be notified of an event if the event object is assignable to the observed event type.
Event interface
The Event interface provides a method for firing events of a specified type.
public interface Event { public void fire(T event);}
To inject event of any type you do following:
@Autowired(required = true)private Event event;
@Observes
To define observer method you simply use @Observes annotation:
```
@Retention(RUNTIME)
@Target(PARAMETER)
@Documented
public @interface Observes {
}
```
Restrictions:
* You use @Observes on