Methods Summary |
---|
public static boolean | isFieldSubsetOfCMP(java.lang.reflect.Field field, java.util.Set CMPFields)The names of the fields in the primary key class must be a subset of the
names of the container-managed fields.
Verify the following:
The primary key class field must be a subset of the names of the
container-managed fields.
if (CMPFields.contains(new FieldDescriptor(field))) {
return true;
} else {
return false;
}
|
public static boolean | isPKFieldMatchingBeanFields(java.lang.reflect.Field field, java.util.Vector beanFields)The names of the fields in the primary key class must correspond to the
field names of the entity bean class that comprise the key.
Verify the following:
The primary key class field must correspond to the field names of the
entity bean class that comprise the key.
for (int i = 0; i < beanFields.size(); i++) {
if (((FieldDescriptor)beanFields.elementAt(i)).getName().equals(field.getName())) {
return true;
} else {
continue;
}
}
// if you made it here, then field[] didn't contain field
return false;
|
public static boolean | isValidApplicationException(java.lang.Class[] methodExceptions)Method application exception checked for compliance test.
Verify the following:
An application exception is an exception defined in the throws clause of
a method in the Bean's home interface, other than java.rmi.RemoteException.
An application exception must not be defined as a subclass of the
java.lang.RuntimeException, or of the java.rmi.RemoteException. These are
reserved for system exceptions.
The javax.ejb.CreateException, javax.ejb.RemoveException,
javax.ejb.FinderException, and subclasses thereof, are considered to be
application exceptions.
for (int kk = 0; kk < methodExceptions.length; ++kk) {
Class ex=methodExceptions[kk];
//check 0: app exception set is all exceptions minus java.rmi.RemoteException.
if (java.rmi.RemoteException.class != ex) {
//check 1: app exception must subclass java.lang.Exception
if (!java.lang.Exception.class.isAssignableFrom(ex)) return false;
//check 2: app exception must not subclass java.lang.RuntimeException or java.rmi.RemoteException
if(java.rmi.RemoteException.class.isAssignableFrom(ex) || java.lang.RuntimeException.class.isAssignableFrom(ex)) {
return false;
}
}
}
return true;
|
public static boolean | isValidCreateException(java.lang.Class[] methodExceptions)Method exception javax.ejb.CreateException checked for compliance
test.
Verify the following:
The home/remote interface methods exception types must be legal types for
CreateException.
This means that their exception must throw javax.ejb.CreateException.
// methods must throw javax.ejb.CreateException
boolean throwsCreateException = false;
for (int kk = 0; kk < methodExceptions.length; ++kk) {
if ((methodExceptions[kk].getName().equals("javax.ejb.CreateException")) ||
(methodExceptions[kk].getName().equals("CreateException"))) {
throwsCreateException = true;
break;
}
}
return throwsCreateException;
|
public static boolean | isValidFinderException(java.lang.Class[] methodExceptions)Method exception javax.ejb.FinderException checked for compliance
test.
Verify the following:
The home/remote interface methods exception types must be legal types for
FinderException
This means that their exception must throw javax.ejb.FinderException
// methods must throw javax.ejb.FinderException
boolean throwsFinderException = false;
for (int kk = 0; kk < methodExceptions.length; ++kk) {
if ((methodExceptions[kk].getName().equals("javax.ejb.FinderException")) ||
(methodExceptions[kk].getName().equals("FinderException"))) {
throwsFinderException = true;
break;
}
}
return throwsFinderException;
|
public static boolean | isValidObjectNotFoundExceptionException(java.lang.Class[] methodExceptions)Method exception javax.ejb.ObjectNotFoundException checked for compliance
test.
Verify the following:
The ObjectNotFoundException is a subclass of FinderException. It is
thrown by the ejbFind(...) methods to indicate that the
requested entity object does not exist.
Only single-object finders (see Subsection 9.1.8) may throw this
exception. Multi-object finders must not throw this exception.
// methods must throw javax.ejb.ObjectNotFoundException
boolean throwsObjectNotFoundException = false;
for (int kk = 0; kk < methodExceptions.length; ++kk) {
if ((methodExceptions[kk].getName().equals("javax.ejb.ObjectNotFoundException")) ||
(methodExceptions[kk].getName().equals("ObjectNotFoundException"))) {
throwsObjectNotFoundException = true;
break;
}
}
return throwsObjectNotFoundException;
|
public static boolean | isValidRemoteException(java.lang.Class[] methodExceptions)Method exception java.rmi.RemoteException checked for compliance
test.
Verify the following:
The home/remote interface methods exception types must be legal types for
RemoteException.
This means that their exception must throw java.rmi.RemoteException
// methods must throw java.rmi.RemoteException
boolean throwsRemoteException = false;
for (int kk = 0; kk < methodExceptions.length; ++kk) {
if ((methodExceptions[kk].getName().equals("java.rmi.RemoteException")) ||
(methodExceptions[kk].getName().equals("RemoteException"))) {
throwsRemoteException = true;
break;
}
}
return throwsRemoteException;
|
public static boolean | isValidSerializableType(java.lang.Class serClass)Class checked for implementing java.io.Serializable interface test.
Verify the following:
The class must implement the java.io.Serializable interface, either
directly or indirectly.
if (java.io.Serializable.class.isAssignableFrom(serClass))
return true;
else
return false;
/**
// This complex logic is replaced by the above simple logic
Class c = serClass;
boolean validInterface = false;
boolean badOne = false;
// The class must implement the java.io.Serializable interface, either
// directly or indirectly,
// walk up the class tree
if (c.getName().equals("java.io.Serializable")) {
validInterface = true;
return validInterface;
}
do {
Class[] interfaces = c.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
if (interfaces[i].getName().equals("java.io.Serializable")) {
validInterface = true;
break;
} else {
// walk up the class tree of the interface and see if it
// implements java.io.Serializable
Class superClass = interfaces[i];
do {
if (superClass.getName().equals("java.io.Serializable")) {
validInterface = true;
break;
}
} while ((((superClass=superClass.getSuperclass()) != null) && (!validInterface)));
}
}
} while ((((c=c.getSuperclass()) != null) && (!validInterface)));
if (validInterface) {
return true;
} else {
return false;
}
**/
|