Home » geronimo-2.2-source-release » org.apache.geronimo.naming.deployment.jsr88 » [javadoc | source]

    1   /**
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   package org.apache.geronimo.naming.deployment.jsr88;
   18   
   19   import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
   20   
   21   /**
   22    * Represents an element of the resource-refType in a Geronimo deployment
   23    * plan.
   24    *                                          <p>
   25    * Has 4 JavaBean Properties                <br />
   26    *  - refName (type String)                 <br />
   27    *  - pattern (type Pattern)                <br />
   28    *  - url (type String)                     <br />
   29    *  - resourceLink (type String)            </p>
   30    *
   31    * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
   32    */
   33   public class ResourceRef extends HasPattern {
   34       public ResourceRef() {
   35           super(null);
   36       }
   37   
   38       public ResourceRef(GerResourceRefType xmlObject) {
   39           super(xmlObject);
   40       }
   41   
   42       public void setRefName(String name) {
   43           String old = getResourceRef().getRefName();
   44           getResourceRef().setRefName(name);
   45           pcs.firePropertyChange("refName", old, name);
   46       }
   47   
   48       public String getRefName() {
   49           return getResourceRef().getRefName();
   50       }
   51   
   52       public String getResourceLink() {
   53           return getResourceRef().getResourceLink();
   54       }
   55   
   56       public void setResourceLink(String link) {
   57           GerResourceRefType ref = getResourceRef();
   58           if(link != null) {
   59               if(ref.isSetPattern()) {
   60                   clearPatternFromChoice();
   61               }
   62               if(ref.isSetUrl()) {
   63                   String old = getUrl();
   64                   ref.unsetUrl();
   65                   pcs.firePropertyChange("url", old, null);
   66               }
   67           }
   68           String old = getResourceLink();
   69           ref.setResourceLink(link);
   70           pcs.firePropertyChange("resourceLink", old, link);
   71       }
   72   
   73       public String getUrl() {
   74           return getResourceRef().getResourceLink();
   75       }
   76   
   77       public void setUrl(String link) {
   78           GerResourceRefType ref = getResourceRef();
   79           if(link != null) {
   80               if(ref.isSetPattern()) {
   81                   clearPatternFromChoice();
   82               }
   83               if(ref.isSetResourceLink()) {
   84                   String old = getResourceLink();
   85                   ref.unsetResourceLink();
   86                   pcs.firePropertyChange("resourceLink", old, null);
   87               }
   88           }
   89           String old = getUrl();
   90           ref.setUrl(link);
   91           pcs.firePropertyChange("url", old, link);
   92       }
   93   
   94   
   95       protected void clearNonPatternFromChoice() {
   96           GerResourceRefType ref = getResourceRef();
   97           if(ref.isSetResourceLink()) {
   98               String temp = ref.getResourceLink();
   99               ref.unsetResourceLink();
  100               pcs.firePropertyChange("resourceLink", temp, null);
  101           }
  102           if(ref.isSetUrl()) {
  103               String temp = ref.getUrl();
  104               ref.unsetUrl();
  105               pcs.firePropertyChange("url", temp, null);
  106           }
  107       }
  108   
  109       protected GerResourceRefType getResourceRef() {
  110           return (GerResourceRefType) getXmlObject();
  111       }
  112   
  113       public void configure(GerResourceRefType xml) {
  114           setXmlObject(xml);
  115       }
  116   }

Home » geronimo-2.2-source-release » org.apache.geronimo.naming.deployment.jsr88 » [javadoc | source]