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.GerEjbRefType;
020    
021    /**
022     * Represents an element of the ejb-refType in a Geronimo deployment plan.
023     *                                          <p>
024     * Has 4 JavaBean Properties                <br />
025     *  - refName (type String)                 <br />
026     *  - pattern (type Pattern)                <br />
027     *  - corbaNamingGroup (type ???)           <br />
028     *  - ejbLink (type String)                 </p>
029     *
030     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
031     */
032    public class EjbRef extends HasPattern {
033        public EjbRef() {
034            super(null);
035        }
036    
037        public EjbRef(GerEjbRefType xmlObject) {
038            super(xmlObject);
039        }
040    
041        public void setRefName(String name) {
042            String old = getEjbRef().getRefName();
043            getEjbRef().setRefName(name);
044            pcs.firePropertyChange("refName", old, name);
045        }
046    
047        public String getRefName() {
048            return getEjbRef().getRefName();
049        }
050    
051        public String getEjbLink() {
052            return getEjbRef().getEjbLink();
053        }
054    
055        public void setEjbLink(String link) {
056            GerEjbRefType ref = getEjbRef();
057            if(link != null) {
058                if(ref.isSetPattern()) {
059                    clearPatternFromChoice();
060                }
061                // todo: clear CORBA property
062            }
063            String old = getEjbLink();
064            ref.setEjbLink(link);
065            pcs.firePropertyChange("ejbLink", old, link);
066        }
067    
068    
069        protected void clearNonPatternFromChoice() {
070            GerEjbRefType ref = getEjbRef();
071            if(ref.isSetEjbLink()) {
072                String temp = ref.getEjbLink();
073                ref.unsetEjbLink();
074                pcs.firePropertyChange("ejbLink", temp, null);
075            }
076            // todo: clear CORBA property
077        }
078    
079        // todo: getter and setter for CORBA property
080    
081        protected GerEjbRefType getEjbRef() {
082            return (GerEjbRefType) getXmlObject();
083        }
084    
085        public void configure(GerEjbRefType xml) {
086            setXmlObject(xml);
087        }
088    }