01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.context;
18:
19: import java.util.EventObject;
20:
21: /**
22: * Class to be extended by all application events. Abstract as it
23: * doesn't make sense for generic events to be published directly.
24: *
25: * @author Rod Johnson
26: * @author Juergen Hoeller
27: */
28: public abstract class ApplicationEvent extends EventObject {
29:
30: /** use serialVersionUID from Spring 1.2 for interoperability */
31: private static final long serialVersionUID = 7099057708183571937L;
32:
33: /** System time when the event happened */
34: private final long timestamp;
35:
36: /**
37: * Create a new ApplicationEvent.
38: * @param source the component that published the event (never <code>null</code>)
39: */
40: public ApplicationEvent(Object source) {
41: super (source);
42: this .timestamp = System.currentTimeMillis();
43: }
44:
45: /**
46: * Return the system time in milliseconds when the event happened.
47: */
48: public final long getTimestamp() {
49: return this.timestamp;
50: }
51:
52: }
|