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: */package org.apache.openejb.jee;
018:
019: import javax.xml.bind.annotation.XmlAccessType;
020: import javax.xml.bind.annotation.XmlAccessorType;
021: import javax.xml.bind.annotation.XmlAttribute;
022: import javax.xml.bind.annotation.XmlElement;
023: import javax.xml.bind.annotation.XmlID;
024: import javax.xml.bind.annotation.XmlType;
025: import javax.xml.bind.annotation.XmlTransient;
026: import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
027: import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
028: import java.util.ArrayList;
029: import java.util.List;
030:
031: /**
032: * The resource-refType contains a declaration of a
033: * Deployment Component's reference to an external resource. It
034: * consists of an optional description, the resource manager
035: * connection factory reference name, an optional indication of
036: * the resource manager connection factory type expected by the
037: * Deployment Component code, an optional type of authentication
038: * (Application or Container), and an optional specification of
039: * the shareability of connections obtained from the resource
040: * (Shareable or Unshareable).
041: * <p/>
042: * It also includes optional elements to define injection of
043: * the named resource into fields or JavaBeans properties.
044: * <p/>
045: * The connection factory type must be supplied unless an
046: * injection target is specified, in which case the type
047: * of the target is used. If both are specified, the type
048: * must be assignment compatible with the type of the injection
049: * target.
050: * <p/>
051: * Example:
052: * <p/>
053: * <resource-ref>
054: * <res-ref-name>jdbc/EmployeeAppDB</res-ref-name>
055: * <res-type>javax.sql.DataSource</res-type>
056: * <res-auth>Container</res-auth>
057: * <res-sharing-scope>Shareable</res-sharing-scope>
058: * </resource-ref>
059: */
060: @XmlAccessorType(XmlAccessType.FIELD)
061: @XmlType(name="resource-refType",propOrder={"description","resRefName","resType","resAuth","resSharingScope","mappedName","injectionTarget"})
062: public class ResourceRef implements JndiReference {
063:
064: @XmlElement(required=true)
065: protected List<Text> description;
066: @XmlElement(name="res-ref-name",required=true)
067: protected String resRefName;
068: @XmlElement(name="res-type")
069: protected String resType;
070: @XmlElement(name="res-auth")
071: protected ResAuth resAuth;
072: @XmlElement(name="res-sharing-scope")
073: protected ResSharingScope resSharingScope = ResSharingScope.SHAREABLE;
074: @XmlElement(name="mapped-name")
075: protected String mappedName;
076: @XmlElement(name="injection-target",required=true)
077: protected List<InjectionTarget> injectionTarget;
078: @XmlAttribute
079: @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
080: @XmlID
081: protected String id;
082:
083: @XmlTransient
084: public String getName() {
085: return getResRefName();
086: }
087:
088: public String getKey() {
089: return getName();
090: }
091:
092: @XmlTransient
093: public String getType() {
094: return getResType();
095: }
096:
097: public void setName(String name) {
098: setResRefName(name);
099: }
100:
101: public void setType(String type) {
102: setResType(type);
103: }
104:
105: public List<Text> getDescription() {
106: if (description == null) {
107: description = new ArrayList<Text>();
108: }
109: return this .description;
110: }
111:
112: public String getResRefName() {
113: return resRefName;
114: }
115:
116: public void setResRefName(String value) {
117: this .resRefName = value;
118: }
119:
120: public String getResType() {
121: return resType;
122: }
123:
124: public void setResType(String value) {
125: this .resType = value;
126: }
127:
128: public ResAuth getResAuth() {
129: return resAuth;
130: }
131:
132: public void setResAuth(ResAuth value) {
133: this .resAuth = value;
134: }
135:
136: public ResSharingScope getResSharingScope() {
137: return resSharingScope;
138: }
139:
140: public void setResSharingScope(ResSharingScope value) {
141: this .resSharingScope = value;
142: }
143:
144: public String getMappedName() {
145: return mappedName;
146: }
147:
148: public void setMappedName(String value) {
149: this .mappedName = value;
150: }
151:
152: public List<InjectionTarget> getInjectionTarget() {
153: if (injectionTarget == null) {
154: injectionTarget = new ArrayList<InjectionTarget>();
155: }
156: return this .injectionTarget;
157: }
158:
159: public String getId() {
160: return id;
161: }
162:
163: public void setId(String value) {
164: this.id = value;
165: }
166: }
|