KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > event > MonitoringEvent


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /**
25  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
26  *
27  * Copyright 2001-2002 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  */

31 package com.sun.enterprise.admin.event;
32
33 import com.sun.enterprise.admin.event.AdminEvent;
34
35 /**
36  * Monitoring Event. A monitoring event should trigger start, stop or
37  * collection of monitoring data for specified component.
38  */

39 public class MonitoringEvent extends AdminEvent {
40
41     /**
42      * Constant denoting action of monitoring start
43      */

44     public static final String JavaDoc START_MONITORING = "start_monitoring";
45
46     /**
47      * Constant denoting action of monitoring stop
48      */

49     public static final String JavaDoc STOP_MONITORING = "stop_monitoring";
50
51     /**
52      * Constant denoting action of get monitoring data (collection of data)
53      */

54     public static final String JavaDoc GET_MONITOR_DATA = "get_monitoring";
55
56     /**
57      * Constant denoting action of list monitorable components
58      */

59     public static final String JavaDoc LIST_MONITORABLE = "list_monitorable";
60
61     /**
62      * Constant denoting action of set (for TxnMgr admin currently)
63      */

64     public static final String JavaDoc SET_MONITOR_DATA = "set_monitoring";
65
66     /**
67      * Event type
68      */

69     static final String JavaDoc eventType = MonitoringEvent.class.getName();
70
71     private String JavaDoc componentName;
72     private String JavaDoc actionCode;
73     private Object JavaDoc command;
74
75     /**
76      * Create a new MonitoringEvent.
77      * @param instance name of the server instance to which this event applies
78      * @param component name of the server component to which this event applies
79      * @param action monitoring action, one of MonitoringEvent.START_MONITORING,
80      * MonitoringEvent.STOP_MONITORING, MonitoringEvent.GET_MONITOR_DATA,
81      * MonitoringEvent.LIST_MONITORABLE
82      */

83     public MonitoringEvent(String JavaDoc instance, String JavaDoc component, String JavaDoc action) {
84         this(instance, component, action, null);
85     }
86
87     /**
88      * Create a new MonitoringEvent.
89      * @param instance name of the server instance to which this event applies
90      * @param component name of the server component to which this event applies
91      * @param action monitoring action, one of MonitoringEvent.START_MONITORING,
92      * MonitoringEvent.STOP_MONITORING, MonitoringEvent.GET_MONITOR_DATA,
93      * MonitoringEvent.LIST_MONITORABLE
94      * @param command a monitoring command. Command is extra information that
95      * is used in monitoring event listeners. This is typically an
96      * instance of com.sun.enterprise.admin.monitor.MonitorCommand (or its
97      * sub-class) and may be null.
98      */

99     public MonitoringEvent(String JavaDoc instance, String JavaDoc component, String JavaDoc action,
100             Object JavaDoc command) {
101         super(eventType, instance);
102         componentName = component;
103         actionCode = action;
104         this.command = command;
105     }
106
107     /**
108      * Get name of component to which this event applies.
109      */

110     public String JavaDoc getComponentName() {
111         return componentName;
112     }
113
114     /**
115      * Get event action code - one of MonitoringEvent.START_MONITORING,
116      * MonitoringEvent.STOP_MONITORING, MonitoringEvent.GET_MONITOR_DATA,
117      * MonitoringEvent.LIST_MONITORABLE
118      */

119     public String JavaDoc getActionCode() {
120         return actionCode;
121     }
122
123     /**
124      * Get monitoring command information. This is used to access an
125      * instance of com.sun.enterprise.admin.monitor.MonitorCommand (or its sub
126      * classes) from the event. This may be null.
127      * @return Monitoring command
128      */

129     public Object JavaDoc getCommand() {
130         return command;
131     }
132
133     /**
134      * Get a string representation.
135      */

136     public String JavaDoc toString() {
137         return "MonitoringEvent -- " + componentName + " -- " + actionCode;
138     }
139 }
140
Popular Tags