KickJava   Java API By Example, From Geeks To Geeks.

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


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.enterprise.deployment.Application;
29 import com.sun.enterprise.deployment.WebService;
30 import com.sun.enterprise.deployment.WebServiceEndpoint;
31 import com.sun.enterprise.management.util.J2EEModuleCallBack;
32
33 public class J2EEApplicationMdl extends J2EEDeployedObjectMdl {
34     
35     private static String JavaDoc MANAGED_OBJECT_TYPE = "J2EEApplication";
36     private String JavaDoc appName = null;
37     private boolean hasWebServices=false;
38     private String JavaDoc[] endpointAddresses = null;
39     
40     public J2EEApplicationMdl(J2EEModuleCallBack module, Application app) {
41     super(module);
42         
43         appName = module.getParentName();
44     if (app==null) {
45         return;
46     }
47     Set webServices = app.getWebServiceDescriptors();
48     if (webServices.size()>0) {
49         hasWebServices = true;
50         Vector endpointList = new Vector();
51         for (Iterator itr = webServices.iterator();itr.hasNext();) {
52         WebService webService = (WebService) itr.next();
53         for (Iterator endpoints = webService.getWebServicesDescriptor().getEndpoints().iterator();
54             endpoints.hasNext();) {
55             WebServiceEndpoint wse = (WebServiceEndpoint) endpoints.next();
56             endpointList.add(wse.getEndpointAddressUri());
57         }
58         }
59         endpointAddresses = new String JavaDoc[endpointList.size()];
60         endpointList.copyInto(endpointAddresses);
61     }
62     }
63     
64     public String JavaDoc [] getmodules() {
65
66         Set appMods = findNames("j2eeType=EJBModule,J2EEServer=" + getJ2EEServer()+",J2EEApplication="+this.appName);
67         appMods.addAll(findNames("j2eeType=WebModule,J2EEServer=" + getJ2EEServer()+",J2EEApplication="+this.appName));
68         appMods.addAll(findNames("j2eeType=ResourceAdapterModule,J2EEServer=" + getJ2EEServer()+",J2EEApplication="+this.appName));
69         appMods.addAll(findNames("j2eeType=AppClientModule,J2EEServer=" + getJ2EEServer()+",J2EEApplication="+this.appName));
70
71         Iterator it = appMods.iterator();
72         String JavaDoc [] mods = new String JavaDoc[appMods.size()];
73         int i =0;
74         while(it.hasNext()) {
75             mods[i++] = ((ObjectName)it.next()).toString();
76         }
77         return mods;
78     }
79     
80     /**
81      * The type of the J2EEManagedObject as specified by JSR77. The class that implements a specific type must override this method and return the appropriate type string.
82      */

83     public String JavaDoc getj2eeType() {
84         return MANAGED_OBJECT_TYPE;
85     }
86     
87     /**
88      * The name of the J2EEManagedObject. All managed objects must have a unique name within the context of the management
89      * domain. The name must not be null.
90      */

91     public String JavaDoc getobjectName() {
92         Set s = findNames("j2eeType="+getj2eeType()+",name="+this.appName+",J2EEServer="+getJ2EEServer());
93         Object JavaDoc [] objs = s.toArray();
94         if (objs.length > 0) {
95             String JavaDoc name = ((ObjectName)objs[0]).toString();
96             return name;
97         } else {
98             return null;
99         }
100     }
101     
102     /**
103      * @return true if this application implements any webservice endpoint
104      */

105     public boolean gethasWebServices() {
106     return hasWebServices;
107     }
108  
109     /**
110      * @return array of endpoint addresses defined for this application
111      */

112     public String JavaDoc[] getendpointAddresses() {
113     return endpointAddresses;
114     }
115 }
116
Popular Tags