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.naming.deployment.jsr88;
018    
019    import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
020    import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
021    
022    /**
023     * Represents an element of the resource-env-refType in a Geronimo deployment
024     * plan.
025     *                                             <p>
026     * Has 4 JavaBean Properties                   <br />
027     *  - refName (type String)                    <br />
028     *  - pattern (type Pattern)                   <br />
029     *  - adminObjectModule (type String)          <br />
030     *  - adminObjectLink (type String)            </p>
031     *
032     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
033     */
034    public class ResourceEnvRef extends HasPattern {
035        public ResourceEnvRef() {
036            super(null);
037        }
038    
039        public ResourceEnvRef(GerResourceEnvRefType xmlObject) {
040            super(xmlObject);
041        }
042    
043        public void setRefName(String name) {
044            String old = getResourceRef().getRefName();
045            getResourceRef().setRefName(name);
046            pcs.firePropertyChange("refName", old, name);
047        }
048    
049        public String getRefName() {
050            return getResourceRef().getRefName();
051        }
052    
053        public String getAdminObjectLink() {
054            return getResourceRef().getAdminObjectLink();
055        }
056    
057        public void setAdminObjectLink(String link) {
058            GerResourceEnvRefType ref = getResourceRef();
059            if(link != null && ref.isSetPattern()) {
060                clearPatternFromChoice();
061            }
062            String old = getAdminObjectLink();
063            ref.setAdminObjectLink(link);
064            pcs.firePropertyChange("adminObjectLink", old, link);
065        }
066    
067        public String getAdminObjectModule() {
068            return getResourceRef().getAdminObjectModule();
069        }
070    
071        public void setAdminObjectModule(String module) {
072            GerResourceEnvRefType ref = getResourceRef();
073            if(module != null && ref.isSetPattern()) {
074                clearPatternFromChoice();
075            }
076            String old = getAdminObjectModule();
077            ref.setAdminObjectModule(module);
078            pcs.firePropertyChange("adminObjectModule", old, module);
079        }
080    
081    
082        protected void clearNonPatternFromChoice() {
083            GerResourceEnvRefType ref = getResourceRef();
084            if(ref.isSetAdminObjectLink()) {
085                String temp = ref.getAdminObjectLink();
086                ref.unsetAdminObjectLink();
087                pcs.firePropertyChange("adminObjectLink", temp, null);
088            }
089            if(ref.isSetAdminObjectModule()) {
090                String temp = ref.getAdminObjectModule();
091                ref.unsetAdminObjectModule();
092                pcs.firePropertyChange("adminObjectModule", temp, null);
093            }
094        }
095    
096        protected GerResourceEnvRefType getResourceRef() {
097            return (GerResourceEnvRefType) getXmlObject();
098        }
099    
100        public void configure(GerResourceEnvRefType xml) {
101            setXmlObject(xml);
102        }
103    }