MessageEvent.java
01 /**
02  *
03  * All content copyright (c) 2003-2008 Terracotta, Inc.,
04  * except as may otherwise be noted in a separate copyright notice.
05  * All rights reserved.
06  *
07  */
08 package demo.events;
09 
10 import java.util.Date;
11 import org.springframework.context.ApplicationContext;
12 import org.springframework.context.ApplicationEvent;
13 
14 /**
15  *  Simple message event, this will be distributed by Terracotta for Spring
16  *  and sent to each of the nodes in the cluster whenever this event is sent
17  *  via the {@link ApplicationContext#publishEvent(ApplicationEvent)} method.
18  *
19  *@author    Terracotta, Inc.
20  */
21 public class MessageEvent
22        extends ApplicationEvent {
23    private final String message;
24 
25    public MessageEvent(Object source, String message) {
26       super(source);
27       this.message = message;
28    }
29 
30    public String getMessage() {
31       return message;
32    }
33 
34    public Date getDate() {
35       return new Date(getTimestamp());
36    }
37 
38    public String toString() {
39       return message;
40    }
41 }