KickJava   Java API By Example, From Geeks To Geeks.

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


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/J2EEServerImpl.java,v 1.7 2006/03/17 03:34:18 llc Exp $
26  * $Revision: 1.7 $
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.HashSet JavaDoc;
35 import java.util.Collections JavaDoc;
36 import java.util.Iterator JavaDoc;
37
38 import javax.management.ObjectName JavaDoc;
39
40 import com.sun.appserv.server.util.Version;
41
42 import com.sun.appserv.management.j2ee.J2EEServer;
43 import com.sun.appserv.management.j2ee.JVM;
44 import com.sun.appserv.management.j2ee.J2EETypes;
45
46 import com.sun.appserv.management.util.misc.GSetUtil;
47
48 import com.sun.appserv.management.base.Util;
49 import com.sun.appserv.management.base.AMX;
50
51 import com.sun.enterprise.management.support.ObjectNames;
52 import com.sun.enterprise.management.support.TypeInfos;
53 import com.sun.enterprise.management.support.TypeInfo;
54
55 import com.sun.enterprise.management.support.Delegate;
56
57 import com.sun.enterprise.management.support.AMXAttributeNameMapper;
58
59 /**
60     JSR 77 extension representing an Appserver standalone server (non-clustered)
61  */

62 public class J2EEServerImpl
63     extends J2EELogicalServerImplBase
64 {
65
66     /* The vendor information for this server. */
67     private static final String JavaDoc serverVendor = "Sun Microsystems, Inc.";
68
69         public
70     J2EEServerImpl( final Delegate delegate )
71     {
72         super( delegate );
73     }
74
75         protected
76     J2EEServerImpl( String JavaDoc j2eeType, Delegate delegate )
77     {
78         super( j2eeType, delegate );
79     }
80
81
82         private J2EEServer
83     getSelfProxy()
84     {
85         return (J2EEServer)getSelf();
86     }
87     
88         public String JavaDoc[]
89     getjavaVMs()
90     {
91         final JVM jvm = getSelfProxy().getJVM();
92         
93         String JavaDoc[] result = null;
94         if ( jvm == null )
95         {
96             result = new String JavaDoc[ 0 ];
97         }
98         else
99         {
100             result = new String JavaDoc[] { "" + Util.getObjectName( jvm ) };
101         }
102         
103         return result;
104     }
105     
106     private static final Set JavaDoc<String JavaDoc> RESOURCE_TYPES =
107     GSetUtil.newUnmodifiableStringSet(
108         J2EETypes.JDBC_RESOURCE,
109         J2EETypes.JAVA_MAIL_RESOURCE,
110         J2EETypes.JCA_RESOURCE,
111         J2EETypes.JMS_RESOURCE,
112         J2EETypes.JNDI_RESOURCE,
113         J2EETypes.JTA_RESOURCE,
114         J2EETypes.RMI_IIOP_RESOURCE,
115         J2EETypes.URL_RESOURCE );
116         
117     
118         public String JavaDoc[]
119     getresources()
120     {
121         return GSetUtil.toStringArray( getResourcesObjectNameSet() );
122     }
123     
124         public Set JavaDoc<ObjectName JavaDoc>
125     getResourcesObjectNameSet()
126     {
127         return getContaineeObjectNameSet( RESOURCE_TYPES );
128     }
129
130         public String JavaDoc
131     getserverVersion()
132     {
133         return ( Version.getVersion() );
134     }
135     
136         public boolean
137     isstatisticProvider()
138     {
139         return( false );
140     }
141     
142         public boolean
143     isstatisticsProvider()
144     {
145         return isstatisticProvider();
146     }
147     
148         public String JavaDoc
149     getserverVendor()
150     {
151         return serverVendor;
152     }
153         
154     private final static Set JavaDoc<String JavaDoc> DONT_MAP_SET =
155         GSetUtil.newUnmodifiableStringSet( "serverVendor" );
156     
157         protected Set JavaDoc<String JavaDoc>
158     getDontMapAttributeNames()
159     {
160         return( GSetUtil.newSet( DONT_MAP_SET, super.getDontMapAttributeNames() ) );
161     }
162     
163         protected final Set JavaDoc<String JavaDoc>
164     getFauxChildTypes()
165     {
166         final TypeInfo j2eeApplicationInfo =
167             TypeInfos.getInstance().getInfo( J2EETypes.J2EE_APPLICATION );
168     
169         final Set JavaDoc<String JavaDoc> childJ2EETypes = j2eeApplicationInfo.getChildJ2EETypes();
170         return( childJ2EETypes );
171     }
172     
173     /*
174         Override default behavior to find modules that belong to J2EEServer directly
175         because J2EEApplication=null.
176      */

177         public final Set JavaDoc<ObjectName JavaDoc>
178     getContaineeObjectNameSet( final String JavaDoc childJ2EEType )
179     {
180         final Set JavaDoc<ObjectName JavaDoc> result = super.getContaineeObjectNameSet( childJ2EEType );
181         
182         if ( getFauxChildTypes().contains( childJ2EEType ) )
183         {
184             final String JavaDoc nullAppProp = Util.makeProp( J2EETypes.J2EE_APPLICATION, AMX.NULL_NAME );
185
186             final Set JavaDoc<ObjectName JavaDoc> fauxContainees =
187                 getFauxContaineeObjectNameSet( childJ2EEType, nullAppProp);
188             result.addAll( fauxContainees );
189         }
190         
191         return( result );
192     }
193     
194         public boolean
195     getRestartRequired()
196     {
197         return (Boolean JavaDoc)delegateGetAttributeNoThrow( "restartRequired" );
198     }
199 }
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
Popular Tags