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 component
23 * that implements the Lifecycle interface.
24 *
25 * @author Craig R. McClanahan
26 */
27 public final class LifecycleEvent extends EventObject {
28
29 private static final long serialVersionUID = 1L;
30
31
32 /**
33 * Construct a new LifecycleEvent with the specified parameters.
34 *
35 * @param lifecycle Component on which this event occurred
36 * @param type Event type (required)
37 * @param data Event data (if any)
38 */
39 public LifecycleEvent(Lifecycle lifecycle, String type, Object data) {
40 super(lifecycle);
41 this.type = type;
42 this.data = data;
43 }
44
45
46 /**
47 * The event data associated with this event.
48 */
49 private final Object data;
50
51
52 /**
53 * The event type this instance represents.
54 */
55 private final String type;
56
57
58 /**
59 * @return the event data of this event.
60 */
61 public Object getData() {
62 return data;
63 }
64
65
66 /**
67 * @return the Lifecycle on which this event occurred.
68 */
69 public Lifecycle getLifecycle() {
70 return (Lifecycle) getSource();
71 }
72
73
74 /**
75 * @return the event type of this event.
76 */
77 public String getType() {
78 return this.type;
79 }
80 }
81