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