KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > server > core > mbean > config > ManagedJ2EEEjbJarModule


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.admin.server.core.mbean.config;
25
26 //Config imports
27
import com.sun.enterprise.config.ConfigException;
28 import com.sun.enterprise.config.serverbeans.ServerXPathHelper;
29 import com.sun.enterprise.config.serverbeans.J2eeApplication;
30
31
32 //Admin Imports
33
import com.sun.enterprise.admin.AdminContext;
34 import com.sun.enterprise.admin.common.ObjectNames;
35 import com.sun.enterprise.admin.common.exception.J2EEEjbJarModuleException;
36 import com.sun.enterprise.admin.common.constant.AdminConstants;
37 import com.sun.enterprise.admin.common.exception.MBeanConfigException;
38 import com.sun.enterprise.admin.server.core.mbean.config.naming.ConfigMBeanNamingInfo;
39
40 /**
41     Represents a Ejb Jar Module within an app. This is a part of a deployed
42     application. When a J2EE application is deployed, instances of this MBean
43     are registered in the MBeanServer.
44     <p>
45     There will be as many instances of this MBean as there are Ejb Modules (per
46     application).
47     <p>
48     ObjectName of this MBean is:
49         ias:type=J2EEEjbJarModule, AppName= <appName>, ModuleName=<moduleName>
50
51 */

52
53 public class ManagedJ2EEEjbJarModule extends ConfigMBeanBase
54 {
55     private static final String JavaDoc[][] MAPLIST = null;
56     private static final String JavaDoc[] ATTRIBUTES = null;
57     private static final String JavaDoc[] OPERATIONS =
58     {
59         "getEnterpriseBeans(), INFO",
60         "getSessionEJBs(), INFO",
61         "getEntityEJBs(), INFO",
62     };
63
64     /**
65         Default constructor sets MBean description tables
66     */

67     public ManagedJ2EEEjbJarModule() throws MBeanConfigException
68     {
69         this.setDescriptions(MAPLIST, ATTRIBUTES, OPERATIONS);
70     }
71
72     public ManagedJ2EEEjbJarModule(String JavaDoc instanceName, String JavaDoc applicationName, String JavaDoc moduleName)
73         throws MBeanConfigException
74     {
75         this(instanceName, applicationName, moduleName, null);
76     }
77
78     public ManagedJ2EEEjbJarModule(String JavaDoc instanceName, String JavaDoc applicationName, String JavaDoc moduleName, AdminContext adminContext)
79         throws MBeanConfigException
80     {
81         this(); //set description tables
82
setAdminContext(adminContext);
83         initialize(ObjectNames.kEjbModule, new String JavaDoc[]{instanceName, applicationName, moduleName});
84     }
85
86     public String JavaDoc[] getEnterpriseBeans() throws J2EEEjbJarModuleException
87     {
88         return getBeansByType(ModulesXMLHelper.EJB_TYPE_ALL);
89     }
90
91     public String JavaDoc[] getSessionEJBs() throws J2EEEjbJarModuleException
92     {
93         return getBeansByType(ModulesXMLHelper.EJB_TYPE_SESSION);
94     }
95
96     public String JavaDoc[] getEntityEJBs() throws J2EEEjbJarModuleException
97     {
98         return getBeansByType(ModulesXMLHelper.EJB_TYPE_ENTITY);
99     }
100
101     private String JavaDoc[] getBeansByType(int ejbType) throws J2EEEjbJarModuleException
102     {
103         ConfigMBeanNamingInfo namingInfo = this.getConfigMBeanNamingInfo();
104         String JavaDoc [] locParams = namingInfo.getLocationParams();
105         String JavaDoc applicationName = locParams[1];
106         String JavaDoc moduleName = locParams[2];
107         
108         
109         try
110         {
111             J2eeApplication app = (J2eeApplication) this.getConfigBeanByXPath(ServerXPathHelper.getAppIdXpathExpression(applicationName));
112             String JavaDoc location = app.getLocation();
113             return ModulesXMLHelper.getEnterpriseBeansForEjbModule(location, moduleName, ejbType);
114         }
115         catch (Exception JavaDoc e)
116         {
117             sLogger.throwing(getClass().getName(), "getBeansByType", e);
118             throw new J2EEEjbJarModuleException(e.getMessage());
119         }
120     }
121
122     public int getModuleType()
123     {
124             return ( AdminConstants.kTypeEjbModule );
125     }
126
127     //all the other ias-ejb-jar.xml parameters that are exposed.
128
}
129
Popular Tags