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 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
22
23 /**
24 * Represents an element of the resource-env-refType in a Geronimo deployment
25 * plan.
26 * <p>
27 * Has 4 JavaBean Properties <br />
28 * - refName (type String) <br />
29 * - pattern (type Pattern) <br />
30 * - adminObjectModule (type String) <br />
31 * - adminObjectLink (type String) </p>
32 *
33 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
34 */
35 public class ResourceEnvRef extends HasPattern {
36 public ResourceEnvRef() {
37 super(null);
38 }
39
40 public ResourceEnvRef(GerResourceEnvRefType xmlObject) {
41 super(xmlObject);
42 }
43
44 public void setRefName(String name) {
45 String old = getResourceRef().getRefName();
46 getResourceRef().setRefName(name);
47 pcs.firePropertyChange("refName", old, name);
48 }
49
50 public String getRefName() {
51 return getResourceRef().getRefName();
52 }
53
54 public String getAdminObjectLink() {
55 return getResourceRef().getAdminObjectLink();
56 }
57
58 public void setAdminObjectLink(String link) {
59 GerResourceEnvRefType ref = getResourceRef();
60 if(link != null && ref.isSetPattern()) {
61 clearPatternFromChoice();
62 }
63 String old = getAdminObjectLink();
64 ref.setAdminObjectLink(link);
65 pcs.firePropertyChange("adminObjectLink", old, link);
66 }
67
68 public String getAdminObjectModule() {
69 return getResourceRef().getAdminObjectModule();
70 }
71
72 public void setAdminObjectModule(String module) {
73 GerResourceEnvRefType ref = getResourceRef();
74 if(module != null && ref.isSetPattern()) {
75 clearPatternFromChoice();
76 }
77 String old = getAdminObjectModule();
78 ref.setAdminObjectModule(module);
79 pcs.firePropertyChange("adminObjectModule", old, module);
80 }
81
82
83 protected void clearNonPatternFromChoice() {
84 GerResourceEnvRefType ref = getResourceRef();
85 if(ref.isSetAdminObjectLink()) {
86 String temp = ref.getAdminObjectLink();
87 ref.unsetAdminObjectLink();
88 pcs.firePropertyChange("adminObjectLink", temp, null);
89 }
90 if(ref.isSetAdminObjectModule()) {
91 String temp = ref.getAdminObjectModule();
92 ref.unsetAdminObjectModule();
93 pcs.firePropertyChange("adminObjectModule", temp, null);
94 }
95 }
96
97 protected GerResourceEnvRefType getResourceRef() {
98 return (GerResourceEnvRefType) getXmlObject();
99 }
100
101 public void configure(GerResourceEnvRefType xml) {
102 setXmlObject(xml);
103 }
104 }