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 org.apache.geronimo.xbeans.geronimo.GerResourceadapterInstanceType;
019: import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
020: import org.apache.geronimo.naming.deployment.jsr88.GBeanLocator;
021: import org.apache.xmlbeans.SchemaTypeLoader;
022: import javax.enterprise.deploy.model.DDBean;
023:
024: /**
025: * Represents /connector/resourceadapter/resourceadapter-instance in the
026: * Geronimo Connector deployment plan. The settings here correspond to
027: * /connector/resourceadapter in the J2EE plan, but since there can be
028: * several instances per resource adapter, it's not 1:1 and this is not
029: * a DConfigBean.
030: *
031: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
032: */
033: public class ResourceAdapterInstance extends ConfigHolder {
034: private DDBean resourceAdapter;
035: private GBeanLocator workManager;
036:
037: /**
038: * Present so a tool can create a new one
039: */
040: public ResourceAdapterInstance() {
041: }
042:
043: public ResourceAdapterInstance(DDBean resourceAdapter,
044: GerResourceadapterInstanceType instance) {
045: configure(resourceAdapter, instance);
046: }
047:
048: protected GerResourceadapterInstanceType getResourceAdapterInstance() {
049: return (GerResourceadapterInstanceType) getXmlObject();
050: }
051:
052: public void reconfigure() {
053: configure(resourceAdapter, getResourceAdapterInstance());
054: }
055:
056: void configure(DDBean resourceAdapter,
057: GerResourceadapterInstanceType xml) {
058: this .resourceAdapter = resourceAdapter;
059: super .configure(resourceAdapter, xml);
060: }
061:
062: protected GerConfigPropertySettingType createConfigProperty() {
063: return getResourceAdapterInstance()
064: .addNewConfigPropertySetting();
065: }
066:
067: protected GerConfigPropertySettingType[] getConfigProperties() {
068: return getResourceAdapterInstance()
069: .getConfigPropertySettingArray();
070: }
071:
072: protected void removeConfigProperty(int index) {
073: getResourceAdapterInstance().removeConfigPropertySetting(index);
074: }
075:
076: // ----------------------- JavaBean Properties for /resourceadapter-instance ----------------------
077:
078: public String getResourceAdapterName() {
079: return getResourceAdapterInstance().getResourceadapterName();
080: }
081:
082: public void setResourceAdapterName(String name) {
083: String old = getResourceAdapterName();
084: getResourceAdapterInstance().setResourceadapterName(name);
085: pcs.firePropertyChange("resourceAdapterName", old, name);
086: }
087:
088: public GBeanLocator getWorkManager() {
089: return workManager;
090: }
091:
092: public void setWorkManager(GBeanLocator locator) {
093: GBeanLocator old = getWorkManager();
094: if (locator != null && !locator.configured()) {
095: if (getResourceAdapterInstance().getWorkmanager() != null) {
096: locator.configure(getResourceAdapterInstance()
097: .getWorkmanager());
098: } else {
099: locator.configure(getResourceAdapterInstance()
100: .addNewWorkmanager());
101: }
102: }
103: workManager = locator;
104: pcs.firePropertyChange("workManager", old, workManager);
105: }
106:
107: // ----------------------- End of JavaBean Properties ----------------------
108:
109: protected SchemaTypeLoader getSchemaTypeLoader() {
110: return Connector15DCBRoot.SCHEMA_TYPE_LOADER;
111: }
112: }
|