KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > model > J2EEModuleMdl


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.management.model;
25
26 import java.util.*;
27 import javax.management.*;
28 //import com.sun.management.j2se.MOAgents.MOAgentFactory;
29
import com.sun.enterprise.management.util.J2EEModuleCallBack;
30
31
32 public abstract class J2EEModuleMdl extends J2EEDeployedObjectMdl {
33     HashSet externalVMs = new HashSet();
34
35     J2EEModuleMdl(J2EEModuleCallBack module) {
36         super(module);
37     }
38
39     public String JavaDoc [] getjavaVMs() {
40         //get the internal VM name
41
//App Clients never run on the internal VM
42
Set res = new HashSet();
43         if (!(this instanceof AppClientModuleMdl)) {
44             //res.addAll(findNames("j2eeType=JVM,name=" + MOAgentFactory.getAgent().getJVMId()));
45
}
46         //get the external VM names
47
Iterator vmNames = externalVMs.iterator();
48         while(vmNames.hasNext()) {
49               String JavaDoc vmName = (String JavaDoc)vmNames.next();
50               Set x = findNames("j2eeType=JVM,name=" + vmName);
51               if(x.size() > 0) {
52                 res.addAll(x);
53               } else {
54                 //no longer an active VM
55
externalVMs.remove(vmName);
56                 vmNames = externalVMs.iterator();
57               }
58         }
59         Iterator it = res.iterator();
60         String JavaDoc [] vms = new String JavaDoc [res.size()];
61         int i =0;
62         while(it.hasNext()) {
63             vms[i++] = ((ObjectName)it.next()).toString();
64         }
65         return vms;
66     }
67     
68     /**
69      * The name of the J2EEManagedObject. All managed objects must have a unique name within the context of the management
70      * domain. The name must not be null.
71      */

72     public String JavaDoc getobjectName() {
73         Set s = findNames("j2eeType="+getj2eeType()+",name="+this.getModuleName()+",J2EEApplication="+this.getJ2EEApplication()+",J2EEServer="+this.getJ2EEServer());
74         Object JavaDoc [] objs = s.toArray();
75         if (objs.length > 0) {
76             String JavaDoc name = ((ObjectName)objs[0]).toString();
77             return name;
78         } else {
79             return null;
80         }
81     }
82
83     public void addVm(String JavaDoc name) {
84         externalVMs.add(name);
85     }
86     /**
87      * Overriding method of ManagedObject
88      */

89     public boolean isstateManageable() {
90     /*
91         if(this.getJ2EEApplication().equals("null"))
92             return true;
93     */

94         return false;
95     }
96     /**
97      * Overriding method of ManagedObject
98      */

99     public boolean iseventProvider() {
100         if(this.getJ2EEApplication().equals("null"))
101             return true;
102         return false;
103     }
104
105     public abstract String JavaDoc getModuleName();
106     public abstract String JavaDoc getJ2EEApplication();
107
108     public static boolean isStandAloneModule(String JavaDoc applicationName){
109     if ( applicationName == null
110          || applicationName.equals("")
111          || applicationName.equals("null") ) {
112         return true;
113     }
114         return false;
115     }
116 }
117
Popular Tags