1 5 package xdoclet.modules.ejb.entity; 6 7 import java.lang.reflect.Modifier ; 8 9 import java.util.Collection ; 10 import java.util.Iterator ; 11 12 import xjavadoc.*; 13 import xdoclet.DocletSupport; 14 import xdoclet.XDocletException; 15 import xdoclet.modules.ejb.EjbDocletTask; 16 import xdoclet.modules.ejb.EjbTagsHandler; 17 import xdoclet.modules.ejb.entity.BmpTagsHandler; 18 import xdoclet.modules.ejb.entity.CmpTagsHandler; 19 20 26 public class EntityTagsHandler extends EjbTagsHandler 27 { 28 34 public static boolean isEntity(XClass clazz) 35 { 36 return clazz.isA("javax.ejb.EntityBean"); 37 } 38 39 public static boolean isEjbSelectMethod(XMethod method) 40 { 41 if (method.getName().startsWith("ejbSelect") == false) 43 return false; 44 45 if (method.getName().length() <= "ejbSelect".length()) 47 return false; 48 49 if ((method.getModifierSpecifier() & Modifier.ABSTRACT) == 0 || (method.getModifierSpecifier() & Modifier.PUBLIC) == 0) 51 return false; 52 53 if (method.getReturnType().getType().getName().equals("void")) 55 return false; 56 57 61 65 return true; 66 } 67 68 76 public void ifEntity(String template) throws XDocletException 77 { 78 if (isEntity(getCurrentClass())) { 79 generate(template); 80 } 81 } 82 83 84 93 public String persistenceType() throws XDocletException 94 { 95 if (CmpTagsHandler.isEntityCmp(getCurrentClass()) && 96 !BmpTagsHandler.isEntityBmp(getCurrentClass())) { 97 return "Container"; 98 } 99 else { 100 return "Bean"; 101 } 102 } 103 104 105 113 public void forAllEntityBeans(String template) throws XDocletException 114 { 115 Collection classes = getXJavaDoc().getSourceClasses(); 116 117 for (Iterator i = classes.iterator(); i.hasNext(); ) { 118 XClass clazz = (XClass) i.next(); 119 120 setCurrentClass(clazz); 121 122 if (DocletSupport.isDocletGenerated(getCurrentClass())) { 123 continue; 124 } 125 126 if (!hasHavingClassTag(getCurrentClass())) { 127 continue; 128 } 129 130 if (isEntity(getCurrentClass())) { 131 generate(template); 132 } 133 } 134 } 135 136 137 146 public String reentrant() throws XDocletException 147 { 148 String value = 149 getTagValue( 150 FOR_CLASS, 151 "ejb:bean", 152 "reentrant", 153 null, 154 "false", 155 true, 156 false 157 ); 158 159 String ejbSpec = EjbTagsHandler.getEjbSpec(); 160 161 if (ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_1_1) || 162 ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_2_0)) { 163 return value.substring(0, 1).toUpperCase() + value.substring(1).toLowerCase(); 165 } 166 else { 167 return value.toLowerCase(); 169 } 170 } 171 172 180 public void forAllEjbSelectMethods(String template) throws XDocletException 181 { 182 XMethod old_cur_method = getCurrentMethod(); 183 184 for (Iterator i = getCurrentClass().getMethods(true).iterator(); i.hasNext(); ) { 185 XMethod method = (XMethod) i.next(); 186 187 if (isEjbSelectMethod(method)) { 188 setCurrentMethod(method); 189 generate(template); 190 } 191 } 192 193 setCurrentMethod(old_cur_method); 194 } 195 } 196 | Popular Tags |