KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > RunMeFirstTest


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 package com.sun.enterprise.management;
24
25 import javax.management.MBeanServerInvocationHandler JavaDoc;
26 import javax.management.ObjectName JavaDoc;
27
28 import java.util.Set JavaDoc;
29 import java.util.Map JavaDoc;
30
31 import com.sun.appserv.management.base.AMX;
32 import com.sun.appserv.management.base.Util;
33 import com.sun.appserv.management.util.misc.ExceptionUtil;
34
35 import com.sun.appserv.management.config.DomainConfig;
36 import com.sun.appserv.management.config.ConfigConfig;
37 import com.sun.appserv.management.config.JavaConfig;
38 import com.sun.appserv.management.config.SecurityServiceConfig;
39 import com.sun.appserv.management.config.AdminServiceConfig;
40
41 import com.sun.appserv.management.util.misc.GSetUtil;
42 import com.sun.appserv.management.util.misc.ExceptionUtil;
43
44 import com.sun.enterprise.management.config.*;
45 import com.sun.enterprise.management.support.AMXDebugStuff;
46 import com.sun.enterprise.management.support.AMXDebugSupportMBean;
47
48
49 /**
50     This test run prior to testing any AMX MBeans.
51  */

52 public final class RunMeFirstTest extends AMXTestBase
53 {
54         public
55     RunMeFirstTest( )
56     {
57         initCoverageInfos();
58     }
59     
60         private void
61     initCoverageInfos()
62     {
63         final Set JavaDoc<AMX> all = getAllAMX();
64         
65         // set the AMX-DEBUG flags on
66
final String JavaDoc AMX_DEBUG = "-DAMX-DEBUG.enabled=true";
67         final String JavaDoc AMX_DEBUG2 = "-DAMX-DEBUG=true";
68         
69         // set AMX-DEBUG.enabled=true in all ConfigConfig JVM options
70
final Map JavaDoc<String JavaDoc,ConfigConfig> configs = getDomainConfig().getConfigConfigMap();
71         for( final ConfigConfig config : configs.values() )
72         {
73             final JavaConfig jc = config.getJavaConfig();
74             final Set JavaDoc<String JavaDoc> jvmOptions = GSetUtil.newStringSet( jc.getJVMOptions() );
75             
76             if ( ! ( jvmOptions.contains( AMX_DEBUG ) || jvmOptions.contains( AMX_DEBUG2 ) ))
77             {
78                 jvmOptions.add( AMX_DEBUG );
79                 jc.setJVMOptions( GSetUtil.toStringArray( jvmOptions ) );
80                 
81                 // don't warn for default-config; it's not used by a running server
82
if ( ! config.getName().equals( "default-config" ) )
83                 {
84                     warning( "Enabled AMX-DEBUG for config " + config.getName()+
85                         " (restart required)" );
86                 }
87             }
88         }
89         
90         // setup default stuff
91
final AMXDebugSupportMBean debug = getAMXDebugSupportMBean();
92         debug.setAll( true );
93         debug.setDefaultDebug( true );
94         debug.getOutputIDs();
95         
96         for( final AMX amx : all )
97         {
98             final AMXDebugStuff debugStuff = getTestUtil().asAMXDebugStuff( amx );
99             
100             if ( debugStuff == null )
101             {
102                 continue;
103             }
104             
105             try
106             {
107                 debugStuff.enableAMXDebug( true );
108             }
109             catch( Throwable JavaDoc t )
110             {
111                 warning( "Couldn't enableAMXDebug() for " + amx.getJ2EEType() );
112             }
113             
114             try
115             {
116                 debugStuff.enableCoverageInfo( true );
117                 debugStuff.clearCoverageInfo();
118             }
119             catch( Throwable JavaDoc t )
120             {
121                 warning( "Couldn't enableCoverageInfo for " + amx.getJ2EEType() );
122             }
123         }
124     }
125 }
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
Popular Tags