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

17 package org.apache.catalina;
18
19 import java.util.EventObject;
20
21 /**
22  * General event for notifying listeners of significant changes on a Container.
23  *
24  * @author Craig R. McClanahan
25  */

26 public final class ContainerEvent extends EventObject {
27
28     private static final long serialVersionUID = 1L;
29
30     /**
31      * The event data associated with this event.
32      */

33     private final Object data;
34
35
36     /**
37      * The event type this instance represents.
38      */

39     private final String type;
40
41
42     /**
43      * Construct a new ContainerEvent with the specified parameters.
44      *
45      * @param container Container on which this event occurred
46      * @param type Event type
47      * @param data Event data
48      */

49     public ContainerEvent(Container container, String type, Object data) {
50         super(container);
51         this.type = type;
52         this.data = data;
53     }
54
55
56     /**
57      * Return the event data of this event.
58      *
59      * @return The data, if any, associated with this event.
60      */

61     public Object getData() {
62         return this.data;
63     }
64
65
66     /**
67      * Return the Container on which this event occurred.
68      *
69      * @return The Container on which this event occurred.
70      */

71     public Container getContainer() {
72         return (Container) getSource();
73     }
74
75
76     /**
77      * Return the event type of this event.
78      *
79      * @return The event type of this event. Although this is a String, it is
80      *         safe to rely on the value returned by this method remaining
81      *         consistent between point releases.
82      */

83     public String getType() {
84         return this.type;
85     }
86
87
88     /**
89      * Return a string representation of this event.
90      */

91     @Override
92     public String toString() {
93         return "ContainerEvent['" + getContainer() + "','" +
94                 getType() + "','" + getData() + "']";
95     }
96 }
97