KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > j2ee > JVMImpl


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  * $Header: /cvs/glassfish/admin/mbeanapi-impl/src/java/com/sun/enterprise/management/j2ee/JVMImpl.java,v 1.6 2006/03/17 03:34:18 llc Exp $
26  * $Revision: 1.6 $
27  * $Date: 2006/03/17 03:34:18 $
28  */

29  
30 package com.sun.enterprise.management.j2ee;
31
32 import java.util.Set JavaDoc;
33 import java.util.Map JavaDoc;
34 import java.util.HashMap JavaDoc;
35 import java.util.Collections JavaDoc;
36
37 import javax.management.ObjectName JavaDoc;
38 import javax.management.InstanceNotFoundException JavaDoc;
39
40 import com.sun.appserv.management.base.Util;
41 import com.sun.appserv.management.base.AMX;
42 import com.sun.appserv.management.base.XTypes;
43 import com.sun.appserv.management.j2ee.JVM;
44 import com.sun.appserv.management.j2ee.J2EEServer;
45
46 import com.sun.appserv.management.j2ee.J2EETypes;
47
48 import com.sun.appserv.management.config.ServerConfig;
49
50 import com.sun.appserv.management.util.misc.GSetUtil;
51
52 import com.sun.enterprise.management.support.Delegate;
53
54 /**
55     Identifies a Java VM being utilized by a server.
56  */

57 public final class JVMImpl
58     extends J2EEManagedObjectImplBase
59 {
60         public
61     JVMImpl( final Delegate delegate )
62     {
63         super( delegate );
64     }
65     
66         public String JavaDoc
67     getjavaVendor()
68     {
69         return( (String JavaDoc)delegateGetAttributeNoThrow( "javaVendor" ) );
70     }
71     
72         protected String JavaDoc
73     getConfigPeerName()
74     {
75         return( AMX.NO_NAME );
76     }
77     
78         protected String JavaDoc
79     getConfigPeerJ2EEType()
80     {
81         return( XTypes.JAVA_CONFIG );
82     }
83     
84         protected Map JavaDoc<String JavaDoc,String JavaDoc>
85     getConfigPeerProps()
86     {
87         final J2EEServer server = (J2EEServer)getContainer();
88         final ServerConfig serverConfig = (ServerConfig)server.getConfigPeer();
89         final String JavaDoc configName = serverConfig.getReferencedConfigName();
90         
91         final Map JavaDoc<String JavaDoc,String JavaDoc> props = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
92         
93         props.put( XTypes.CONFIG_CONFIG, configName );
94         props.put( AMX.J2EE_TYPE_KEY, XTypes.JAVA_CONFIG );
95         
96         return props;
97     }
98     
99         public String JavaDoc
100     getjavaVersion()
101     {
102         return( (String JavaDoc)delegateGetAttributeNoThrow( "javaVersion" ) );
103     }
104     
105         public String JavaDoc
106     getnode()
107     {
108         String JavaDoc fullyQualifiedHostName = (String JavaDoc)delegateGetAttributeNoThrow( "node" );
109         
110         /*
111             Underlying MBean does not comply with JSR77.3.4.1.3, which states:
112             "Identifies the node (machine) this JVM is running on. The value of the node
113             attribute must be the fully quailified hostname of the node the JVM is running on."
114             
115             value seems to be of the form: BLACK/129.150.29.138
116             
117             Roll our own instead.
118          */

119          try
120          {
121             fullyQualifiedHostName = java.net.InetAddress.getLocalHost().getCanonicalHostName();
122          }
123          catch( java.net.UnknownHostException JavaDoc e)
124          {
125          }
126         
127         return( fullyQualifiedHostName );
128     }
129     
130     
131     private final static Set JavaDoc<String JavaDoc> DONT_MAP_SET = Collections.unmodifiableSet(
132         GSetUtil.newSet( new String JavaDoc[] { "node", "javaVersion", "javaVendor" }) );
133     
134         protected Set JavaDoc<String JavaDoc>
135     getDontMapAttributeNames()
136     {
137         final Set JavaDoc<String JavaDoc> all = GSetUtil.newSet( DONT_MAP_SET );
138         all.addAll( super.getDontMapAttributeNames() );
139         return( all );
140     }
141     
142
143 }
144
Popular Tags