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