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.GerResourceRefType; 021 022 /** 023 * Represents an element of the resource-refType in a Geronimo deployment 024 * plan. 025 * <p> 026 * Has 4 JavaBean Properties <br /> 027 * - refName (type String) <br /> 028 * - pattern (type Pattern) <br /> 029 * - url (type String) <br /> 030 * - resourceLink (type String) </p> 031 * 032 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $ 033 */ 034 public class ResourceRef extends HasPattern { 035 public ResourceRef() { 036 super(null); 037 } 038 039 public ResourceRef(GerResourceRefType xmlObject) { 040 super(xmlObject); 041 } 042 043 public void setRefName(String name) { 044 String old = getResourceRef().getRefName(); 045 getResourceRef().setRefName(name); 046 pcs.firePropertyChange("refName", old, name); 047 } 048 049 public String getRefName() { 050 return getResourceRef().getRefName(); 051 } 052 053 public String getResourceLink() { 054 return getResourceRef().getResourceLink(); 055 } 056 057 public void setResourceLink(String link) { 058 GerResourceRefType ref = getResourceRef(); 059 if(link != null) { 060 if(ref.isSetPattern()) { 061 clearPatternFromChoice(); 062 } 063 if(ref.isSetUrl()) { 064 String old = getUrl(); 065 ref.unsetUrl(); 066 pcs.firePropertyChange("url", old, null); 067 } 068 } 069 String old = getResourceLink(); 070 ref.setResourceLink(link); 071 pcs.firePropertyChange("resourceLink", old, link); 072 } 073 074 public String getUrl() { 075 return getResourceRef().getResourceLink(); 076 } 077 078 public void setUrl(String link) { 079 GerResourceRefType ref = getResourceRef(); 080 if(link != null) { 081 if(ref.isSetPattern()) { 082 clearPatternFromChoice(); 083 } 084 if(ref.isSetResourceLink()) { 085 String old = getResourceLink(); 086 ref.unsetResourceLink(); 087 pcs.firePropertyChange("resourceLink", old, null); 088 } 089 } 090 String old = getUrl(); 091 ref.setUrl(link); 092 pcs.firePropertyChange("url", old, link); 093 } 094 095 096 protected void clearNonPatternFromChoice() { 097 GerResourceRefType ref = getResourceRef(); 098 if(ref.isSetResourceLink()) { 099 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 }