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