KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > ejb > dd > AbstractEjbDeploymentDescriptorSubTask


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet.modules.ejb.dd;
6
7 import java.util.Collection JavaDoc;
8 import java.util.Iterator JavaDoc;
9
10 import xjavadoc.*;
11 import xdoclet.XDocletException;
12 import xdoclet.XmlSubTask;
13 import xdoclet.modules.ejb.entity.CmpTagsHandler;
14
15 /**
16  * Base class for all subtasks that generate xml-ish ejb deployment descriptors.
17  *
18  * @author Ara Abrahamian (ara_e@email.com)
19  * @created Dec 11, 2001
20  * @version $Revision: 1.6 $
21  */

22 public abstract class AbstractEjbDeploymentDescriptorSubTask extends XmlSubTask
23 {
24     private final static int DONT_CARE = 0;
25     private final static int CMP_2_X = 1;
26     private final static int CMP_1_X = 2;
27
28     /**
29      * Describe what the method does
30      *
31      * @return Describe the return value
32      * @exception XDocletException
33      */

34     protected boolean atLeastOneCmpEntityBeanExists() throws XDocletException
35     {
36         return atLeastOneCmpEntityBeanExists(DONT_CARE);
37     }
38
39     /**
40      * Describe what the method does
41      *
42      * @return Describe the return value
43      * @exception XDocletException
44      */

45     protected boolean atLeastOneCmp1EntityBeanExists() throws XDocletException
46     {
47         return atLeastOneCmpEntityBeanExists(CMP_1_X);
48     }
49
50     /**
51      * Describe what the method does
52      *
53      * @return Describe the return value
54      * @exception XDocletException
55      */

56     protected boolean atLeastOneCmp2EntityBeanExists() throws XDocletException
57     {
58         return atLeastOneCmpEntityBeanExists(CMP_2_X);
59     }
60
61     /**
62      * Describe what the method does
63      *
64      * @param cmpVersion
65      * @return Describe the return value
66      * @exception XDocletException
67      */

68     private boolean atLeastOneCmpEntityBeanExists(int cmpVersion) throws XDocletException
69     {
70         Collection JavaDoc classes = getXJavaDoc().getSourceClasses();
71
72         for (Iterator JavaDoc i = classes.iterator(); i.hasNext(); ) {
73             XClass clazz = (XClass) i.next();
74
75             if (CmpTagsHandler.isEntityCmp(clazz) &&
76                 (cmpVersion == DONT_CARE ||
77                 (cmpVersion == CMP_2_X && CmpTagsHandler.isUsingCmp2Impl(clazz)) ||
78                 (cmpVersion == CMP_1_X && !CmpTagsHandler.isUsingCmp2Impl(clazz)))) {
79                 return true;
80             }
81         }
82
83         return false;
84     }
85 }
86
Popular Tags