KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > support > AMXDebugSupport


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  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28 package com.sun.enterprise.management.support;
29
30 import javax.management.MBeanServer JavaDoc;
31 import javax.management.ObjectName JavaDoc;
32
33 import java.io.File JavaDoc;
34
35 import com.sun.appserv.management.base.AMXDebug;
36 import com.sun.appserv.management.base.Util;
37 import com.sun.appserv.management.util.misc.FileUtils;
38
39 import com.sun.enterprise.management.support.BootUtil;
40
41
42 /**
43  */

44 public final class AMXDebugSupport
45     implements AMXDebugSupportMBean
46 {
47     private final MBeanServer JavaDoc mServer;
48     
49     public static final String JavaDoc NAME = "amx-debug";
50     
51         public
52     AMXDebugSupport( final MBeanServer JavaDoc server )
53     {
54         mServer = server;
55         
56         final String JavaDoc domain =
57             BootUtil.getInstance().getAMXSupportJMXDomain();
58         
59         final String JavaDoc props = Util.makeNameProp( NAME);
60         
61         final ObjectName JavaDoc objectName = Util.newObjectName( domain, props );
62         try
63         {
64             mServer.registerMBean( this, objectName );
65         }
66         catch( Exception JavaDoc e )
67         {
68             throw new RuntimeException JavaDoc( e );
69         }
70     }
71     
72         private AMXDebug
73     getAMXDebug()
74     {
75         return AMXDebug.getInstance();
76     }
77     
78         public String JavaDoc[]
79     getOutputIDs()
80     {
81         return AMXDebug.getInstance().getOutputIDs();
82     }
83     
84         public boolean
85     getDefaultDebug()
86     {
87         return getAMXDebug().getDefaultDebug();
88     }
89      
90         public void
91     setDefaultDebug( boolean debug )
92     {
93         getAMXDebug().setDefaultDebug( debug );
94     }
95     
96         public boolean
97     getDebug( final String JavaDoc id )
98     {
99         return getAMXDebug().getDebug( id );
100     }
101     
102         public void
103     setDebug( final String JavaDoc id, final boolean debug )
104     {
105         getAMXDebug().setDebug( id, debug );
106     }
107     
108         public void
109     setAll( final boolean debug )
110     {
111         getAMXDebug().setAll( debug );
112     }
113     
114         public void
115     cleanup()
116     {
117         getAMXDebug().cleanup();
118     }
119     
120         public String JavaDoc
121     getOutputFrom( final String JavaDoc id )
122     {
123         String JavaDoc output = "";
124         
125         final File JavaDoc f = getAMXDebug().getOutputFile( id );
126         if ( f != null && f.exists() )
127         {
128             try
129             {
130                 output = FileUtils.fileToString( f );
131             }
132             catch( Exception JavaDoc e )
133             {
134                 output = "";
135             }
136         }
137         
138         return output;
139     }
140 }
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Popular Tags