KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.sun.enterprise.admin.selfmanagement.event;
25
26 import com.sun.enterprise.admin.monitor.callflow.Agent;
27 import com.sun.enterprise.admin.monitor.callflow.RequestType;
28 import com.sun.enterprise.admin.monitor.callflow.ComponentType;
29 import com.sun.enterprise.Switch;
30 import com.sun.enterprise.admin.monitor.callflow.Listener;
31
32 public class CallflowEventListener implements Listener {
33     
34     private static TraceEventImpl traceImpl = null;
35     private static CallflowEventListener _instance = new CallflowEventListener();
36     static CallflowEventListener getInstance() {
37         return _instance;
38     }
39     
40     // To give the call backs to the listener
41
static synchronized void setTraceImpl(TraceEventImpl impl) {
42         traceImpl = impl;
43         // Switch.getSwitch().getCallFlowAgent().enableForNotifications(true);
44
}
45   
46     static synchronized void register() {
47         Switch.getSwitch().getCallFlowAgent().registerListener(getInstance());
48     }
49
50     static synchronized void unregister() {
51         Switch.getSwitch().getCallFlowAgent().unregisterListener(getInstance());
52     }
53     
54     public void requestStart(String JavaDoc requestId,
55                                     RequestType requestType,
56                                     String JavaDoc callerIPAddress, String JavaDoc remoteUser) {
57         traceImpl.requestStart(requestId, requestType, callerIPAddress,
58                                System.nanoTime(), Thread.currentThread().toString());
59     }
60
61     public void requestEnd(String JavaDoc requestId) {
62         traceImpl.requestEnd(requestId, System.nanoTime(),
63                                         Thread.currentThread().toString());
64     }
65
66     public void ejbMethodStart(String JavaDoc requestId,
67                        String JavaDoc methodName, String JavaDoc applicationName,
68                        String JavaDoc moduleName, String JavaDoc componentName,
69                        ComponentType componentType, String JavaDoc securityId,
70                        String JavaDoc transactionId) {
71         traceImpl.ejbMethodStart(requestId, methodName, componentType.toString(), applicationName,
72                                  moduleName, componentName, transactionId, securityId,
73                                  System.nanoTime(),Thread.currentThread().toString());
74     }
75
76     public void ejbMethodEnd(String JavaDoc requestId, Throwable JavaDoc exception) {
77         traceImpl.ejbMethodEnd(requestId, exception, System.nanoTime(),
78                                  Thread.currentThread().toString());
79     }
80
81
82     public void webMethodStart(String JavaDoc requestId, String JavaDoc methodName,
83                                String JavaDoc applicationName, String JavaDoc moduleName,
84                                String JavaDoc componentName, ComponentType componentType,
85                                String JavaDoc callerPrincipal) {
86         traceImpl.webMethodStart(requestId, methodName, applicationName, componentType.toString(),
87                                  componentName, callerPrincipal, System.nanoTime(),
88                                  Thread.currentThread().toString());
89     }
90
91     public void webMethodEnd(String JavaDoc requestId, Throwable JavaDoc exception) {
92         traceImpl.webMethodEnd(requestId,exception, System.nanoTime(),
93                                  Thread.currentThread().toString());
94     }
95
96 }
97
Popular Tags