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.GerGbeanLocatorType;
020    
021    /**
022     * Represents an element of the gbean-locatorType in a Geronimo
023     * deployment plan.
024     *                                     <p>
025     * Has 2 JavaBean Properties           <br />
026     *  - GBeanLink (type String)          <br />
027     *  - pattern (type Pattern)           </p>
028     *
029     * @version $Rev: 484989 $ $Date: 2006-12-09 09:54:26 -0500 (Sat, 09 Dec 2006) $
030     */
031    public class GBeanLocator extends HasPattern {
032        public GBeanLocator() {
033            super(null);
034        }
035    
036        public GBeanLocator(GerGbeanLocatorType xmlObject) {
037            super(xmlObject);
038        }
039    
040        protected GerGbeanLocatorType getGBeanLocator() {
041            return (GerGbeanLocatorType) getXmlObject();
042        }
043    
044        public void configure(GerGbeanLocatorType xml) {
045            setXmlObject(xml);
046        }
047    
048        public String getGBeanLink() {
049            return getGBeanLocator().getGbeanLink();
050        }
051    
052        public void setGBeanLink(String link) {
053            GerGbeanLocatorType locator = getGBeanLocator();
054            if(link != null && locator.isSetPattern()) {
055                clearPatternFromChoice();
056            }
057            String old = getGBeanLink();
058            locator.setGbeanLink(link);
059            pcs.firePropertyChange("GBeanLink", old, link);
060        }
061    
062    
063        protected void clearNonPatternFromChoice() {
064            GerGbeanLocatorType locator = getGBeanLocator();
065            if(locator.isSetGbeanLink()) {
066                String temp = locator.getGbeanLink();
067                locator.unsetGbeanLink();
068                pcs.firePropertyChange("GBeanLink", temp, null);
069            }
070        }
071    }