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     */
017    package org.apache.geronimo.connector.deployment.jsr88;
018    
019    import org.apache.geronimo.xbeans.geronimo.GerAdminobjectInstanceType;
020    import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
021    import org.apache.xmlbeans.SchemaTypeLoader;
022    import javax.enterprise.deploy.model.DDBean;
023    
024    /**
025     * Represents /connector/adminobject/adminobject-instance in the
026     * Geronimo Connector deployment plan.
027     *
028     * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
029     */
030    public class AdminObjectInstance extends ConfigHolder {
031        private DDBean adminObject;
032    
033        public AdminObjectInstance() {
034        }
035    
036        public AdminObjectInstance(DDBean adminObject, GerAdminobjectInstanceType instance) {
037            configure(adminObject, instance);
038        }
039    
040        protected GerAdminobjectInstanceType getAdminInstance() {
041            return (GerAdminobjectInstanceType) getXmlObject();
042        }
043    
044        public void reconfigure() {
045            configure(adminObject, getAdminInstance());
046        }
047    
048        void configure(DDBean adminObject, GerAdminobjectInstanceType definition) {
049            this.adminObject = adminObject;
050            super.configure(adminObject, definition);
051        }
052    
053        protected GerConfigPropertySettingType createConfigProperty() {
054            return getAdminInstance().addNewConfigPropertySetting();
055        }
056    
057        protected GerConfigPropertySettingType[] getConfigProperties() {
058            return getAdminInstance().getConfigPropertySettingArray();
059        }
060    
061        protected void removeConfigProperty(int index) {
062            getAdminInstance().removeConfigPropertySetting(index);
063        }
064    
065        // ----------------------- JavaBean Properties for /adminobject-instance ----------------------
066    
067        public String getMessageDestinationName() {
068            return getAdminInstance().getMessageDestinationName();
069        }
070    
071        public void setMessageDestinationName(String name) {
072            String old = getMessageDestinationName();
073            getAdminInstance().setMessageDestinationName(name);
074            pcs.firePropertyChange("messageDestinationName", old, name);
075        }
076    
077        // ----------------------- End of JavaBean Properties ----------------------
078    
079        protected SchemaTypeLoader getSchemaTypeLoader() {
080            return Connector15DCBRoot.SCHEMA_TYPE_LOADER;
081        }
082    }