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 ejb-refType is used by ejb-ref elements for the
033: * declaration of a reference to an enterprise bean's home or
034: * to the remote business interface of a 3.0 bean.
035: * The declaration consists of:
036: * <p/>
037: * - an optional description
038: * - the EJB reference name used in the code of
039: * the Deployment Component that's referencing the enterprise
040: * bean.
041: * - the optional expected type of the referenced enterprise bean
042: * - the optional remote interface of the referenced enterprise bean
043: * or the remote business interface of the referenced enterprise
044: * bean
045: * - the optional expected home interface of the referenced
046: * enterprise bean. Not applicable if this ejb-ref
047: * refers to the remote business interface of a 3.0 bean.
048: * - optional ejb-link information, used to specify the
049: * referenced enterprise bean
050: * - optional elements to define injection of the named enterprise
051: * bean into a component field or property
052: */
053: @XmlAccessorType(XmlAccessType.FIELD)
054: @XmlType(name="ejb-refType",propOrder={"description","ejbRefName","ejbRefType","home","remote","ejbLink","mappedName","injectionTarget"})
055: public class EjbRef implements EjbReference {
056:
057: @XmlElement(required=true)
058: protected List<Text> description;
059: @XmlElement(name="ejb-ref-name",required=true)
060: protected String ejbRefName;
061: @XmlElement(name="ejb-ref-type")
062: protected EjbRefType ejbRefType;
063: protected String home;
064: protected String remote;
065: @XmlElement(name="ejb-link")
066: protected String ejbLink;
067: @XmlElement(name="mapped-name")
068: protected String mappedName;
069: @XmlElement(name="injection-target",required=true)
070: protected List<InjectionTarget> injectionTarget;
071: @XmlAttribute
072: @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
073: @XmlID
074: protected String id;
075:
076: @XmlTransient
077: protected Type refType = Type.REMOTE;
078:
079: public Type getRefType() {
080: return refType;
081: }
082:
083: public void setRefType(Type refType) {
084: this .refType = refType;
085: }
086:
087: public List<Text> getDescription() {
088: if (description == null) {
089: description = new ArrayList<Text>();
090: }
091: return this .description;
092: }
093:
094: public String getEjbRefName() {
095: return ejbRefName;
096: }
097:
098: public String getName() {
099: return getEjbRefName();
100: }
101:
102: public String getKey() {
103: return getName();
104: }
105:
106: public String getType() {
107: return getEjbRefType().name();
108: }
109:
110: public void setName(String name) {
111: setEjbRefName(name);
112: }
113:
114: public void setType(String type) {
115: }
116:
117: /**
118: * The ejb-ref-name element contains the name of an EJB
119: * reference. The EJB reference is an entry in the
120: * Deployment Component's environment and is relative to the
121: * java:comp/env context. The name must be unique within the
122: * Deployment Component.
123: * <p/>
124: * It is recommended that name is prefixed with "ejb/".
125: * <p/>
126: * Example:
127: * <p/>
128: * <ejb-ref-name>ejb/Payroll</ejb-ref-name>
129: */
130: public void setEjbRefName(String value) {
131: this .ejbRefName = value;
132: }
133:
134: public EjbRefType getEjbRefType() {
135: return ejbRefType;
136: }
137:
138: public void setEjbRefType(EjbRefType value) {
139: this .ejbRefType = value;
140: }
141:
142: public String getHome() {
143: return home;
144: }
145:
146: public void setHome(String value) {
147: this .home = value;
148: }
149:
150: public String getRemote() {
151: return remote;
152: }
153:
154: public String getInterface() {
155: return getRemote();
156: }
157:
158: public void setRemote(String value) {
159: this .remote = value;
160: }
161:
162: /**
163: * The value of the ejb-link element must be the ejb-name of an
164: * enterprise bean in the same ejb-jar file or in another ejb-jar
165: * file in the same Java EE application unit.
166: * <p/>
167: * Alternatively, the name in the ejb-link element may be
168: * composed of a path name specifying the ejb-jar containing the
169: * referenced enterprise bean with the ejb-name of the target
170: * bean appended and separated from the path name by "#". The
171: * path name is relative to the Deployment File containing
172: * Deployment Component that is referencing the enterprise
173: * bean. This allows multiple enterprise beans with the same
174: * ejb-name to be uniquely identified.
175: * <p/>
176: * Examples:
177: * <p/>
178: * <ejb-link>EmployeeRecord</ejb-link>
179: * <p/>
180: * <ejb-link>../products/product.jar#ProductEJB</ejb-link>
181: */
182: public String getEjbLink() {
183: return ejbLink;
184: }
185:
186: public void setEjbLink(String value) {
187: this .ejbLink = value;
188: }
189:
190: public String getMappedName() {
191: return mappedName;
192: }
193:
194: public void setMappedName(String value) {
195: this .mappedName = value;
196: }
197:
198: public List<InjectionTarget> getInjectionTarget() {
199: if (injectionTarget == null) {
200: injectionTarget = new ArrayList<InjectionTarget>();
201: }
202: return this .injectionTarget;
203: }
204:
205: public String getId() {
206: return id;
207: }
208:
209: public void setId(String value) {
210: this.id = value;
211: }
212:
213: }
|