KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > ResourceAdapterModuleImpl


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.connector;
18
19 import java.util.Hashtable JavaDoc;
20 import java.util.Map JavaDoc;
21 import javax.management.ObjectName JavaDoc;
22
23 import org.apache.geronimo.gbean.GBeanData;
24 import org.apache.geronimo.j2ee.management.impl.InvalidObjectNameException;
25 import org.apache.geronimo.kernel.ObjectNameUtil;
26 import org.apache.geronimo.management.J2EEApplication;
27 import org.apache.geronimo.management.J2EEServer;
28 import org.apache.geronimo.management.geronimo.ResourceAdapter;
29 import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
30
31 /**
32  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
33  */

34 public class ResourceAdapterModuleImpl implements ResourceAdapterModule {
35     private final J2EEServer server;
36     private final J2EEApplication application;
37     private final String JavaDoc deploymentDescriptor;
38     private final ResourceAdapter resourceAdapter;
39
40     private final GBeanData resourceAdapterGBeanData;
41     private final Map JavaDoc activationSpecInfoMap;
42     private final Map JavaDoc adminObjectInfoMap;
43     private final Map JavaDoc managedConnectionFactoryInfoMap;
44     private final String JavaDoc objectName;
45     private final String JavaDoc displayName;
46     private final String JavaDoc description;
47     private final String JavaDoc vendorName;
48     private final String JavaDoc resourceAdapterVersion;
49     private final String JavaDoc eisType;
50
51     public ResourceAdapterModuleImpl(String JavaDoc objectName,
52                                      ResourceAdapter resourceAdapter,
53                                      J2EEServer server,
54                                      J2EEApplication application,
55                                      String JavaDoc deploymentDescriptor,
56                                      GBeanData resourceAdapterGBeanData,
57                                      Map JavaDoc activationSpecInfoMap,
58                                      Map JavaDoc adminObjectInfoMap,
59                                      Map JavaDoc managedConnectionFactoryInfoMap,
60                                      String JavaDoc displayName,
61                                      String JavaDoc description,
62                                      String JavaDoc vendorName,
63                                      String JavaDoc resourceAdapterVersion,
64                                      String JavaDoc eisType) {
65         this.objectName = objectName;
66         ObjectName JavaDoc myObjectName = ObjectNameUtil.getObjectName(objectName);
67         verifyObjectName(myObjectName);
68
69         this.resourceAdapter = resourceAdapter;
70
71         this.server = server;
72         this.application = application;
73         this.deploymentDescriptor = deploymentDescriptor;
74
75         this.resourceAdapterGBeanData = resourceAdapterGBeanData;
76         this.activationSpecInfoMap = activationSpecInfoMap;
77         this.adminObjectInfoMap = adminObjectInfoMap;
78         this.managedConnectionFactoryInfoMap = managedConnectionFactoryInfoMap;
79         this.description = description;
80         this.displayName = displayName;
81         this.vendorName = vendorName;
82         this.resourceAdapterVersion = resourceAdapterVersion;
83         this.eisType = eisType;
84     }
85
86     public String JavaDoc getObjectName() {
87         return objectName;
88     }
89
90     public boolean isStateManageable() {
91         return true;
92     }
93
94     public boolean isStatisticsProvider() {
95         return false;
96     }
97
98     public boolean isEventProvider() {
99         return true;
100     }
101
102     public String JavaDoc getDeploymentDescriptor() {
103         return deploymentDescriptor;
104     }
105
106     public String JavaDoc getServer() {
107         return server.getObjectName();
108     }
109
110     public String JavaDoc getApplication() {
111         if (application == null) {
112             return null;
113         }
114         return application.getObjectName();
115     }
116
117     public String JavaDoc[] getJavaVMs() {
118         return server.getJavaVMs();
119     }
120
121     public String JavaDoc[] getResourceAdapters() {
122         return new String JavaDoc[]{resourceAdapter.getObjectName()};
123     }
124
125     public GBeanData getResourceAdapterGBeanData() {
126         return resourceAdapterGBeanData;
127     }
128
129     public Map JavaDoc getActivationSpecInfoMap() {
130         return activationSpecInfoMap;
131     }
132
133     public Map JavaDoc getAdminObjectInfoMap() {
134         return adminObjectInfoMap;
135     }
136
137     public Map JavaDoc getManagedConnectionFactoryInfoMap() {
138         return managedConnectionFactoryInfoMap;
139     }
140
141     public String JavaDoc getDisplayName() {
142         return displayName;
143     }
144
145     public String JavaDoc getDescription() {
146         return description;
147     }
148
149     public String JavaDoc getVendorName() {
150         return vendorName;
151     }
152
153     public String JavaDoc getResourceAdapterVersion() {
154         return resourceAdapterVersion;
155     }
156
157     public String JavaDoc getEISType() {
158         return eisType;
159     }
160
161     public ResourceAdapter[] getResourceAdapterInstances() {
162         return new ResourceAdapter[] {resourceAdapter};
163     }
164
165     /**
166      * ObjectName must match this pattern:
167      * <p/>
168      * domain:j2eeType=ResourceAdapterModule,name=MyName,J2EEServer=MyServer,J2EEApplication=MyApplication
169      */

170     private void verifyObjectName(ObjectName JavaDoc objectName) {
171         if (objectName.isPattern()) {
172             throw new InvalidObjectNameException("ObjectName can not be a pattern", objectName);
173         }
174         Hashtable JavaDoc keyPropertyList = objectName.getKeyPropertyList();
175         if (!"ResourceAdapterModule".equals(keyPropertyList.get("j2eeType"))) {
176             throw new InvalidObjectNameException("ResourceAdapterModule object name j2eeType property must be 'ResourceAdapterModule'", objectName);
177         }
178         if (!keyPropertyList.containsKey("name")) {
179             throw new InvalidObjectNameException("ResourceAdapterModule object must contain a name property", objectName);
180         }
181         if (!keyPropertyList.containsKey("J2EEServer")) {
182             throw new InvalidObjectNameException("ResourceAdapterModule object name must contain a J2EEServer property", objectName);
183         }
184         if (!keyPropertyList.containsKey("J2EEApplication")) {
185             throw new InvalidObjectNameException("ResourceAdapterModule object name must contain a J2EEApplication property", objectName);
186         }
187         if (keyPropertyList.size() != 4) {
188             throw new InvalidObjectNameException("ResourceAdapterModule object name can only have j2eeType, name, J2EEApplication, and J2EEServer properties", objectName);
189         }
190     }
191 }
192
Popular Tags