KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > deployment > dconfigbean > AdminObjectInstance


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
18 package org.apache.geronimo.connector.deployment.dconfigbean;
19
20 import javax.enterprise.deploy.model.DDBean JavaDoc;
21 import javax.enterprise.deploy.model.XpathListener JavaDoc;
22
23 import org.apache.geronimo.deployment.plugin.XmlBeanSupport;
24 import org.apache.geronimo.xbeans.geronimo.GerAdminobjectInstanceType;
25 import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
26 import org.apache.xmlbeans.SchemaTypeLoader;
27 import org.apache.xmlbeans.XmlBeans;
28
29 /**
30  *
31  *
32  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
33  *
34  * */

35 public class AdminObjectInstance extends XmlBeanSupport {
36     private final static SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans.getContextTypeLoader();
37     private AdminObjectDConfigBean parent;
38     private ConfigPropertySettings[] configs;
39     private XpathListener JavaDoc configListener;
40
41     public AdminObjectInstance() {
42         super(null);
43     }
44
45     void initialize(GerAdminobjectInstanceType xmlObject, AdminObjectDConfigBean parent) {
46         setXmlObject(xmlObject);
47         this.parent = parent;
48         DDBean JavaDoc parentDDBean = parent.getDDBean();
49         configListener = ConfigPropertiesHelper.initialize(parentDDBean, new ConfigPropertiesHelper.ConfigPropertiesSource() {
50             public GerConfigPropertySettingType[] getConfigPropertySettingArray() {
51                 return getAdminobjectInstance().getConfigPropertySettingArray();
52             }
53
54             public GerConfigPropertySettingType addNewConfigPropertySetting() {
55                 return getAdminobjectInstance().addNewConfigPropertySetting();
56             }
57
58             public void removeConfigPropertySetting(int j) {
59                 getAdminobjectInstance().removeConfigPropertySetting(j);
60             }
61
62             public ConfigPropertySettings[] getConfigPropertySettings() {
63                 return configs;
64             }
65
66             public void setConfigPropertySettings(ConfigPropertySettings[] configs) {
67                 setConfigProperty(configs);
68             }
69
70         }, "config-property", "config-property-name");
71     }
72
73     boolean hasParent() {
74         return parent != null;
75     }
76
77     void dispose() {
78         if (configs != null) {
79             for (int i = 0; i < configs.length; i++) {
80                 configs[i].dispose();
81             }
82         }
83         if (parent != null) {
84             parent.getDDBean().removeXpathListener("config-property", configListener);
85         }
86         configs = null;
87         configListener = null;
88         parent = null;
89     }
90
91 // JavaBean properties for this object (with a couple helper methods)
92
GerAdminobjectInstanceType getAdminobjectInstance() {
93         return (GerAdminobjectInstanceType) getXmlObject();
94     }
95
96     public ConfigPropertySettings[] getConfigProperty() {
97         return configs;
98     }
99
100     private void setConfigProperty(ConfigPropertySettings[] configs) { // can only be changed by adding a new DDBean
101
ConfigPropertySettings[] old = getConfigProperty();
102         this.configs = configs;
103         pcs.firePropertyChange("configProperty", old, configs);
104     }
105
106     public String JavaDoc getMessageDestinationName() {
107         return getAdminobjectInstance().getMessageDestinationName();
108     }
109
110     public void setMessageDestinationName(String JavaDoc messageDestinationName) {
111         getAdminobjectInstance().setMessageDestinationName(messageDestinationName);
112     }
113
114 }
115
Popular Tags