View RSS Feed

Spring Framework

Spring Event Handling

Rate this Entry
by , 07-07-2012 at 07:26 PM (1865 Views)
The ApplicationEvent class and ApplicationListener interface provide the event handling in the ApplicationContext.For each ApplicationEvents that is published to ApplicationContext the bean which has implemented the ApplicationListener is notified.

Following events are provided by the Spring.

ContextRefreshedEvent: At the initializion or refreshing of ApplicationContext, ContextRefreshedEvent is generated. Also the refresh() method is used to generate this event on ConfigurableApplicationContext interface.
ContextStartedEvent: When the start() method is used to start the ApplicationContext on ConfigurableApplicationContext interface, this event is generated. This event is used to start or restart any application and database polling.
ContextStoppedEvent: When the stop() method is used to stop the ApplicationContext on ConfigurableApplicationContext, this event is generated. This event can be used to perform necessary housekeeping work.
ContextClosedEvent: When the close() method is used to close the ApplicationContext on ConfigurableApplicationContext, this event is generated. The context cannot be restarted or refreshed after it is closed.
RequestHandledEvent: When a HTTP request is services, this event is generated.

All the processes are blocked until all event receivers get the event message as event handling is single threaded. The flow is stoped and processes will be blocked.

Submit "Spring Event Handling" to Facebook Submit "Spring Event Handling" to Digg Submit "Spring Event Handling" to del.icio.us Submit "Spring Event Handling" to StumbleUpon Submit "Spring Event Handling" to Google

Categories
Event

Comments