001/*
002 * Copyright 2002-2015 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.context;
018
019import java.util.EventObject;
020
021/**
022 * Class to be extended by all application events. Abstract as it
023 * doesn't make sense for generic events to be published directly.
024 *
025 * @author Rod Johnson
026 * @author Juergen Hoeller
027 */
028public abstract class ApplicationEvent extends EventObject {
029
030        /** use serialVersionUID from Spring 1.2 for interoperability */
031        private static final long serialVersionUID = 7099057708183571937L;
032
033        /** System time when the event happened */
034        private final long timestamp;
035
036
037        /**
038         * Create a new ApplicationEvent.
039         * @param source the object on which the event initially occurred (never {@code null})
040         */
041        public ApplicationEvent(Object source) {
042                super(source);
043                this.timestamp = System.currentTimeMillis();
044        }
045
046
047        /**
048         * Return the system time in milliseconds when the event happened.
049         */
050        public final long getTimestamp() {
051                return this.timestamp;
052        }
053
054}