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.j2ee.deployment.annotation;
017:
018: import java.util.ArrayList;
019: import java.util.List;
020:
021: import org.apache.geronimo.common.DeploymentException;
022: import org.apache.geronimo.xbeans.javaee.EjbJarType;
023: import org.apache.geronimo.xbeans.javaee.EjbLocalRefType;
024: import org.apache.geronimo.xbeans.javaee.EjbRefType;
025: import org.apache.geronimo.xbeans.javaee.EntityBeanType;
026: import org.apache.geronimo.xbeans.javaee.EnvEntryType;
027: import org.apache.geronimo.xbeans.javaee.LifecycleCallbackType;
028: import org.apache.geronimo.xbeans.javaee.MessageDestinationRefType;
029: import org.apache.geronimo.xbeans.javaee.MessageDrivenBeanType;
030: import org.apache.geronimo.xbeans.javaee.PersistenceContextRefType;
031: import org.apache.geronimo.xbeans.javaee.PersistenceUnitRefType;
032: import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
033: import org.apache.geronimo.xbeans.javaee.ResourceRefType;
034: import org.apache.geronimo.xbeans.javaee.ServiceRefType;
035: import org.apache.geronimo.xbeans.javaee.SessionBeanType;
036: import org.apache.xmlbeans.XmlObject;
037:
038: /**
039: * Wrapper class to encapsulate the EjbJarType class with an interface that the various
040: * AnnotationHelpers can use
041: * <p/>
042: * <p><strong>Remaining ToDo(s):</strong>
043: * <ul>
044: * <li>None
045: * </ul>
046: *
047: * @version $Rev $Date
048: * @since Geronimo 2.0
049: */
050: public class AnnotatedEjbJar implements AnnotatedApp {
051:
052: private final EjbJarType ejbJar;
053: private List<EjbRefType> ambiguousEjbRefs;
054: private AnnotatedApp delegate;
055:
056: public AnnotatedEjbJar(EjbJarType ejbJar) {
057: this .ejbJar = ejbJar;
058: }
059:
060: public void setBean(XmlObject bean) throws DeploymentException {
061: if (bean instanceof EntityBeanType) {
062: delegate = new EntityBean((EntityBeanType) bean);
063: } else if (bean instanceof MessageDrivenBeanType) {
064: delegate = new MessageDriveBean(
065: (MessageDrivenBeanType) bean);
066: } else if (bean instanceof SessionBeanType) {
067: delegate = new SessionBean((SessionBeanType) bean);
068: } else {
069: throw new DeploymentException(
070: "Unrecognized XmlBeans object: " + bean);
071: }
072: }
073:
074: /**
075: * EjbJarType methods used for the @EJB, @EJBs annotations
076: */
077: public EjbLocalRefType[] getEjbLocalRefArray() {
078: return delegate.getEjbLocalRefArray();
079: }
080:
081: public EjbLocalRefType addNewEjbLocalRef() {
082: return delegate.addNewEjbLocalRef();
083: }
084:
085: public EjbRefType[] getEjbRefArray() {
086: return delegate.getEjbRefArray();
087: }
088:
089: public EjbRefType addNewEjbRef() {
090: return delegate.addNewEjbRef();
091: }
092:
093: /**
094: * EjbJarType methods used for the @Resource, @Resources annotations
095: */
096: public EnvEntryType[] getEnvEntryArray() {
097: return delegate.getEnvEntryArray();
098: }
099:
100: public EnvEntryType addNewEnvEntry() {
101: return delegate.addNewEnvEntry();
102: }
103:
104: public ServiceRefType[] getServiceRefArray() {
105: return delegate.getServiceRefArray();
106: }
107:
108: public ServiceRefType addNewServiceRef() {
109: return delegate.addNewServiceRef();
110: }
111:
112: public ResourceRefType[] getResourceRefArray() {
113: return delegate.getResourceRefArray();
114: }
115:
116: public ResourceRefType addNewResourceRef() {
117: return delegate.addNewResourceRef();
118: }
119:
120: public MessageDestinationRefType[] getMessageDestinationRefArray() {
121: return delegate.getMessageDestinationRefArray();
122: }
123:
124: public MessageDestinationRefType addNewMessageDestinationRef() {
125: return delegate.addNewMessageDestinationRef();
126: }
127:
128: public ResourceEnvRefType[] getResourceEnvRefArray() {
129: return delegate.getResourceEnvRefArray();
130: }
131:
132: public ResourceEnvRefType addNewResourceEnvRef() {
133: return delegate.addNewResourceEnvRef();
134: }
135:
136: public LifecycleCallbackType[] getPostConstructArray() {
137: return delegate.getPostConstructArray();
138: }
139:
140: public LifecycleCallbackType addPostConstruct() {
141: return delegate.addPostConstruct();
142: }
143:
144: public LifecycleCallbackType[] getPreDestroyArray() {
145: return delegate.getPreDestroyArray();
146: }
147:
148: public LifecycleCallbackType addPreDestroy() {
149: return delegate.addPreDestroy();
150: }
151:
152: public PersistenceContextRefType[] getPersistenceContextRefArray() {
153: return delegate.getPersistenceContextRefArray();
154: }
155:
156: public PersistenceContextRefType addNewPersistenceContextRef() {
157: return delegate.addNewPersistenceContextRef();
158: }
159:
160: public PersistenceUnitRefType[] getPersistenceUnitRefArray() {
161: return delegate.getPersistenceUnitRefArray();
162: }
163:
164: public PersistenceUnitRefType addNewPersistenceUnitRef() {
165: return delegate.addNewPersistenceUnitRef();
166: }
167:
168: public String getComponentType() {
169: return null;
170: }
171:
172: /**
173: * ejbJar getter
174: *
175: * @return String representation of ejbJar
176: */
177: public String toString() {
178: return ejbJar.xmlText();
179: }
180:
181: public EjbJarType getEjbJar() {
182: return ejbJar;
183: }
184:
185: /**
186: * ambiguousRefs getter
187: * <p/>
188: * <p>There is no corresponding setter method. To add a new item to the list do:
189: * <pre>
190: * getAmbiguousEjbRefs().add(ejbRef);
191: * </pre>
192: *
193: * @return ambiguousRefs list
194: */
195: public List<EjbRefType> getAmbiguousEjbRefs() {
196: if (ambiguousEjbRefs == null) {
197: ambiguousEjbRefs = new ArrayList<EjbRefType>();
198: }
199: return this .ambiguousEjbRefs;
200: }
201:
202: public static class EntityBean implements AnnotatedApp {
203: private final EntityBeanType bean;
204:
205: public EntityBean(EntityBeanType bean) {
206: this .bean = bean;
207: }
208:
209: public EjbLocalRefType[] getEjbLocalRefArray() {
210: return bean.getEjbLocalRefArray();
211: }
212:
213: public EjbLocalRefType addNewEjbLocalRef() {
214: return bean.addNewEjbLocalRef();
215: }
216:
217: public EjbRefType[] getEjbRefArray() {
218: return bean.getEjbRefArray();
219: }
220:
221: public EjbRefType addNewEjbRef() {
222: return bean.addNewEjbRef();
223: }
224:
225: public EnvEntryType[] getEnvEntryArray() {
226: return bean.getEnvEntryArray();
227: }
228:
229: public EnvEntryType addNewEnvEntry() {
230: return bean.addNewEnvEntry();
231: }
232:
233: public ServiceRefType[] getServiceRefArray() {
234: return bean.getServiceRefArray();
235: }
236:
237: public ServiceRefType addNewServiceRef() {
238: return bean.addNewServiceRef();
239: }
240:
241: public ResourceRefType[] getResourceRefArray() {
242: return bean.getResourceRefArray();
243: }
244:
245: public ResourceRefType addNewResourceRef() {
246: return bean.addNewResourceRef();
247: }
248:
249: public MessageDestinationRefType[] getMessageDestinationRefArray() {
250: return bean.getMessageDestinationRefArray();
251: }
252:
253: public MessageDestinationRefType addNewMessageDestinationRef() {
254: return bean.addNewMessageDestinationRef();
255: }
256:
257: public ResourceEnvRefType[] getResourceEnvRefArray() {
258: return bean.getResourceEnvRefArray();
259: }
260:
261: public ResourceEnvRefType addNewResourceEnvRef() {
262: return bean.addNewResourceEnvRef();
263: }
264:
265: public String toString() {
266: return bean.xmlText();
267: }
268:
269: public List<EjbRefType> getAmbiguousEjbRefs() {
270: throw new AssertionError("don't call this");
271: }
272:
273: public LifecycleCallbackType[] getPostConstructArray() {
274: return bean.getPostConstructArray();
275: }
276:
277: public LifecycleCallbackType addPostConstruct() {
278: return bean.addNewPostConstruct();
279: }
280:
281: public LifecycleCallbackType[] getPreDestroyArray() {
282: return bean.getPreDestroyArray();
283: }
284:
285: public LifecycleCallbackType addPreDestroy() {
286: return bean.addNewPreDestroy();
287: }
288:
289: public PersistenceContextRefType[] getPersistenceContextRefArray() {
290: return bean.getPersistenceContextRefArray();
291: }
292:
293: public PersistenceContextRefType addNewPersistenceContextRef() {
294: return bean.addNewPersistenceContextRef();
295: }
296:
297: public PersistenceUnitRefType[] getPersistenceUnitRefArray() {
298: return bean.getPersistenceUnitRefArray();
299: }
300:
301: public PersistenceUnitRefType addNewPersistenceUnitRef() {
302: return bean.addNewPersistenceUnitRef();
303: }
304:
305: public String getComponentType() {
306: return bean.getEjbClass().getStringValue().trim();
307: }
308: }
309:
310: public static class MessageDriveBean implements AnnotatedApp {
311: private final MessageDrivenBeanType bean;
312:
313: public MessageDriveBean(MessageDrivenBeanType bean) {
314: this .bean = bean;
315: }
316:
317: public EjbLocalRefType[] getEjbLocalRefArray() {
318: return bean.getEjbLocalRefArray();
319: }
320:
321: public EjbLocalRefType addNewEjbLocalRef() {
322: return bean.addNewEjbLocalRef();
323: }
324:
325: public EjbRefType[] getEjbRefArray() {
326: return bean.getEjbRefArray();
327: }
328:
329: public EjbRefType addNewEjbRef() {
330: return bean.addNewEjbRef();
331: }
332:
333: public EnvEntryType[] getEnvEntryArray() {
334: return bean.getEnvEntryArray();
335: }
336:
337: public EnvEntryType addNewEnvEntry() {
338: return bean.addNewEnvEntry();
339: }
340:
341: public ServiceRefType[] getServiceRefArray() {
342: return bean.getServiceRefArray();
343: }
344:
345: public ServiceRefType addNewServiceRef() {
346: return bean.addNewServiceRef();
347: }
348:
349: public ResourceRefType[] getResourceRefArray() {
350: return bean.getResourceRefArray();
351: }
352:
353: public ResourceRefType addNewResourceRef() {
354: return bean.addNewResourceRef();
355: }
356:
357: public MessageDestinationRefType[] getMessageDestinationRefArray() {
358: return bean.getMessageDestinationRefArray();
359: }
360:
361: public MessageDestinationRefType addNewMessageDestinationRef() {
362: return bean.addNewMessageDestinationRef();
363: }
364:
365: public ResourceEnvRefType[] getResourceEnvRefArray() {
366: return bean.getResourceEnvRefArray();
367: }
368:
369: public ResourceEnvRefType addNewResourceEnvRef() {
370: return bean.addNewResourceEnvRef();
371: }
372:
373: public String toString() {
374: return bean.xmlText();
375: }
376:
377: public List<EjbRefType> getAmbiguousEjbRefs() {
378: throw new AssertionError("don't call this");
379: }
380:
381: public LifecycleCallbackType[] getPostConstructArray() {
382: return bean.getPostConstructArray();
383: }
384:
385: public LifecycleCallbackType addPostConstruct() {
386: return bean.addNewPostConstruct();
387: }
388:
389: public LifecycleCallbackType[] getPreDestroyArray() {
390: return bean.getPreDestroyArray();
391: }
392:
393: public LifecycleCallbackType addPreDestroy() {
394: return bean.addNewPreDestroy();
395: }
396:
397: public PersistenceContextRefType[] getPersistenceContextRefArray() {
398: return bean.getPersistenceContextRefArray();
399: }
400:
401: public PersistenceContextRefType addNewPersistenceContextRef() {
402: return bean.addNewPersistenceContextRef();
403: }
404:
405: public PersistenceUnitRefType[] getPersistenceUnitRefArray() {
406: return bean.getPersistenceUnitRefArray();
407: }
408:
409: public PersistenceUnitRefType addNewPersistenceUnitRef() {
410: return bean.addNewPersistenceUnitRef();
411: }
412:
413: public String getComponentType() {
414: return bean.getEjbClass().getStringValue().trim();
415: }
416: }
417:
418: public static class SessionBean implements AnnotatedApp {
419: private final SessionBeanType bean;
420:
421: public SessionBean(SessionBeanType bean) {
422: this .bean = bean;
423: }
424:
425: public EjbLocalRefType[] getEjbLocalRefArray() {
426: return bean.getEjbLocalRefArray();
427: }
428:
429: public EjbLocalRefType addNewEjbLocalRef() {
430: return bean.addNewEjbLocalRef();
431: }
432:
433: public EjbRefType[] getEjbRefArray() {
434: return bean.getEjbRefArray();
435: }
436:
437: public EjbRefType addNewEjbRef() {
438: return bean.addNewEjbRef();
439: }
440:
441: public EnvEntryType[] getEnvEntryArray() {
442: return bean.getEnvEntryArray();
443: }
444:
445: public EnvEntryType addNewEnvEntry() {
446: return bean.addNewEnvEntry();
447: }
448:
449: public ServiceRefType[] getServiceRefArray() {
450: return bean.getServiceRefArray();
451: }
452:
453: public ServiceRefType addNewServiceRef() {
454: return bean.addNewServiceRef();
455: }
456:
457: public ResourceRefType[] getResourceRefArray() {
458: return bean.getResourceRefArray();
459: }
460:
461: public ResourceRefType addNewResourceRef() {
462: return bean.addNewResourceRef();
463: }
464:
465: public MessageDestinationRefType[] getMessageDestinationRefArray() {
466: return bean.getMessageDestinationRefArray();
467: }
468:
469: public MessageDestinationRefType addNewMessageDestinationRef() {
470: return bean.addNewMessageDestinationRef();
471: }
472:
473: public ResourceEnvRefType[] getResourceEnvRefArray() {
474: return bean.getResourceEnvRefArray();
475: }
476:
477: public ResourceEnvRefType addNewResourceEnvRef() {
478: return bean.addNewResourceEnvRef();
479: }
480:
481: public String toString() {
482: return bean.xmlText();
483: }
484:
485: public List<EjbRefType> getAmbiguousEjbRefs() {
486: throw new AssertionError("don't call this");
487: }
488:
489: public LifecycleCallbackType[] getPostConstructArray() {
490: return bean.getPostConstructArray();
491: }
492:
493: public LifecycleCallbackType addPostConstruct() {
494: return bean.addNewPostConstruct();
495: }
496:
497: public LifecycleCallbackType[] getPreDestroyArray() {
498: return bean.getPreDestroyArray();
499: }
500:
501: public LifecycleCallbackType addPreDestroy() {
502: return bean.addNewPreDestroy();
503: }
504:
505: public PersistenceContextRefType[] getPersistenceContextRefArray() {
506: return bean.getPersistenceContextRefArray();
507: }
508:
509: public PersistenceContextRefType addNewPersistenceContextRef() {
510: return bean.addNewPersistenceContextRef();
511: }
512:
513: public PersistenceUnitRefType[] getPersistenceUnitRefArray() {
514: return bean.getPersistenceUnitRefArray();
515: }
516:
517: public PersistenceUnitRefType addNewPersistenceUnitRef() {
518: return bean.addNewPersistenceUnitRef();
519: }
520:
521: public String getComponentType() {
522: return bean.getEjbClass().getStringValue().trim();
523: }
524: }
525: }
|