KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > event > CayenneEvent


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20
21 package org.apache.cayenne.event;
22
23 import java.util.Collections JavaDoc;
24 import java.util.EventObject JavaDoc;
25 import java.util.Map JavaDoc;
26
27 /**
28  * Common superclass for events passed from the EventManager to Listeners; encapsulates
29  * optional event information.
30  *
31  * @author Dirk Olmes
32  * @author Holger Hoffstaette
33  */

34 public class CayenneEvent extends EventObject JavaDoc {
35
36     protected Map JavaDoc info;
37     protected transient Object JavaDoc postedBy;
38     protected EventSubject subject;
39
40     public CayenneEvent(Object JavaDoc source) {
41         this(source, null);
42     }
43
44     public CayenneEvent(Object JavaDoc source, Map JavaDoc info) {
45         this(source, source, info);
46     }
47
48     /**
49      * Creates CayenneEvent with possibly different event source and poster. This may be
50      * the case when an event is resent by listener.
51      *
52      * @since 1.1
53      */

54     public CayenneEvent(Object JavaDoc source, Object JavaDoc postedBy, Map JavaDoc info) {
55         super(source);
56         this.postedBy = postedBy;
57         this.info = info;
58     }
59
60     public Map JavaDoc getInfo() {
61         return info != null ? info : Collections.EMPTY_MAP;
62     }
63
64     /**
65      * @since 1.2
66      */

67     public EventSubject getSubject() {
68         return subject;
69     }
70
71     /**
72      * @since 1.2
73      */

74     public void setSubject(EventSubject subject) {
75         this.subject = subject;
76     }
77
78     /**
79      * Used when deserializing remote events.
80      */

81     void setSource(Object JavaDoc source) {
82         super.source = source;
83     }
84
85     /**
86      * Returns an object that posted this event. It may be different from event source, if
87      * event is reposted multiple times.
88      */

89     public Object JavaDoc getPostedBy() {
90         return postedBy;
91     }
92
93     public void setPostedBy(Object JavaDoc postedBy) {
94         this.postedBy = postedBy;
95     }
96 }
97
Popular Tags