FileDocCategorySizeDatePackage
BeanFieldsTransient.javaAPI DocGlassfish v2 API6593Fri May 04 22:34:06 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.session

BeanFieldsTransient

public class BeanFieldsTransient extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest implements com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck
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.

Fields Summary
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(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.

param
descriptor the Enterprise Java Bean deployment descriptor
return
Result the results for this assertion


        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;