KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > deployment > jsr88 > ResourceAdapterInstance


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.deployment.jsr88;
18
19 import org.apache.geronimo.xbeans.geronimo.GerResourceadapterInstanceType;
20 import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
21 import org.apache.geronimo.naming.deployment.jsr88.GBeanLocator;
22 import org.apache.xmlbeans.SchemaTypeLoader;
23 import javax.enterprise.deploy.model.DDBean JavaDoc;
24
25 /**
26  * Represents /connector/resourceadapter/resourceadapter-instance in the
27  * Geronimo Connector deployment plan. The settings here correspond to
28  * /connector/resourceadapter in the J2EE plan, but since there can be
29  * several instances per resource adapter, it's not 1:1 and this is not
30  * a DConfigBean.
31  *
32  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
33  */

34 public class ResourceAdapterInstance extends ConfigHolder {
35     private DDBean JavaDoc resourceAdapter;
36     private GBeanLocator workManager;
37
38     /**
39      * Present so a tool can create a new one
40      */

41     public ResourceAdapterInstance() {
42     }
43
44     public ResourceAdapterInstance(DDBean JavaDoc resourceAdapter, GerResourceadapterInstanceType instance) {
45         configure(resourceAdapter, instance);
46     }
47
48     protected GerResourceadapterInstanceType getResourceAdapterInstance() {
49         return (GerResourceadapterInstanceType) getXmlObject();
50     }
51
52     public void reconfigure() {
53         configure(resourceAdapter, getResourceAdapterInstance());
54     }
55
56     void configure(DDBean JavaDoc resourceAdapter, GerResourceadapterInstanceType xml) {
57         this.resourceAdapter = resourceAdapter;
58         super.configure(resourceAdapter, xml);
59     }
60
61     protected GerConfigPropertySettingType createConfigProperty() {
62         return getResourceAdapterInstance().addNewConfigPropertySetting();
63     }
64
65     protected GerConfigPropertySettingType[] getConfigProperties() {
66         return getResourceAdapterInstance().getConfigPropertySettingArray();
67     }
68
69     protected void removeConfigProperty(int index) {
70         getResourceAdapterInstance().removeConfigPropertySetting(index);
71     }
72
73     // ----------------------- JavaBean Properties for /resourceadapter-instance ----------------------
74

75     public String JavaDoc getResourceAdapterName() {
76         return getResourceAdapterInstance().getResourceadapterName();
77     }
78
79     public void setResourceAdapterName(String JavaDoc name) {
80         String JavaDoc old = getResourceAdapterName();
81         getResourceAdapterInstance().setResourceadapterName(name);
82         pcs.firePropertyChange("resourceAdapterName", old, name);
83     }
84
85     public GBeanLocator getWorkManager() {
86         return workManager;
87     }
88
89     public void setWorkManager(GBeanLocator locator) {
90         GBeanLocator old = getWorkManager();
91         if(locator != null && !locator.configured()) {
92             if(getResourceAdapterInstance().getWorkmanager() != null) {
93                 locator.configure(getResourceAdapterInstance().getWorkmanager());
94             } else {
95                 locator.configure(getResourceAdapterInstance().addNewWorkmanager());
96             }
97         }
98         workManager = locator;
99         pcs.firePropertyChange("workManager", old, workManager);
100     }
101
102     // ----------------------- End of JavaBean Properties ----------------------
103

104     protected SchemaTypeLoader getSchemaTypeLoader() {
105         return Connector15DCBRoot.SCHEMA_TYPE_LOADER;
106     }
107 }
108
Popular Tags