001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.connector.deployment.jsr88;
017:
018: import javax.enterprise.deploy.model.DDBean;
019: import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType;
020: import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
021: import org.apache.geronimo.naming.deployment.jsr88.GBeanLocator;
022: import org.apache.xmlbeans.SchemaTypeLoader;
023:
024: /**
025: * Represents connection-definition/connectiondefinition-instance in the
026: * Geronimo Connector deployment plan.
027: *
028: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
029: */
030: public class ConnectionDefinitionInstance extends ConfigHolder {
031: private DDBean connectionDefinition;
032: private ConnectionManager manager;
033:
034: public ConnectionDefinitionInstance() {
035: }
036:
037: public ConnectionDefinitionInstance(DDBean connectionDefinition,
038: GerConnectiondefinitionInstanceType instance) {
039: configure(connectionDefinition, instance);
040: }
041:
042: protected GerConnectiondefinitionInstanceType getConnectionInstance() {
043: return (GerConnectiondefinitionInstanceType) getXmlObject();
044: }
045:
046: public void reconfigure() {
047: configure(connectionDefinition, getConnectionInstance());
048: }
049:
050: void configure(DDBean connectionDefinition,
051: GerConnectiondefinitionInstanceType definition) {
052: this .connectionDefinition = connectionDefinition;
053: super .configure(connectionDefinition, definition);
054: if (connectionDefinition != null) {
055: DDBean parent = connectionDefinition.getChildBean("..")[0];
056: ConnectionManager oldMgr = manager;
057: if (oldMgr == null) {
058: if (definition.getConnectionmanager() != null) {
059: manager = new ConnectionManager(parent, definition
060: .getConnectionmanager());
061: } else {
062: manager = new ConnectionManager(parent, definition
063: .addNewConnectionmanager());
064: }
065: } else {
066: if (definition.getConnectionmanager() != null) {
067: manager.configure(parent, definition
068: .getConnectionmanager());
069: } else {
070: manager.configure(parent, definition
071: .addNewConnectionmanager());
072: }
073: }
074: pcs
075: .firePropertyChange("connectionManager", oldMgr,
076: manager);
077: }
078: }
079:
080: DDBean getDDBean() {
081: return connectionDefinition;
082: }
083:
084: protected GerConfigPropertySettingType createConfigProperty() {
085: return getConnectionInstance().addNewConfigPropertySetting();
086: }
087:
088: protected GerConfigPropertySettingType[] getConfigProperties() {
089: return getConnectionInstance().getConfigPropertySettingArray();
090: }
091:
092: protected void removeConfigProperty(int index) {
093: getConnectionInstance().removeConfigPropertySetting(index);
094: }
095:
096: // ----------------------- JavaBean Properties for /connectiondefinition-instance ----------------------
097:
098: public String getName() {
099: return getConnectionInstance().getName();
100: }
101:
102: public void setName(String name) {
103: String old = getName();
104: getConnectionInstance().setName(name);
105: pcs.firePropertyChange("name", old, name);
106: }
107:
108: public String[] getImplementedInterface() {
109: return getConnectionInstance().getImplementedInterfaceArray();
110: }
111:
112: public String getImplementedInterface(int index) {
113: return getConnectionInstance().getImplementedInterfaceArray(
114: index);
115: }
116:
117: public void setImplementedInterface(String[] list) {
118: String[] old = getImplementedInterface();
119: getConnectionInstance().setImplementedInterfaceArray(list);
120: pcs.firePropertyChange("implementedInterface", old, list);
121: }
122:
123: public void setImplementedInterface(int index, String iface) {
124: String[] old = getImplementedInterface();
125: getConnectionInstance().setImplementedInterfaceArray(index,
126: iface);
127: pcs.firePropertyChange("implementedInterface", old,
128: getImplementedInterface());
129: }
130:
131: public ConnectionManager getConnectionManager() {
132: return manager;
133: }
134:
135: // ----------------------- End of JavaBean Properties ----------------------
136:
137: protected SchemaTypeLoader getSchemaTypeLoader() {
138: return Connector15DCBRoot.SCHEMA_TYPE_LOADER;
139: }
140: }
|