public com.sun.enterprise.tools.verifier.Result | check(com.sun.enterprise.deployment.EjbDescriptor descriptor)The Bean Provider should not declare the session bean fields in the session
bean class as transient.
This is to allow the Container to swap out an instance's state through
techniques other than the Java Serialization protocol. For example, the
Container's Java Virtual Machine implementation may use a block of memory
to keep the instance's variables, and the Container swaps the whole memory
block to the disk instead of performing Java Serialization on the instance.
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (descriptor instanceof EjbSessionDescriptor) {
try {
Class c = Class.forName(((EjbSessionDescriptor)descriptor).getEjbClassName(), false, getVerifierContext().getClassLoader());
// fields should not be defined in the session bean class as transient.
Field [] fields = c.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
int modifiers = fields[i].getModifiers();
if (!Modifier.isTransient(modifiers)) {
continue;
} else {
addWarningDetails(result, compName);
result.warning(smh.getLocalString
(getClass().getName() + ".warning",
"Warning: Field [ {0} ] defined within session bean class [ {1} ] is defined as transient. Session bean fields should not be defined in the session bean class as transient.",
new Object[] {fields[i].getName(),((EjbSessionDescriptor)descriptor).getEjbClassName()}));
}
}
} catch (ClassNotFoundException e) {
Verifier.debug(e);
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".failedException",
"Error: [ {0} ] class not found.",
new Object[] {((EjbSessionDescriptor)descriptor).getEjbClassName()}));
} catch (Throwable t) {
addWarningDetails(result, compName);
result.warning(smh.getLocalString
(getClass().getName() + ".warningException",
"Warning: [ {0} ] class encountered [ {1} ]. " +
"Cannot access fields of class [ {2} ] which is external to [ {3} ].",
new Object[] {(descriptor).getEjbClassName(),t.toString(),
t.getMessage(),
descriptor.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri()}));
}
return result;
}
if(result.getStatus()!=Result.WARNING){
addGoodDetails(result, compName);
result.passed(smh.getLocalString
(getClass().getName() + ".passed",
"The session bean class has defined all fields " +
"as non-transient fields."));
}
return result;
|