View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   
6   package com.hack23.cia.web.controller.application;
7   
8   import org.apache.commons.logging.Log;
9   import org.apache.commons.logging.LogFactory;
10  import org.springframework.context.ApplicationEvent;
11  import org.springframework.context.ApplicationListener;
12  import org.springframework.context.event.ApplicationContextEvent;
13  
14  /***
15   * The Class ApplicationEventHandler.
16   */
17  public class ApplicationEventHandler implements ApplicationListener<ApplicationEvent> {
18  
19      /*** The Constant LOGGER. */
20      private static final Log LOGGER = LogFactory
21              .getLog(ApplicationEventHandler.class);
22  
23      /***
24       * Instantiates a new application event handler.
25       */
26      public ApplicationEventHandler() {
27      }
28  
29      /*
30       * (non-Javadoc)
31       * 
32       * @see
33       * org.springframework.context.ApplicationListener#onApplicationEvent(org
34       * .springframework.context.ApplicationEvent)
35       */
36      @Override
37  	public final void onApplicationEvent(final ApplicationEvent event) {
38          if (event instanceof ApplicationContextEvent) {
39              final ApplicationContextEvent applicationContextEvent = (ApplicationContextEvent) event;
40              LOGGER
41                      .info("Application event : " + applicationContextEvent.toString()); //$NON-NLS-1$
42          } else {
43              LOGGER.warn("Unhandled event " + event); //$NON-NLS-1$
44          }
45      }
46  }