KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > spring > bean > SimpleListener


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4
5 package com.tctest.spring.bean;
6
7 import org.springframework.context.ApplicationEvent;
8 import org.springframework.context.ApplicationListener;
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.Date JavaDoc;
12 import java.util.List JavaDoc;
13
14
15 public class SimpleListener implements ApplicationListener {
16     private transient List JavaDoc events = new ArrayList JavaDoc();
17     private Date JavaDoc lastEventTime;
18
19     public List JavaDoc getEvents() {
20       return this.events;
21     }
22     
23     // ApplicationListener
24

25     public void onApplicationEvent(ApplicationEvent event) {
26       if(event instanceof SingletonEvent) {
27         System.out.println("Got SingletonEvent: " + event);
28         this.events.add(event);
29         this.lastEventTime = new Date JavaDoc();
30       } else {
31         System.out.println("Got some other kind of event: " + event);
32       }
33     }
34     
35     public Date JavaDoc getLastEventTime() {
36         return lastEventTime;
37     }
38 }
39
40
Popular Tags