1 22 package org.jboss.verifier.strategy; 23 24 26 import org.jboss.logging.Logger; 27 import org.jboss.metadata.BeanMetaData; 28 import org.jboss.metadata.EntityMetaData; 29 import org.jboss.metadata.MessageDrivenMetaData; 30 import org.jboss.metadata.SessionMetaData; 31 import org.jboss.verifier.Section; 32 33 import java.lang.reflect.Method ; 34 import java.util.Arrays ; 35 import java.util.Iterator ; 36 37 48 public class EJBVerifier20 extends AbstractEJB2xVerifier 49 { 50 private static Logger log = Logger.getLogger(EJBVerifier20.class); 51 52 55 public EJBVerifier20(VerificationContext context) 56 { 57 super(context); 58 } 59 60 public String getMessageBundle() 61 { 62 return "EJB20Messages.properties"; 63 } 64 65 70 public void checkSession(SessionMetaData session) 71 { 72 boolean localOrRemoteExists = false; 73 boolean verified = false; 74 75 if (!verifyBean(session)) 76 return; 77 78 verified = verifySessionBean(session); 79 80 if (hasRemoteInterfaces(session)) 81 { 82 localOrRemoteExists = true; 84 verified = verified && verifySessionRemote(session); 85 verified = verified && verifySessionHome(session); 86 } 87 88 if (hasLocalInterfaces(session)) 89 { 90 localOrRemoteExists = true; 92 verified = verified && verifySessionLocal(session); 93 verified = verified && verifySessionLocalHome(session); 94 } 95 96 if (!localOrRemoteExists) 103 { 104 fireSpecViolationEvent(session, new Section("7.10.1")); 105 verified = false; 106 } 107 108 if (verified) 109 { 110 fireBeanVerifiedEvent(session); 112 } 113 } 114 115 public void checkEntity(EntityMetaData entity) 116 { 117 if (entity.isCMP1x()) 118 { 119 cmp1XVerifier.checkEntity(entity); 120 } 121 else 122 { 123 checkBmpOrCmp2Entity(entity); 124 } 125 } 126 127 public void checkMessageBean(MessageDrivenMetaData mdb) 128 { 129 boolean beanVerified = false; 130 131 if (!verifyBean(mdb)) 132 return; 133 134 beanVerified = verifyMessageDrivenBean(mdb); 135 136 if (beanVerified) 137 { 138 fireBeanVerifiedEvent(mdb); 140 } 141 } 142 143 private void checkBmpOrCmp2Entity(EntityMetaData entity) 144 { 145 boolean localOrRemoteExists = false; 146 boolean verified = false; 147 148 if (!verifyBean(entity)) 149 return; 150 151 if (entity.isCMP()) 152 { 153 verified = verifyCMPEntityBean(entity); 154 } 155 else if (entity.isBMP()) 156 { 157 verified = verifyBMPEntityBean(entity); 158 } 159 160 if (hasRemoteInterfaces(entity)) 161 { 162 localOrRemoteExists = true; 164 verified = verified && verifyEntityRemote(entity); 165 verified = verified && verifyEntityHome(entity); 166 } 167 168 if (hasLocalInterfaces(entity)) 169 { 170 localOrRemoteExists = true; 172 verified = verified && verifyEntityLocal(entity); 173 verified = verified && verifyEntityLocalHome(entity); 174 } 175 176 verified = verified && verifyPrimaryKey(entity); 177 178 if (!localOrRemoteExists) 179 { 180 if (entity.isCMP()) 187 { 188 fireSpecViolationEvent(entity, new Section("10.6.1")); 189 verified = false; 190 } 191 else 192 { 193 fireSpecViolationEvent(entity, new Section("12.2.1")); 194 verified = false; 195 } 196 } 197 198 if (verified) 199 { 200 fireBeanVerifiedEvent(entity); 201 } 202 } 203 204 210 protected boolean verifyBean(BeanMetaData theBean) 211 { 212 String beanName = theBean.getEjbClass(); 213 214 if (beanName == null) 215 return false; 216 217 try 218 { 219 bean = classloader.loadClass(beanName); 220 return true; 221 } 222 catch (ClassNotFoundException cnfe) 223 { 224 fireSpecViolationEvent(theBean, new Section("22.2.b", 225 "Class not found on '" + beanName + "': " + cnfe.getMessage())); 226 return false; 227 } 228 } 229 230 236 protected boolean hasRemoteInterfaces(BeanMetaData bean) 237 { 238 boolean status = true; 239 String homeName = bean.getHome(); 240 String remoteName = bean.getRemote(); 241 242 if (homeName == null || remoteName == null) 243 return false; 244 245 try 247 { 248 home = classloader.loadClass(homeName); 249 } 250 catch (ClassNotFoundException cnfe) 251 { 252 fireSpecViolationEvent(bean, new Section("22.2.c", 253 "Class not found on '" + homeName + "': " + cnfe.getMessage())); 254 status = false; 255 } 256 257 try 259 { 260 remote = classloader.loadClass(remoteName); 261 } 262 catch (ClassNotFoundException cnfe) 263 { 264 fireSpecViolationEvent(bean, new Section("22.2.d", 265 "Class not found on '" + remoteName + "': " + cnfe.getMessage())); 266 status = false; 267 } 268 269 return status; 270 } 271 272 278 protected boolean hasLocalInterfaces(BeanMetaData bean) 279 { 280 boolean status = true; 281 String localHomeName = bean.getLocalHome(); 282 String localName = bean.getLocal(); 283 284 if (localHomeName == null || localName == null) 285 return false; 286 287 try 289 { 290 localHome = classloader.loadClass(localHomeName); 291 } 292 catch (ClassNotFoundException cnfe) 293 { 294 fireSpecViolationEvent(bean, new Section("22.2.e", 295 "Class not found on '" + localHomeName + "': " + 296 cnfe.getMessage())); 297 status = false; 298 } 299 300 try 301 { 302 local = classloader.loadClass(localName); 303 } 304 catch (ClassNotFoundException cnfe) 305 { 306 fireSpecViolationEvent(bean, new Section("22.2.f", 307 "Class not found on '" + localName + "': " + cnfe.getMessage())); 308 status = false; 309 } 310 311 return status; 312 } 313 314 320 protected boolean verifySessionHome(SessionMetaData session) 321 { 322 boolean status = true; 323 324 if (session.isStateless()) 335 { 336 if (!hasDefaultCreateMethod(home)) 337 { 338 fireSpecViolationEvent(session, new Section("7.10.6.d2")); 339 status = false; 340 } 341 else 342 { 343 Method create = getDefaultCreateMethod(home); 344 345 if (hasMoreThanOneCreateMethods(home)) 346 { 347 fireSpecViolationEvent(session, new Section("7.10.6.d2")); 348 status = false; 349 } 350 } 351 } 352 353 if (!hasEJBHomeInterface(home)) 359 { 360 fireSpecViolationEvent(session, new Section("7.10.6.a")); 361 status = false; 362 } 363 364 Iterator it = Arrays.asList(home.getMethods()).iterator(); 376 while (it.hasNext()) 377 { 378 Method method = (Method )it.next(); 379 380 if (!hasLegalRMIIIOPArguments(method)) 381 { 382 fireSpecViolationEvent(session, method, new Section("7.10.6.b1")); 383 status = false; 384 } 385 386 if (!hasLegalRMIIIOPReturnType(method)) 387 { 388 fireSpecViolationEvent(session, method, new Section("7.10.6.b2")); 389 status = false; 390 } 391 392 if (!throwsRemoteException(method)) 393 { 394 fireSpecViolationEvent(session, method, new Section("7.10.6.b3")); 395 status = false; 396 } 397 } 398 399 if (!hasCreateMethod(home)) 405 { 406 fireSpecViolationEvent(session, new Section("7.10.6.d1")); 407 status = false; 408 } 409 410 Iterator createMethods = getCreateMethods(home); 431 while (createMethods.hasNext()) 432 { 433 Method create = (Method )createMethods.next(); 434 435 if (!hasMatchingEJBCreate(bean, create)) 436 { 437 fireSpecViolationEvent(session, create, new Section("7.10.6.e")); 438 status = false; 439 } 440 441 if (!hasRemoteReturnType(session, create)) 442 { 443 fireSpecViolationEvent(session, create, new Section("7.10.6.f")); 444 status = false; 445 } 446 447 if (hasMatchingEJBCreate(bean, create)) 448 { 449 Method ejbCreate = getMatchingEJBCreate(bean, create); 450 if (!hasMatchingExceptions(ejbCreate, create)) 451 { 452 fireSpecViolationEvent(session, create, 453 new Section("7.10.6.g")); 454 status = false; 455 } 456 } 457 458 if (!throwsCreateException(create)) 459 { 460 fireSpecViolationEvent(session, create, new Section("7.10.6.h")); 461 status = false; 462 } 463 } 464 465 return status; 466 } 467 468 474 protected boolean verifySessionLocalHome(SessionMetaData session) 475 { 476 boolean status = true; 477 478 if (session.isStateless()) 486 { 487 if (!hasDefaultCreateMethod(localHome)) 488 { 489 fireSpecViolationEvent(session, new Section("7.10.8.d2")); 490 status = false; 491 } 492 else 493 { 494 Method create = getDefaultCreateMethod(localHome); 495 496 if (hasMoreThanOneCreateMethods(localHome)) 497 { 498 fireSpecViolationEvent(session, new Section("7.10.8.d2")); 499 status = false; 500 } 501 } 502 } 503 504 if (!hasEJBLocalHomeInterface(localHome)) 510 { 511 fireSpecViolationEvent(session, new Section("7.10.8.a")); 512 status = false; 513 } 514 515 Iterator it = Arrays.asList(localHome.getMethods()).iterator(); 521 while (it.hasNext()) 522 { 523 Method method = (Method )it.next(); 524 525 if (throwsRemoteException(method)) 526 { 527 fireSpecViolationEvent(session, method, new Section("7.10.8.b")); 528 status = false; 529 } 530 } 531 532 if (!hasCreateMethod(localHome)) 538 { 539 fireSpecViolationEvent(session, new Section("7.10.8.d1")); 540 status = false; 541 } 542 543 Iterator createMethods = getCreateMethods(localHome); 564 while (createMethods.hasNext()) 565 { 566 Method create = (Method )createMethods.next(); 567 568 if (!hasMatchingEJBCreate(bean, create)) 569 { 570 fireSpecViolationEvent(session, create, 571 new Section("7.10.8.e")); 572 status = false; 573 } 574 575 if (!hasLocalReturnType(session, create)) 576 { 577 fireSpecViolationEvent(session, create, 578 new Section("7.10.8.f")); 579 status = false; 580 } 581 582 if (hasMatchingEJBCreate(bean, create)) 583 { 584 Method ejbCreate = getMatchingEJBCreate(bean, create); 585 if (!hasMatchingExceptions(ejbCreate, create)) 586 { 587 fireSpecViolationEvent(session, create, 588 new Section("7.10.8.g")); 589 } 590 } 591 592 if (!throwsCreateException(create)) 593 { 594 fireSpecViolationEvent(session, create, 595 new Section("7.10.8.h")); 596 status = false; 597 } 598 } 599 600 return status; 601 } 602 603 606 protected boolean verifySessionRemote(SessionMetaData session) 607 { 608 boolean status = true; 609 610 if (!hasEJBObjectInterface(remote)) 616 { 617 fireSpecViolationEvent(session, new Section("7.10.5.a")); 618 status = false; 619 } 620 621 Iterator it = Arrays.asList(remote.getMethods()).iterator(); 633 while (it.hasNext()) 634 { 635 Method method = (Method )it.next(); 636 637 if (!hasLegalRMIIIOPArguments(method)) 638 { 639 fireSpecViolationEvent(session, method, new Section("7.10.5.b1")); 640 status = false; 641 } 642 643 if (!hasLegalRMIIIOPReturnType(method)) 644 { 645 fireSpecViolationEvent(session, method, new Section("7.10.5.b2")); 646 status = false; 647 } 648 649 if (!throwsRemoteException(method)) 650 { 651 fireSpecViolationEvent(session, method, new Section("7.10.5.b3")); 652 status = false; 653 } 654 } 655 656 it = Arrays.asList(remote.getDeclaredMethods()).iterator(); 670 while (it.hasNext()) 671 { 672 Method remoteMethod = (Method )it.next(); 673 674 if (!hasMatchingMethod(bean, remoteMethod)) 675 { 676 fireSpecViolationEvent(session, remoteMethod, 677 new Section("7.10.5.d1")); 678 679 status = false; 680 } 681 682 if (hasMatchingMethod(bean, remoteMethod)) 683 { 684 try 685 { 686 Method beanMethod = bean.getMethod(remoteMethod.getName(), 687 remoteMethod.getParameterTypes()); 688 689 if (!hasMatchingReturnType(remoteMethod, beanMethod)) 690 { 691 fireSpecViolationEvent(session, remoteMethod, 692 new Section("7.10.5.d2")); 693 status = false; 694 } 695 696 if (!hasMatchingExceptions(beanMethod, remoteMethod)) 697 { 698 fireSpecViolationEvent(session, remoteMethod, 699 new Section("7.10.5.d3")); 700 status = false; 701 } 702 } 703 catch (NoSuchMethodException ignored) 704 { 705 } 706 } 707 } 708 709 return status; 710 } 711 712 715 protected boolean verifySessionLocal(SessionMetaData session) 716 { 717 boolean status = true; 718 719 if (!hasEJBLocalObjectInterface(local)) 725 { 726 fireSpecViolationEvent(session, new Section("7.10.7.a")); 727 status = false; 728 } 729 730 Iterator it = Arrays.asList(local.getMethods()).iterator(); 736 while (it.hasNext()) 737 { 738 Method method = (Method )it.next(); 739 if (throwsRemoteException(method)) 740 { 741 fireSpecViolationEvent(session, method, new Section("7.10.7.b")); 742 status = false; 743 } 744 } 745 746 it = Arrays.asList(local.getDeclaredMethods()).iterator(); 760 while (it.hasNext()) 761 { 762 Method localMethod = (Method )it.next(); 763 764 if (!hasMatchingMethod(bean, localMethod)) 765 { 766 fireSpecViolationEvent(session, localMethod, 767 new Section("7.10.7.d1")); 768 status = false; 769 } 770 771 if (hasMatchingMethod(bean, localMethod)) 772 { 773 try 774 { 775 Method beanMethod = bean.getMethod(localMethod.getName(), 776 localMethod.getParameterTypes()); 777 778 if (!hasMatchingReturnType(localMethod, beanMethod)) 779 { 780 fireSpecViolationEvent(session, localMethod, 781 new Section("7.10.7.d2")); 782 status = false; 783 } 784 785 if (!hasMatchingExceptions(beanMethod, localMethod)) 786 { 787 fireSpecViolationEvent(session, localMethod, 788 new Section("7.10.7.d3")); 789 status = false; 790 } 791 } 792 catch (NoSuchMethodException ignored) 793 { 794 } 795 } 796 } 797 798 return status; 799 } 800 801 804 protected boolean verifySessionBean(SessionMetaData session) 805 { 806 boolean status = true; 807 808 if (!hasSessionBeanInterface(bean)) 814 { 815 fireSpecViolationEvent(session, new Section("7.10.2.a")); 816 status = false; 817 } 818 819 if (hasSessionSynchronizationInterface(bean)) 829 { 830 if (session.isStateless()) 831 { 832 fireSpecViolationEvent(session, new Section("7.5.3.a")); 833 status = false; 834 } 835 836 if (session.isBeanManagedTx()) 837 { 838 fireSpecViolationEvent(session, new Section("7.5.3.b")); 839 status = false; 840 } 841 } 842 843 if (!hasEJBCreateMethod(bean, true)) 849 { 850 fireSpecViolationEvent(session, new Section("7.10.3")); 851 status = false; 852 } 853 854 if (hasSessionSynchronizationInterface(bean) 860 && session.isBeanManagedTx()) 861 { 862 fireSpecViolationEvent(session, new Section("7.6.1")); 863 status = false; 864 } 865 866 if (!isPublic(bean)) 871 { 872 fireSpecViolationEvent(session, new Section("7.10.2.b1")); 873 status = false; 874 } 875 876 if (isFinal(bean)) 881 { 882 fireSpecViolationEvent(session, new Section("7.10.2.b2")); 883 status = false; 884 } 885 886 if (isAbstract(bean)) 891 { 892 fireSpecViolationEvent(session, new Section("7.10.2.b3")); 893 status = false; 894 } 895 896 if (!hasDefaultConstructor(bean)) 902 { 903 fireSpecViolationEvent(session, new Section("7.10.2.c")); 904 status = false; 905 } 906 907 if (hasFinalizer(bean)) 912 { 913 fireSpecViolationEvent(session, new Section("7.10.2.d")); 914 status = false; 915 } 916 917 if (hasEJBCreateMethod(bean, true)) 930 { 931 Iterator it = getEJBCreateMethods(bean); 932 while (it.hasNext()) 933 { 934 Method ejbCreate = (Method )it.next(); 935 936 if (!isPublic(ejbCreate)) 937 { 938 fireSpecViolationEvent(session, ejbCreate, 939 new Section("7.10.3.b")); 940 status = false; 941 } 942 943 if ((isFinal(ejbCreate)) || (isStatic(ejbCreate))) 944 { 945 fireSpecViolationEvent(session, ejbCreate, 946 new Section("7.10.3.c")); 947 status = false; 948 } 949 950 if (!hasVoidReturnType(ejbCreate)) 951 { 952 fireSpecViolationEvent(session, ejbCreate, 953 new Section("7.10.3.d")); 954 status = false; 955 } 956 957 if (!hasLegalRMIIIOPArguments(ejbCreate)) 958 { 959 fireSpecViolationEvent(session, ejbCreate, 960 new Section("7.10.3.e")); 961 status = false; 962 } 963 } 964 } 965 966 return status; 967 } 968 969 972 private boolean verifyEntityHome(EntityMetaData entity) 973 { 974 boolean status = true; 975 976 if (!hasEJBHomeInterface(home)) 982 { 983 fireSpecViolationEvent(entity, new Section("12.2.9.a")); 984 status = false; 985 } 986 987 Iterator methods = Arrays.asList(home.getMethods()).iterator(); 999 while (methods.hasNext()) 1000 { 1001 Method method = (Method )methods.next(); 1002 1003 if (!hasLegalRMIIIOPArguments(method)) 1004 { 1005 fireSpecViolationEvent(entity, method, 1006 new Section("12.2.9.b1")); 1007 status = false; 1008 } 1009 1010 if (!hasLegalRMIIIOPReturnType(method)) 1011 { 1012 fireSpecViolationEvent(entity, method, 1013 new Section("12.2.9.b2")); 1014 status = false; 1015 } 1016 1017 if (!throwsRemoteException(method)) 1018 { 1019 fireSpecViolationEvent(entity, method, 1020 new Section("12.2.9.b3")); 1021 status = false; 1022 } 1023 } 1024 1025 methods = Arrays.asList(home.getMethods()).iterator(); 1035 while (methods.hasNext()) 1036 { 1037 Method method = (Method )methods.next(); 1038 1039 if (method.getDeclaringClass().getName().equals(EJB_HOME_INTERFACE)) 1041 continue; 1042 1043 if (isCreateMethod(method)) 1044 { 1045 if (!hasMatchingEJBCreate(bean, method)) 1067 { 1068 fireSpecViolationEvent(entity, method, new Section("12.2.9.d")); 1069 status = false; 1070 } 1071 1072 if (!hasRemoteReturnType(entity, method)) 1073 { 1074 fireSpecViolationEvent(entity, method, new Section("12.2.9.e")); 1075 status = false; 1076 } 1077 1078 if (hasMatchingEJBCreate(bean, method) 1079 && hasMatchingEJBPostCreate(bean, method)) 1080 { 1081 Method ejbCreate = getMatchingEJBCreate(bean, method); 1082 Method ejbPostCreate = getMatchingEJBPostCreate(bean, method); 1083 1084 if (!(hasMatchingExceptions(ejbCreate, method) 1085 && hasMatchingExceptions(ejbPostCreate, method))) 1086 { 1087 fireSpecViolationEvent(entity, method, 1088 new Section("12.2.9.f")); 1089 } 1090 } 1091 1092 if (!throwsCreateException(method)) 1093 { 1094 fireSpecViolationEvent(entity, method, new Section("12.2.9.g")); 1095 status = false; 1096 } 1097 } 1098 else if (isFinderMethod(method)) 1099 { 1100 if (entity.isBMP()) 1122 { if ((!hasMatchingEJBFind(bean, method))) 1124 { 1125 fireSpecViolationEvent(entity, method, 1126 new Section("12.2.9.h")); 1127 status = false; 1128 } 1129 1130 if (!(hasRemoteReturnType(entity, method) 1131 || isMultiObjectFinder(method))) 1132 { 1133 fireSpecViolationEvent(entity, method, 1134 new Section("12.2.9.j")); 1135 status = false; 1136 } 1137 1138 if ((hasMatchingEJBFind(bean, method))) 1139 { 1140 Method ejbFind = getMatchingEJBFind(bean, method); 1141 if (!(hasMatchingExceptions(ejbFind, method))) 1142 { 1143 fireSpecViolationEvent(entity, method, 1144 new Section("12.2.9.k")); 1145 status = false; 1146 } 1147 } 1148 1149 if (!throwsFinderException(method)) 1150 { 1151 fireSpecViolationEvent(entity, method, 1152 new Section("12.2.9.l")); 1153 status = false; 1154 } 1155 } 1157 if (entity.isCMP()) 1158 { 1159 1160 if (!(hasRemoteReturnType(entity, method) 1161 || isMultiObjectFinder(method))) 1162 { 1163 fireSpecViolationEvent(entity, method, 1164 new Section("10.6.10.a")); 1165 status = false; 1166 } 1167 1168 if (!throwsFinderException(method)) 1169 { 1170 fireSpecViolationEvent(entity, method, 1171 new Section("10.6.10.b")); 1172 status = false; 1173 } 1174 1175 if (!method.getName().equals("findByPrimaryKey") 1182 && !method.getName().equals("findAll") 1183 && !hasMatchingQuery(method, entity)) 1184 { 1185 fireSpecViolationEvent(entity, method, 1186 new Section("10.5.6")); 1187 status = false; 1188 } 1189 } } 1191 else { 1193 if (!hasMatchingEJBHome(bean, method)) 1203 { 1204 fireSpecViolationEvent(entity, method, 1205 new Section("12.2.9.m")); 1206 status = false; 1207 } 1208 } 1209 } 1211 1212 return status; 1213 } 1214 1215 1218 private boolean verifyEntityLocalHome(EntityMetaData entity) 1219 { 1220 boolean status = true; 1221 1222 if (!hasEJBLocalHomeInterface(localHome)) 1228 { 1229 fireSpecViolationEvent(entity, new Section("12.2.11.a")); 1230 status = false; 1231 } 1232 1233 Iterator homeMethods = Arrays.asList(localHome.getMethods()).iterator(); 1239 while (homeMethods.hasNext()) 1240 { 1241 Method method = (Method )homeMethods.next(); 1242 1243 if (throwsRemoteException(method)) 1244 { 1245 fireSpecViolationEvent(entity, method, new Section("12.2.11.b")); 1246 status = false; 1247 } 1248 } 1249 1250 homeMethods = Arrays.asList(localHome.getMethods()).iterator(); 1260 while (homeMethods.hasNext()) 1261 { 1262 Method method = (Method )homeMethods.next(); 1263 1264 if (method.getDeclaringClass().getName().equals(EJB_LOCAL_HOME_INTERFACE)) 1266 continue; 1267 1268 if (isCreateMethod(method)) 1269 { 1270 if (!hasMatchingEJBCreate(bean, method)) 1292 { 1293 fireSpecViolationEvent(entity, method, 1294 new Section("12.2.11.e")); 1295 status = false; 1296 } 1297 1298 if (!hasLocalReturnType(entity, method)) 1299 { 1300 fireSpecViolationEvent(entity, method, 1301 new Section("12.2.11.f")); 1302 status = false; 1303 } 1304 1305 if (hasMatchingEJBCreate(bean, method) 1306 && hasMatchingEJBPostCreate(bean, method)) 1307 { 1308 Method ejbCreate = getMatchingEJBCreate(bean, method); 1309 Method ejbPostCreate = getMatchingEJBPostCreate(bean, method); 1310 1311 if (!(hasMatchingExceptions(ejbCreate, method) 1312 && hasMatchingExceptions(ejbPostCreate, method))) 1313 { 1314 fireSpecViolationEvent(entity, method, 1315 new Section("12.2.11.g")); 1316 } 1317 } 1318 1319 if (!throwsCreateException(method)) 1320 { 1321 fireSpecViolationEvent(entity, method, 1322 new Section("12.2.11.h")); 1323 status = false; 1324 } 1325 } 1326 else if (isFinderMethod(method)) 1327 { 1328 if (!(hasLocalReturnType(entity, method) 1349 || isMultiObjectFinder(method))) 1350 { 1351 fireSpecViolationEvent(entity, method, 1352 new Section("12.2.11.j")); 1353 status = false; 1354 } 1355 1356 if (!throwsFinderException(method)) 1357 { 1358 fireSpecViolationEvent(entity, method, 1359 new Section("12.2.11.k")); 1360 status = false; 1361 } 1362 1363 if (entity.isCMP()) 1364 { 1365 if (hasMatchingEJBFind(bean, method)) 1372 { 1373 fireSpecViolationEvent(entity, method, 1374 new Section("10.6.2.j")); 1375 status = false; 1376 } 1377 1378 if (!method.getName().equals("findByPrimaryKey") 1387 && !method.getName().equals("findAll") 1388 && !hasMatchingQuery(method, entity)) 1389 { 1390 fireSpecViolationEvent(entity, method, 1391 new Section("10.5.6")); 1392 status = false; 1393 } 1394 } 1395 1396 if (entity.isBMP()) 1397 { 1398 if (!hasMatchingEJBFind(bean, method)) 1399 { 1400 fireSpecViolationEvent(entity, method, 1401 new Section("12.2.11.i")); 1402 status = false; 1403 } 1404 else 1405 { 1406 Method ejbFind = getMatchingEJBFind(bean, method); 1407 1408 if (!(hasMatchingExceptions(ejbFind, method))) 1409 { 1410 fireSpecViolationEvent(entity, method, 1411 new Section("12.2.11.l")); 1412 } 1413 } 1414 } 1415 } 1416 else 1417 { 1418 if (!hasMatchingEJBHome(bean, method)) 1428 { 1429 fireSpecViolationEvent(entity, method, 1430 new Section("12.2.11.m")); 1431 status = false; 1432 } 1433 } 1434 } 1436 return status; 1437 } 1438 1439 1442 private boolean verifyEntityLocal(EntityMetaData entity) 1443 { 1444 boolean status = true; 1445 1446 if (!hasEJBLocalObjectInterface(local)) 1452 { 1453 fireSpecViolationEvent(entity, new Section("12.2.10.a")); 1454 status = false; 1455 } 1456 1457 Iterator localMethods = Arrays.asList(local.getMethods()).iterator(); 1463 while (localMethods.hasNext()) 1464 { 1465 Method method = (Method )localMethods.next(); 1466 1467 if (throwsRemoteException(method)) 1468 { 1469 fireSpecViolationEvent(entity, method, new Section("12.2.10.b")); 1470 status = false; 1471 } 1472 } 1473 1474 localMethods = Arrays.asList(local.getMethods()).iterator(); 1489 while (localMethods.hasNext()) 1490 { 1491 Method method = (Method )localMethods.next(); 1492 1493 if (method.getDeclaringClass().getName().equals(EJB_LOCAL_OBJECT_INTERFACE)) 1496 continue; 1497 1498 if (!hasMatchingMethod(bean, method)) 1499 { 1500 fireSpecViolationEvent(entity, method, new Section("12.2.10.c")); 1501 status = false; 1502 } 1503 1504 if (hasMatchingMethod(bean, method)) 1505 { 1506 try 1507 { 1508 Method beanMethod = bean.getMethod(method.getName(), 1509 method.getParameterTypes()); 1510 1511 if (!hasMatchingReturnType(beanMethod, method)) 1512 { 1513 fireSpecViolationEvent(entity, method, 1514 new Section("12.2.10.d")); 1515 status = false; 1516 } 1517 1518 if (!hasMatchingExceptions(beanMethod, method)) 1519 { 1520 fireSpecViolationEvent(entity, method, 1521 new Section("12.2.10.e")); 1522 1523 status = false; 1524 } 1525 } 1526 catch (NoSuchMethodException ignored) 1527 { 1528 } 1529 } 1530 } 1531 1532 return status; 1533 } 1534 1535 1538 private boolean verifyEntityRemote(EntityMetaData entity) 1539 { 1540 boolean status = true; 1541 1542 if (!hasEJBObjectInterface(remote)) 1548 { 1549 fireSpecViolationEvent(entity, new Section("9.2.7.a")); 1550 status = false; 1551 } 1552 1553 Iterator it = Arrays.asList(remote.getMethods()).iterator(); 1565 while (it.hasNext()) 1566 { 1567 Method method = (Method )it.next(); 1568 1569 if (!hasLegalRMIIIOPArguments(method)) 1570 { 1571 fireSpecViolationEvent(entity, method, new Section("9.2.7.b")); 1572 status = false; 1573 } 1574 1575 if (!hasLegalRMIIIOPReturnType(method)) 1576 { 1577 fireSpecViolationEvent(entity, method, new Section("9.2.7.c")); 1578 status = false; 1579 } 1580 1581 if (!hasLegalRMIIIOPExceptionTypes(method)) 1582 { 1583 fireSpecViolationEvent(entity, method, new Section("9.2.7.h")); 1584 status = false; 1585 } 1586 1587 if (!throwsRemoteException(method)) 1588 { 1589 fireSpecViolationEvent(entity, method, new Section("9.2.7.d")); 1590 status = false; 1591 } 1592 } 1593 1594 it = Arrays.asList(remote.getMethods()).iterator(); 1609 while (it.hasNext()) 1610 { 1611 Method method = (Method )it.next(); 1612 1613 if (method.getDeclaringClass().getName().equals(EJB_OBJECT_INTERFACE)) 1615 continue; 1616 1617 if (!hasMatchingMethod(bean, method)) 1618 { 1619 fireSpecViolationEvent(entity, method, new Section("9.2.7.e")); 1620 status = false; 1621 } 1622 1623 if (hasMatchingMethod(bean, method)) 1624 { 1625 try 1626 { 1627 Method beanMethod = bean.getMethod(method.getName(), 1628 method.getParameterTypes()); 1629 1630 if (!hasMatchingReturnType(beanMethod, method)) 1631 { 1632 fireSpecViolationEvent(entity, method, 1633 new Section("9.2.7.f")); 1634 status = false; 1635 } 1636 1637 if (!hasMatchingExceptions(beanMethod, method)) 1638 { 1639 fireSpecViolationEvent(entity, method, 1640 new Section("9.2.7.g")); 1641 status = false; 1642 } 1643 } 1644 catch (NoSuchMethodException ignored) 1645 { 1646 } 1647 } 1648 } 1649 1650 return status; 1651 } 1652 1653 1656 private boolean verifyCMPEntityBean(EntityMetaData entity) 1657 { 1658 boolean status = true; 1659 1660 if (!hasEntityBeanInterface(bean)) 1666 { 1667 fireSpecViolationEvent(entity, new Section("10.6.2.a")); 1668 status = false; 1669 } 1670 1671 if (!isPublic(bean) || !isAbstract(bean)) 1676 { 1677 fireSpecViolationEvent(entity, new Section("10.6.2.b")); 1678 status = false; 1679 } 1680 1681 if (!hasDefaultConstructor(bean)) 1687 { 1688 fireSpecViolationEvent(entity, new Section("10.6.2.c")); 1689 status = false; 1690 } 1691 1692 if (hasFinalizer(bean)) 1697 { 1698 fireSpecViolationEvent(entity, new Section("10.6.2.d")); 1699 status = false; 1700 } 1701 1702 if (hasEJBCreateMethod(bean, false)) 1716 { 1717 Iterator it = getEJBCreateMethods(bean); 1718 while (it.hasNext()) 1719 { 1720 Method ejbCreate = (Method )it.next(); 1721 if (!isPublic(ejbCreate)) 1722 { 1723 fireSpecViolationEvent(entity, ejbCreate, 1724 new Section("10.6.4.b")); 1725 status = false; 1726 } 1727 1728 if ((isFinal(ejbCreate)) || (isStatic(ejbCreate))) 1729 { 1730 fireSpecViolationEvent(entity, ejbCreate, 1731 new Section("10.6.4.c")); 1732 status = false; 1733 } 1734 1735 if (!hasPrimaryKeyReturnType(entity, ejbCreate)) 1736 { 1737 fireSpecViolationEvent(entity, ejbCreate, 1738 new Section("10.6.4.d")); 1739 status = false; 1740 } 1741 1742 1755 1756 if (!throwsCreateException(ejbCreate)) 1757 { 1758 fireSpecViolationEvent(entity, ejbCreate, 1759 new Section("10.6.4.g")); 1760 status = false; 1761 } 1762 } 1763 } 1764 1765 if (hasEJBCreateMethod(bean, false)) 1779 { 1780 Iterator it = getEJBCreateMethods(bean); 1781 1782 while (it.hasNext()) 1783 { 1784 Method ejbCreate = (Method )it.next(); 1785 1786 if (!hasMatchingEJBPostCreate(bean, ejbCreate)) 1787 { 1788 fireSpecViolationEvent(entity, ejbCreate, 1789 new Section("10.6.5.a")); 1790 status = false; 1791 } 1792 1793 if (hasMatchingEJBPostCreate(bean, ejbCreate)) 1794 { 1795 Method ejbPostCreate = getMatchingEJBPostCreate(bean, 1796 ejbCreate); 1797 1798 if (!isPublic(ejbPostCreate)) 1799 { 1800 fireSpecViolationEvent(entity, ejbPostCreate, 1801 new Section("10.6.5.b")); 1802 status = false; 1803 } 1804 1805 if (isStatic(ejbPostCreate)) 1806 { 1807 fireSpecViolationEvent(entity, ejbPostCreate, 1808 new Section("10.6.5.c")); 1809 status = false; 1810 } 1811 1812 if (isFinal(ejbPostCreate)) 1813 { 1814 fireSpecViolationEvent(entity, ejbPostCreate, 1815 new Section("10.6.5.d")); 1816 status = false; 1817 } 1818 1819 if (!hasVoidReturnType(ejbPostCreate)) 1820 { 1821 fireSpecViolationEvent(entity, ejbPostCreate, 1822 new Section("10.6.5.e")); 1823 status = false; 1824 } 1825 } 1826 } 1827 } 1828 1829 Iterator it = getEjbHomeMethods(bean); 1839 while (it.hasNext()) 1840 { 1841 Method ejbHome = (Method )it.next(); 1842 if (!isPublic(ejbHome)) 1843 { 1844 fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.a")); 1845 status = false; 1846 } 1847 1848 if (isStatic(ejbHome)) 1849 { 1850 fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.b")); 1851 status = false; 1852 } 1853 1854 if (throwsRemoteException(ejbHome)) 1855 { 1856 fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.c")); 1857 status = false; 1858 } 1859 } 1860 1861 it = entity.getCMPFields(); 1867 while (it.hasNext()) 1868 { 1869 String fieldName = (String )it.next(); 1870 String getName = "get" + fieldName.substring(0, 1).toUpperCase() + 1871 fieldName.substring(1); 1872 Class fieldType = null; 1873 1874 try 1875 { 1876 Method m = bean.getMethod(getName, new Class [0]); 1877 fieldType = m.getReturnType(); 1878 1879 if (fieldType == Void.TYPE) 1882 { 1883 fireSpecViolationEvent(entity, 1884 new Section("jb.7.1.b", "Field: " + fieldName)); 1885 } 1886 } 1887 catch (NoSuchMethodException nsme) 1888 { 1889 fireSpecViolationEvent(entity, 1890 new Section("10.6.2.g", "Field: " + fieldName)); 1891 status = false; 1892 } 1893 1894 String setName = "set" + fieldName.substring(0, 1).toUpperCase() + 1895 fieldName.substring(1); 1896 Class [] args = new Class [1]; 1897 args[0] = fieldType; 1898 1899 try 1900 { 1901 Method m = bean.getMethod(setName, args); 1902 fieldType = m.getReturnType(); 1903 1904 if (fieldType != Void.TYPE) 1907 { 1908 fireSpecViolationEvent(entity, 1909 new Section("jb.7.1.a", "Field: " + fieldName)); 1910 } 1911 } 1912 catch (NoSuchMethodException nsme) 1913 { 1914 try 1919 { 1920 args[0] = classloader.loadClass("java.util.Collection"); 1921 Method m = bean.getMethod(setName, args); 1922 } 1923 catch (NoSuchMethodException nsme2) 1924 { 1925 fireSpecViolationEvent(entity, 1926 new Section("10.6.2.h", "Field: " + fieldName)); 1927 status = false; 1928 } 1929 catch (ClassNotFoundException cnfe) 1930 { 1931 } 1933 } 1934 } 1935 1936 it = getEjbSelectMethods(bean); 1946 while (it.hasNext()) 1947 { 1948 Method ejbSelect = (Method )it.next(); 1949 1950 if (!isPublic(ejbSelect)) 1951 { 1952 fireSpecViolationEvent(entity, ejbSelect, new Section("10.6.7.a")); 1953 status = false; 1954 } 1955 1956 if (!isAbstract(ejbSelect)) 1957 { 1958 fireSpecViolationEvent(entity, ejbSelect, new Section("10.6.7.b")); 1959 status = false; 1960 } 1961 1962 if (!throwsFinderException(ejbSelect)) 1963 { 1964 fireSpecViolationEvent(entity, ejbSelect, new Section("10.6.7.c")); 1965 status = false; 1966 } 1967 1968 if (!hasMatchingQuery(ejbSelect, entity)) 1969 { 1970 fireSpecViolationEvent(entity, ejbSelect, new Section("10.5.7")); 1971 status = false; 1972 } 1973 } 1974 1975 if (hasFinderMethod(bean)) 1980 { 1981 fireSpecViolationEvent(entity, new Section("10.6.2.i")); 1982 status = false; 1983 } 1984 1985 return status; 1986 } 1987 1988 1991 private boolean verifyBMPEntityBean(EntityMetaData entity) 1992 { 1993 boolean status = true; 1994 1995 if (!hasEntityBeanInterface(bean)) 2001 { 2002 fireSpecViolationEvent(entity, new Section("12.2.2.a")); 2003 status = false; 2004 } 2005 2006 if (!isPublic(bean) || isAbstract(bean)) 2011 { 2012 fireSpecViolationEvent(entity, new Section("12.2.2.b")); 2013 status = false; 2014 } 2015 2016 if (isFinal(bean)) 2021 { 2022 fireSpecViolationEvent(entity, new Section("12.2.2.c")); 2023 status = false; 2024 } 2025 2026 if (!hasDefaultConstructor(bean)) 2032 { 2033 fireSpecViolationEvent(entity, new Section("12.2.2.d")); 2034 status = false; 2035 } 2036 2037 if (hasFinalizer(bean)) 2042 { 2043 fireSpecViolationEvent(entity, new Section("12.2.2.e")); 2044 status = false; 2045 } 2046 2047 if (hasEJBCreateMethod(bean, false)) 2060 { 2061 Iterator it = getEJBCreateMethods(bean); 2062 while (it.hasNext()) 2063 { 2064 Method ejbCreate = (Method )it.next(); 2065 if (!isPublic(ejbCreate)) 2066 { 2067 fireSpecViolationEvent(entity, ejbCreate, 2068 new Section("12.2.3.a")); 2069 status = false; 2070 } 2071 2072 if ((isFinal(ejbCreate)) || (isStatic(ejbCreate))) 2073 { 2074 fireSpecViolationEvent(entity, ejbCreate, 2075 new Section("12.2.3.b")); 2076 status = false; 2077 } 2078 2079 if (!hasPrimaryKeyReturnType(entity, ejbCreate)) 2080 { 2081 fireSpecViolationEvent(entity, ejbCreate, 2082 new Section("12.2.3.c")); 2083 status = false; 2084 } 2085 2086 2098 } 2099 } 2100 2101 if (hasEJBCreateMethod(bean, false)) 2115 { 2116 Iterator it = getEJBCreateMethods(bean); 2117 while (it.hasNext()) 2118 { 2119 Method ejbCreate = (Method )it.next(); 2120 2121 if (!hasMatchingEJBPostCreate(bean, ejbCreate)) 2122 { 2123 fireSpecViolationEvent(entity, ejbCreate, 2124 new Section("12.2.4.a")); 2125 status = false; 2126 } 2127 2128 if (hasMatchingEJBPostCreate(bean, ejbCreate)) 2129 { 2130 Method ejbPostCreate = getMatchingEJBPostCreate(bean, 2131 ejbCreate); 2132 2133 if (!isPublic(ejbPostCreate)) 2134 { 2135 fireSpecViolationEvent(entity, ejbPostCreate, 2136 new Section("12.2.4.b")); 2137 status = false; 2138 } 2139 2140 if (isStatic(ejbPostCreate) || isFinal(ejbPostCreate)) 2141 { 2142 fireSpecViolationEvent(entity, ejbPostCreate, 2143 new Section("12.2.4.c")); 2144 status = false; 2145 } 2146 2147 if (!hasVoidReturnType(ejbPostCreate)) 2148 { 2149 fireSpecViolationEvent(entity, ejbPostCreate, 2150 new Section("12.2.4.d")); 2151 status = false; 2152 } 2153 } 2154 } 2155 } 2156 2157 if (!hasEJBFindByPrimaryKey(bean)) 2167 { 2168 fireSpecViolationEvent(entity, new Section("12.2.5.e")); 2169 status = false; 2170 } 2171 2172 if (hasEJBFindByPrimaryKey(bean)) 2173 { 2174 Method ejbFindByPrimaryKey = getEJBFindByPrimaryKey(bean); 2175 2176 if (!hasPrimaryKeyReturnType(entity, ejbFindByPrimaryKey)) 2177 { 2178 fireSpecViolationEvent(entity, ejbFindByPrimaryKey, 2179 new Section("12.2.5.e1")); 2180 status = false; 2181 } 2182 2183 if (!isSingleObjectFinder(entity, ejbFindByPrimaryKey)) 2184 { 2185 fireSpecViolationEvent(entity, ejbFindByPrimaryKey, 2186 new Section("12.2.5.e2")); 2187 status = false; 2188 } 2189 } 2190 2191 if (hasFinderMethod(bean)) 2207 { 2208 Iterator it = getEJBFindMethods(bean); 2209 while (it.hasNext()) 2210 { 2211 Method finder = (Method )it.next(); 2212 2213 if (!isPublic(finder)) 2214 { 2215 fireSpecViolationEvent(entity, finder, new Section("12.2.5.a")); 2216 status = false; 2217 } 2218 2219 if (isFinal(finder) || isStatic(finder)) 2220 { 2221 fireSpecViolationEvent(entity, finder, new Section("12.2.5.b")); 2222 status = false; 2223 } 2224 2225 2233 2234 if (!(isSingleObjectFinder(entity, finder) 2235 || isMultiObjectFinder(finder))) 2236 { 2237 fireSpecViolationEvent(entity, finder, new Section("12.2.5.d")); 2238 status = false; 2239 } 2240 } 2241 } 2242 2243 Iterator it = getEjbHomeMethods(bean); 2253 while (it.hasNext()) 2254 { 2255 Method ejbHome = (Method )it.next(); 2256 2257 if (!isPublic(ejbHome)) 2258 { 2259 fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.a")); 2260 status = false; 2261 } 2262 2263 if (isStatic(ejbHome)) 2264 { 2265 fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.b")); 2266 status = false; 2267 } 2268 2269 if (throwsRemoteException(ejbHome)) 2270 { 2271 fireSpecViolationEvent(entity, ejbHome, new Section("10.6.6.c")); 2272 status = false; 2273 } 2274 } 2275 2276 return status; 2277 } 2278 2279 2282 private boolean verifyPrimaryKey(EntityMetaData entity) 2283 { 2284 boolean status = true; 2285 boolean cmp = entity.isCMP(); 2286 2287 if (entity.getPrimaryKeyClass() == null 2288 || entity.getPrimaryKeyClass().length() == 0) 2289 { 2290 if (cmp) 2291 fireSpecViolationEvent(entity, new Section("10.6.1.a")); 2292 else 2293 fireSpecViolationEvent(entity, new Section("12.2.1.a")); 2294 2295 return false; 2297 } 2298 2299 Class cls = null; 2305 try 2306 { 2307 cls = classloader.loadClass(entity.getPrimaryKeyClass()); 2308 } 2309 catch (ClassNotFoundException e) 2310 { 2311 if (cmp) 2312 fireSpecViolationEvent(entity, new Section("10.6.13.a")); 2313 else 2314 fireSpecViolationEvent(entity, new Section("12.2.12.a")); 2315 2316 return false; 2318 } 2319 2320 if (!isRMIIDLValueType(cls)) 2325 { 2326 if (cmp) 2327 fireSpecViolationEvent(entity, new Section("10.6.13.b")); 2328 else 2329 fireSpecViolationEvent(entity, new Section("12.2.12.b")); 2330 status = false; 2331 } 2332 2333 if (entity.getPrimKeyField() == null || 2335 entity.getPrimKeyField().length() == 0) 2336 { 2337 if (!cls.getName().equals("java.lang.Object")) 2342 { 2343 Object one, two; 2344 2345 try 2346 { 2347 one = cls.newInstance(); 2348 two = cls.newInstance(); 2349 try 2350 { 2351 if (!one.equals(two)) 2352 { 2353 if (cmp) 2354 { 2355 log.warn("Default instances of primary key: " + cls 2357 + " do not equate, check your equals method"); 2358 } 2359 else 2360 { 2361 log.warn("Default instances of primary key: " + cls 2363 + " do not equate, check your equals method"); 2364 } 2365 status = true; 2366 } 2367 } 2368 catch (NullPointerException e) 2369 { 2370 } 2373 2374 try 2375 { 2376 if (one.hashCode() != two.hashCode()) 2377 { 2378 if (cmp) 2379 { 2380 log.warn("Default instances of primary key: " + cls 2382 + " do not have the same hash, check your hashCode method"); 2383 } 2384 else 2385 { 2386 log.warn("Default instances of primary key: " + cls 2388 + " do not have the same hash, check your hashCode method"); 2389 } 2390 status = true; 2391 } 2392 } 2393 catch (NullPointerException e) 2394 { 2395 } 2397 } 2398 catch (IllegalAccessException e) 2399 { 2400 if (cmp) 2404 { 2405 fireSpecViolationEvent(entity, new Section("10.8.2.a")); 2406 status = false; 2407 } 2408 } 2409 catch (InstantiationException e) 2410 { 2411 } 2415 } 2416 } 2417 else 2418 { 2419 if (entity.isBMP()) 2423 { 2424 fireSpecViolationEvent(entity, new Section("dd.a")); 2425 status = false; 2426 } 2427 2428 boolean found = false; 2434 Iterator it = entity.getCMPFields(); 2435 while (it.hasNext()) 2436 { 2437 String fieldName = (String )it.next(); 2438 if (fieldName.equals(entity.getPrimKeyField())) 2439 { 2440 found = true; 2441 break; 2442 } 2443 } 2444 2445 if (!found) 2446 { 2447 status = false; 2448 fireSpecViolationEvent(entity, new Section("10.8.1.b")); 2449 } 2450 2451 try 2452 { 2453 String pkField = entity.getPrimKeyField(); 2461 String methodName = "get" + 2462 pkField.substring(0, 1).toUpperCase() + pkField.substring(1); 2463 2464 Method method = bean.getMethod(methodName, new Class [0]); 2465 if (!entity.getPrimaryKeyClass().equals(method.getReturnType().getName()) 2466 ) 2467 { 2468 status = false; 2469 fireSpecViolationEvent(entity, new Section("10.8.1.a")); 2470 } 2471 2472 } 2473 catch (NoSuchMethodException e) 2474 { 2475 status = false; 2481 fireSpecViolationEvent(entity, new Section("10.8.1.b")); 2482 } 2483 } 2484 2485 return status; 2486 } 2487 2488 2491 protected boolean verifyMessageDrivenBean(MessageDrivenMetaData mdBean) 2492 { 2493 boolean status = true; 2494 2495 if (!hasMessageDrivenBeanInterface(bean)) 2501 { 2502 fireSpecViolationEvent(mdBean, new Section("15.7.2.a")); 2503 status = false; 2504 } 2505 2506 if (!hasMessageListenerInterface(bean)) 2512 { 2513 fireSpecViolationEvent(mdBean, new Section("15.7.2.b")); 2514 status = false; 2515 } 2516 2517 if (!isPublic(bean)) 2522 { 2523 fireSpecViolationEvent(mdBean, new Section("15.7.2.c1")); 2524 status = false; 2525 } 2526 2527 if (isFinal(bean)) 2532 { 2533 fireSpecViolationEvent(mdBean, new Section("15.7.2.c2")); 2534 status = false; 2535 } 2536 2537 if (isAbstract(bean)) 2542 { 2543 fireSpecViolationEvent(mdBean, new Section("15.7.2.c3")); 2544 status = false; 2545 } 2546 2547 if (!hasDefaultConstructor(bean)) 2553 { 2554 fireSpecViolationEvent(mdBean, new Section("15.7.2.d")); 2555 status = false; 2556 } 2557 2558 if (hasFinalizer(bean)) 2563 { 2564 fireSpecViolationEvent(mdBean, new Section("15.7.2.e")); 2565 status = false; 2566 } 2567 2568 if (hasEJBCreateMethod(bean, false)) 2581 { 2582 Iterator it = getEJBCreateMethods(bean); 2583 Method ejbCreate = (Method )it.next(); 2584 2585 if (!isPublic(ejbCreate)) 2586 { 2587 fireSpecViolationEvent(mdBean, ejbCreate, new Section("15.7.3.b")); 2588 status = false; 2589 } 2590 2591 if ((isFinal(ejbCreate)) || (isStatic(ejbCreate))) 2592 { 2593 fireSpecViolationEvent(mdBean, ejbCreate, new Section("15.7.3.c")); 2594 status = false; 2595 } 2596 2597 if (!hasVoidReturnType(ejbCreate)) 2598 { 2599 fireSpecViolationEvent(mdBean, ejbCreate, new Section("15.7.3.d")); 2600 status = false; 2601 } 2602 2603 if (!hasNoArguments(ejbCreate)) 2604 { 2605 fireSpecViolationEvent(mdBean, ejbCreate, new Section("15.7.3.e")); 2606 status = false; 2607 } 2608 2609 if (!throwsNoException(ejbCreate)) 2610 { 2611 fireSpecViolationEvent(mdBean, ejbCreate, new Section("15.7.3.f")); 2612 status = false; 2613 } 2614 2615 if (it.hasNext()) 2616 { 2617 fireSpecViolationEvent(mdBean, new Section("15.7.3.a")); 2618 status = false; 2619 } 2620 } 2621 else 2622 { 2623 fireSpecViolationEvent(mdBean, new Section("15.7.3.a")); 2624 status = false; 2625 } 2626 2627 if (hasOnMessageMethod(bean)) 2641 { 2642 Iterator it = getOnMessageMethods(bean); 2643 Method onMessage = (Method )it.next(); 2644 2645 if (!isPublic(onMessage)) 2646 { 2647 fireSpecViolationEvent(mdBean, onMessage, new Section("15.7.4.b")); 2648 status = false; 2649 } 2650 2651 if ((isFinal(onMessage)) || (isStatic(onMessage))) 2652 { 2653 fireSpecViolationEvent(mdBean, onMessage, new Section("15.7.4.c")); 2654 status = false; 2655 } 2656 2657 try 2658 { 2659 Class message = classloader.loadClass("javax.jms.Message"); 2660 if (!hasSingleArgument(onMessage, message)) 2661 { 2662 fireSpecViolationEvent(mdBean, onMessage, 2663 new Section("15.7.4.e")); 2664 status = false; 2665 } 2666 2667 if (!throwsNoException(onMessage)) 2668 { 2669 fireSpecViolationEvent(mdBean, onMessage, 2670 new Section("15.7.4.f")); 2671 status = false; 2672 } 2673 2674 if (it.hasNext()) 2675 { 2676 fireSpecViolationEvent(mdBean, new Section("15.7.4.a")); 2677 status = false; 2678 } 2679 } 2680 catch (ClassNotFoundException cnfe) 2681 { 2682 } 2684 } 2685 else 2686 { 2687 fireSpecViolationEvent(mdBean, new Section("15.7.4.a")); 2688 status = false; 2689 } 2690 2691 if (hasEJBRemoveMethod(bean)) 2704 { 2705 Iterator it = getEJBRemoveMethods(bean); 2706 Method ejbRemove = (Method )it.next(); 2707 2708 if (!isPublic(ejbRemove)) 2709 { 2710 fireSpecViolationEvent(mdBean, ejbRemove, new Section("15.7.5.b")); 2711 status = false; 2712 } 2713 2714 if ((isFinal(ejbRemove)) || (isStatic(ejbRemove))) 2715 { 2716 fireSpecViolationEvent(mdBean, ejbRemove, new Section("15.7.5.c")); 2717 status = false; 2718 } 2719 2720 if (!hasVoidReturnType(ejbRemove)) 2721 { 2722 fireSpecViolationEvent(mdBean, ejbRemove, new Section("15.7.5.d")); 2723 status = false; 2724 } 2725 2726 if (!hasNoArguments(ejbRemove)) 2727 { 2728 fireSpecViolationEvent(mdBean, ejbRemove, new Section("15.7.5.e")); 2729 status = false; 2730 } 2731 2732 if (!throwsNoException(ejbRemove)) 2733 { 2734 fireSpecViolationEvent(mdBean, ejbRemove, new Section("15.7.5.f")); 2735 status = false; 2736 } 2737 2738 if (it.hasNext()) 2739 { 2740 fireSpecViolationEvent(mdBean, new Section("15.7.5.a")); 2741 status = false; 2742 } 2743 } 2744 else 2745 { 2746 fireSpecViolationEvent(mdBean, new Section("15.7.5.a")); 2747 status = false; 2748 } 2749 2750 return status; 2751 } 2752 2753} 2754 2755 2758 | Popular Tags |