001    /**
002     *
003     *  Licensed to the Apache Software Foundation (ASF) under one or more
004     *  contributor license agreements.  See the NOTICE file distributed with
005     *  this work for additional information regarding copyright ownership.
006     *  The ASF licenses this file to You under the Apache License, Version 2.0
007     *  (the "License"); you may not use this file except in compliance with
008     *  the License.  You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     *  Unless required by applicable law or agreed to in writing, software
013     *  distributed under the License is distributed on an "AS IS" BASIS,
014     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     *  See the License for the specific language governing permissions and
016     *  limitations under the License.
017     */
018    package org.apache.geronimo.naming.deployment.jsr88;
019    
020    import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
021    import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
022    
023    /**
024     * Represents an element of the resource-env-refType in a Geronimo deployment
025     * plan.
026     *                                             <p>
027     * Has 4 JavaBean Properties                   <br />
028     *  - refName (type String)                    <br />
029     *  - pattern (type Pattern)                   <br />
030     *  - adminObjectModule (type String)          <br />
031     *  - adminObjectLink (type String)            </p>
032     *
033     * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
034     */
035    public class ResourceEnvRef extends HasPattern {
036        public ResourceEnvRef() {
037            super(null);
038        }
039    
040        public ResourceEnvRef(GerResourceEnvRefType xmlObject) {
041            super(xmlObject);
042        }
043    
044        public void setRefName(String name) {
045            String old = getResourceRef().getRefName();
046            getResourceRef().setRefName(name);
047            pcs.firePropertyChange("refName", old, name);
048        }
049    
050        public String getRefName() {
051            return getResourceRef().getRefName();
052        }
053    
054        public String getAdminObjectLink() {
055            return getResourceRef().getAdminObjectLink();
056        }
057    
058        public void setAdminObjectLink(String link) {
059            GerResourceEnvRefType ref = getResourceRef();
060            if(link != null && ref.isSetPattern()) {
061                clearPatternFromChoice();
062            }
063            String old = getAdminObjectLink();
064            ref.setAdminObjectLink(link);
065            pcs.firePropertyChange("adminObjectLink", old, link);
066        }
067    
068        public String getAdminObjectModule() {
069            return getResourceRef().getAdminObjectModule();
070        }
071    
072        public void setAdminObjectModule(String module) {
073            GerResourceEnvRefType ref = getResourceRef();
074            if(module != null && ref.isSetPattern()) {
075                clearPatternFromChoice();
076            }
077            String old = getAdminObjectModule();
078            ref.setAdminObjectModule(module);
079            pcs.firePropertyChange("adminObjectModule", old, module);
080        }
081    
082    
083        protected void clearNonPatternFromChoice() {
084            GerResourceEnvRefType ref = getResourceRef();
085            if(ref.isSetAdminObjectLink()) {
086                String temp = ref.getAdminObjectLink();
087                ref.unsetAdminObjectLink();
088                pcs.firePropertyChange("adminObjectLink", temp, null);
089            }
090            if(ref.isSetAdminObjectModule()) {
091                String temp = ref.getAdminObjectModule();
092                ref.unsetAdminObjectModule();
093                pcs.firePropertyChange("adminObjectModule", temp, null);
094            }
095        }
096    
097        protected GerResourceEnvRefType getResourceRef() {
098            return (GerResourceEnvRefType) getXmlObject();
099        }
100    
101        public void configure(GerResourceEnvRefType xml) {
102            setXmlObject(xml);
103        }
104    }