KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > selfmanagement > event > TraceEvent


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  * TraceEvent.java
26  *
27  */

28
29 package com.sun.enterprise.admin.selfmanagement.event;
30
31 import javax.management.NotificationBroadcasterSupport JavaDoc;
32 import javax.management.NotificationListener JavaDoc;
33 import javax.management.NotificationFilter JavaDoc;
34 import javax.management.Notification JavaDoc;
35 import javax.management.ObjectName JavaDoc;
36 import javax.management.MalformedObjectNameException JavaDoc;
37 import com.sun.enterprise.util.i18n.StringManager;
38 import java.util.logging.Logger JavaDoc;
39 import java.util.logging.Level JavaDoc;
40 import com.sun.logging.LogDomains;
41
42 import static com.sun.appserv.management.event.TraceEventHelper.*;
43
44
45
46 /**
47  *
48  * @author Sun Micro Systems, Inc
49  */

50 public class TraceEvent implements Event {
51     
52     private static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.SELF_MANAGEMENT_LOGGER);
53     private static StringManager sm = StringManager.getManager(TraceEvent.class);
54     
55     public TraceEvent(String JavaDoc type, TraceEventNotificationFilter lfilter, String JavaDoc description) {
56         this.type = type;
57         this.lfilter = lfilter;
58         if (description != null)
59             this.description = description;
60         else
61             this.description = defaultDescription;
62     }
63     
64     public ObjectName JavaDoc getObjectName() {
65         return objName;
66     }
67     
68     
69     public String JavaDoc getType() {
70         return type;
71     }
72     
73     public NotificationFilter JavaDoc getNotificationFilter( ){
74         return lfilter;
75     }
76     
77     public String JavaDoc getDescription() {
78         return description;
79     }
80     
81     public void destroy() {
82         // do nothing
83
}
84     
85     static ObjectName JavaDoc getTraceImplObjectName() {
86         if (objName != null)
87             return objName;
88         try {
89             objName = new ObjectName JavaDoc( DOMAIN_NAME,DEFAULT_KEY, "trace");
90         }catch (MalformedObjectNameException JavaDoc mex) {
91             _logger.log(Level.WARNING,"smgt.internal_error", mex);
92         }
93         return objName;
94     }
95
96     public static boolean isValidType(String JavaDoc type) {
97         if ("*".equals(type) || REQUEST_START.equals(type) ||
98            REQUEST_END.equals(type) || WEB_COMPONENT_METHOD_ENTRY.equals(type) ||
99            WEB_COMPONENT_METHOD_EXIT.equals(type) || EJB_COMPONENT_METHOD_ENTRY.equals(type) ||
100            EJB_COMPONENT_METHOD_EXIT.equals(type) ) {
101             return true;
102         }
103         return false;
104     }
105     
106     private static ObjectName JavaDoc objName = null;
107     private static String JavaDoc defaultDescription =
108             sm.getString("selfmgmt_event.trace_event_description");
109     private TraceEventNotificationFilter lfilter = null;
110     private String JavaDoc description = null;
111     private String JavaDoc type = null;
112
113     /**
114      * event types
115     public static final String REQUEST_START = "trace.request_start";
116     public static final String REQUEST_END = "trace.request_end";
117     public static final String WEB_COMPONENT_METHOD_ENTRY = "trace.web_component_method_entry";
118     public static final String WEB_COMPONENT_METHOD_EXIT = "trace.web_component_method_exit";
119     public static final String EJB_COMPONENT_METHOD_ENTRY = "trace.ejb_component_method_entry";
120     public static final String EJB_COMPONENT_METHOD_EXIT = "trace.ejb_component_method_exit";
121      */

122                                                                                                                                                
123
124 }
125
Popular Tags