Enterprise Java Bean class modifiers test. The class must not be defined
as abstract.
Result result = getInitializedResult();
boolean shouldBeAbstract = false;
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (descriptor instanceof EjbEntityDescriptor) {
String persistentType = ((EjbEntityDescriptor)descriptor).getPersistenceType();
if (EjbEntityDescriptor.CONTAINER_PERSISTENCE.equals(persistentType)) {
if (EjbCMPEntityDescriptor.CMP_1_1!=((EjbCMPEntityDescriptor) descriptor).getCMPVersion()) {
shouldBeAbstract = true;
}
}
}
Class c = loadEjbClass(descriptor, result);
if (c!=null) {
boolean isAbstract = false;
int modifiers = c.getModifiers();
if (Modifier.isAbstract(modifiers)) {
isAbstract = true;
}
if (!isAbstract && !shouldBeAbstract) {
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.passed(smh.getLocalString
(getClass().getName() + ".passed",
"[ {0} ] properly declares non-abstract class modifier.",
new Object[] {descriptor.getEjbClassName()}));
}
if (isAbstract && shouldBeAbstract) {
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.passed(smh.getLocalString
(getClass().getName() + ".passed2",
"[ {0} ] properly declares abstract class modifier.",
new Object[] {descriptor.getEjbClassName()}));
}
if (isAbstract && !shouldBeAbstract ) {
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.failed(smh.getLocalString
(getClass().getName() + ".failed",
"Error: Ejb Class [ {0} ] was found, but was declared as abstract. The class [ {1} ] must not be abstract.",
new Object[] {descriptor.getEjbClassName(),descriptor.getEjbClassName()}));
}
if (!isAbstract && shouldBeAbstract ) {
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.failed(smh.getLocalString
(getClass().getName() + ".failed2",
"Error: CMP 2.0 Entity Bean Class [ {0} ] was found, but was declared as non abstract. The class [ {1} ] must be abstract.",
new Object[] {descriptor.getEjbClassName(),descriptor.getEjbClassName()}));
}
}
return result;