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