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