KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.enterprise.deploy.model.DDBean JavaDoc;
20 import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType;
21 import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
22 import org.apache.geronimo.naming.deployment.jsr88.GBeanLocator;
23 import org.apache.xmlbeans.SchemaTypeLoader;
24
25 /**
26  * Represents connection-definition/connectiondefinition-instance in the
27  * Geronimo Connector deployment plan.
28  *
29  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
30  */

31 public class ConnectionDefinitionInstance extends ConfigHolder {
32     private DDBean JavaDoc connectionDefinition;
33     private ConnectionManager manager;
34
35     public ConnectionDefinitionInstance() {
36     }
37
38     public ConnectionDefinitionInstance(DDBean JavaDoc connectionDefinition, GerConnectiondefinitionInstanceType instance) {
39         configure(connectionDefinition, instance);
40     }
41
42     protected GerConnectiondefinitionInstanceType getConnectionInstance() {
43         return (GerConnectiondefinitionInstanceType) getXmlObject();
44     }
45
46     public void reconfigure() {
47         configure(connectionDefinition, getConnectionInstance());
48     }
49
50     void configure(DDBean JavaDoc connectionDefinition, GerConnectiondefinitionInstanceType definition) {
51         this.connectionDefinition = connectionDefinition;
52         super.configure(connectionDefinition, definition);
53         if(connectionDefinition != null) {
54             DDBean JavaDoc parent = connectionDefinition.getChildBean("..")[0];
55             ConnectionManager oldMgr = manager;
56             if(oldMgr == null) {
57                 if(definition.getConnectionmanager() != null) {
58                     manager = new ConnectionManager(parent, definition.getConnectionmanager());
59                 } else {
60                     manager = new ConnectionManager(parent, definition.addNewConnectionmanager());
61                 }
62             } else {
63                 if(definition.getConnectionmanager() != null) {
64                     manager.configure(parent, definition.getConnectionmanager());
65                 } else {
66                     manager.configure(parent, definition.addNewConnectionmanager());
67                 }
68             }
69             pcs.firePropertyChange("connectionManager", oldMgr, manager);
70         }
71     }
72
73     DDBean JavaDoc getDDBean() {
74         return connectionDefinition;
75     }
76
77     protected GerConfigPropertySettingType createConfigProperty() {
78         return getConnectionInstance().addNewConfigPropertySetting();
79     }
80
81     protected GerConfigPropertySettingType[] getConfigProperties() {
82         return getConnectionInstance().getConfigPropertySettingArray();
83     }
84
85     protected void removeConfigProperty(int index) {
86         getConnectionInstance().removeConfigPropertySetting(index);
87     }
88
89     // ----------------------- JavaBean Properties for /connectiondefinition-instance ----------------------
90

91     public String JavaDoc getName() {
92         return getConnectionInstance().getName();
93     }
94
95     public void setName(String JavaDoc name) {
96         String JavaDoc old = getName();
97         getConnectionInstance().setName(name);
98         pcs.firePropertyChange("name", old, name);
99     }
100
101     public String JavaDoc[] getImplementedInterface() {
102         return getConnectionInstance().getImplementedInterfaceArray();
103     }
104
105     public String JavaDoc getImplementedInterface(int index) {
106         return getConnectionInstance().getImplementedInterfaceArray(index);
107     }
108
109     public void setImplementedInterface(String JavaDoc[] list) {
110         String JavaDoc[] old = getImplementedInterface();
111         getConnectionInstance().setImplementedInterfaceArray(list);
112         pcs.firePropertyChange("implementedInterface", old, list);
113     }
114
115     public void setImplementedInterface(int index, String JavaDoc iface) {
116         String JavaDoc[] old = getImplementedInterface();
117         getConnectionInstance().setImplementedInterfaceArray(index, iface);
118         pcs.firePropertyChange("implementedInterface", old, getImplementedInterface());
119     }
120
121     public ConnectionManager getConnectionManager() {
122         return manager;
123     }
124
125     // ----------------------- End of JavaBean Properties ----------------------
126

127     protected SchemaTypeLoader getSchemaTypeLoader() {
128         return Connector15DCBRoot.SCHEMA_TYPE_LOADER;
129     }
130 }
131
Popular Tags