it's about decoupling and the separation of concerns.
How to use?
add this tag in your application spring.xml
step 1:
add spring bean in spring.xml com.qc.eventbus.spring.SpringEventBus and add init-method="init" and destroy-method="destroy"
step 2:
use eventbus instance like this
eventbus.publish(DemoEvent event);
event is what you are concerned.
step 3:
add @Subscribe annotation on you service method
@Subscribe(async=false) or @Subscribe(async=true)
public void handleDemoEvent(DemoEvent event){
}
async=false the thread is synchronous
async=ture the thread is asynchronous