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.dconfigbean;
017:
018: import javax.enterprise.deploy.model.DDBean;
019: import javax.enterprise.deploy.model.XpathListener;
020:
021: import org.apache.geronimo.deployment.plugin.XmlBeanSupport;
022: import org.apache.geronimo.xbeans.geronimo.GerAdminobjectInstanceType;
023: import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
024: import org.apache.xmlbeans.SchemaTypeLoader;
025: import org.apache.xmlbeans.XmlBeans;
026:
027: /**
028: *
029: *
030: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
031: *
032: * */
033: public class AdminObjectInstance extends XmlBeanSupport {
034: private final static SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans
035: .getContextTypeLoader();
036: private AdminObjectDConfigBean parent;
037: private ConfigPropertySettings[] configs;
038: private XpathListener configListener;
039:
040: public AdminObjectInstance() {
041: super (null);
042: }
043:
044: void initialize(GerAdminobjectInstanceType xmlObject,
045: AdminObjectDConfigBean parent) {
046: setXmlObject(xmlObject);
047: this .parent = parent;
048: DDBean parentDDBean = parent.getDDBean();
049: configListener = ConfigPropertiesHelper.initialize(
050: parentDDBean,
051: new ConfigPropertiesHelper.ConfigPropertiesSource() {
052: public GerConfigPropertySettingType[] getConfigPropertySettingArray() {
053: return getAdminobjectInstance()
054: .getConfigPropertySettingArray();
055: }
056:
057: public GerConfigPropertySettingType addNewConfigPropertySetting() {
058: return getAdminobjectInstance()
059: .addNewConfigPropertySetting();
060: }
061:
062: public void removeConfigPropertySetting(int j) {
063: getAdminobjectInstance()
064: .removeConfigPropertySetting(j);
065: }
066:
067: public ConfigPropertySettings[] getConfigPropertySettings() {
068: return configs;
069: }
070:
071: public void setConfigPropertySettings(
072: ConfigPropertySettings[] configs) {
073: setConfigProperty(configs);
074: }
075:
076: }, "config-property", "config-property-name");
077: }
078:
079: boolean hasParent() {
080: return parent != null;
081: }
082:
083: void dispose() {
084: if (configs != null) {
085: for (int i = 0; i < configs.length; i++) {
086: configs[i].dispose();
087: }
088: }
089: if (parent != null) {
090: parent.getDDBean().removeXpathListener("config-property",
091: configListener);
092: }
093: configs = null;
094: configListener = null;
095: parent = null;
096: }
097:
098: // JavaBean properties for this object (with a couple helper methods)
099: GerAdminobjectInstanceType getAdminobjectInstance() {
100: return (GerAdminobjectInstanceType) getXmlObject();
101: }
102:
103: public ConfigPropertySettings[] getConfigProperty() {
104: return configs;
105: }
106:
107: private void setConfigProperty(ConfigPropertySettings[] configs) { // can only be changed by adding a new DDBean
108: ConfigPropertySettings[] old = getConfigProperty();
109: this .configs = configs;
110: pcs.firePropertyChange("configProperty", old, configs);
111: }
112:
113: public String getMessageDestinationName() {
114: return getAdminobjectInstance().getMessageDestinationName();
115: }
116:
117: public void setMessageDestinationName(String messageDestinationName) {
118: getAdminobjectInstance().setMessageDestinationName(
119: messageDestinationName);
120: }
121:
122: }
|