| Method from org.jboss.verifier.strategy.AbstractVerifier Detail: |
public void checkMessageBean(MessageDrivenMetaData bean) {
}
Provides an empty default implementation for EJB 1.1 verifier (message
beans are for EJB 2.0 and greater only). |
protected final void fireBeanVerifiedEvent(BeanMetaData bean) {
fireBeanVerifiedEvent(bean, null);
}
|
protected final void fireBeanVerifiedEvent(BeanMetaData bean,
String msg) {
VerificationEvent event = factory.createBeanVerifiedEvent(context);
event.setName(bean.getEjbName());
if (msg != null)
{
event.setMessage(msg);
}
context.fireBeanChecked(event);
}
|
protected void fireSpecViolationEvent(BeanMetaData bean,
Section section) {
fireSpecViolationEvent(bean, null /* method */, section);
}
|
protected void fireSpecViolationEvent(BeanMetaData bean,
Method method,
Section section) {
VerificationEvent event = factory.createSpecViolationEvent(context,
section);
event.setName(bean.getEjbName());
event.setMethod(method);
context.fireSpecViolation(event);
}
|
public VerificationContext getContext() {
return context;
}
Returns the context object reference for this strategy implementation. |
public Iterator getCreateMethods(Class c) {
List creates = new LinkedList();
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (isCreateMethod(method[i]))
creates.add(method[i]);
}
return creates.iterator();
}
Return all create methods of a class |
public Method getDefaultCreateMethod(Class c) {
Method method = null;
try
{
method = c.getMethod(CREATE_METHOD, null);
}
catch (NoSuchMethodException ignored)
{
}
return method;
}
|
public Iterator getEJBCreateMethods(Class c) {
List ejbCreates = new LinkedList();
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (isEjbCreateMethod(method[i]))
ejbCreates.add(method[i]);
}
return ejbCreates.iterator();
}
Returns the ejbCreate(...) methods of a bean |
public Method getEJBFindByPrimaryKey(Class c) {
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (method[i].getName().equals(EJB_FIND_BY_PRIMARY_KEY))
return method[i];
}
return null;
}
Returns the ejbFindByPrimaryKey method |
public Iterator getEJBFindMethods(Class c) {
List finders = new LinkedList();
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (method[i].getName().startsWith("ejbFind"))
finders.add(method[i]);
}
return finders.iterator();
}
returns the ejbFind methods of a bean |
public Iterator getFinderMethods(Class home) {
List finders = new LinkedList();
Method[] method = home.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (method[i].getName().startsWith("find"))
finders.add(method[i]);
}
return finders.iterator();
}
returns the finder methods of a home interface |
public Method getMatchingEJBCreate(Class bean,
Method create) {
try
{
return bean.getMethod(getMatchingEJBCreateName(create.getName()), create.getParameterTypes());
}
catch (NoSuchMethodException e)
{
return null;
}
}
|
public Method getMatchingEJBFind(Class bean,
Method finder) {
try
{
String methodName = "ejbF" + finder.getName().substring(1);
return bean.getMethod(methodName, finder.getParameterTypes());
}
catch (NoSuchMethodException e)
{
return null;
}
}
|
public Method getMatchingEJBPostCreate(Class bean,
Method create) {
try
{
return bean.getMethod(getMatchingEJBPostCreateName(create.getName()), create.getParameterTypes());
}
catch (NoSuchMethodException e)
{
return null;
}
}
|
abstract public String getMessageBundle()
|
public Iterator getOnMessageMethods(Class c) {
List onMessages = new LinkedList();
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (isOnMessageMethod(method[i]))
onMessages.add(method[i]);
}
return onMessages.iterator();
}
Returns the onMessage(...) method of a bean |
public boolean hasANonStaticField(Class c) {
try
{
Field list[] = c.getFields();
for (int i = 0; i < list.length; i++)
{
if (!Modifier.isStatic(list[i].getModifiers()))
return true;
}
}
catch (Exception ignored)
{
}
return false;
}
Checks for at least one non-static field. |
public boolean hasCreateMethod(Class c) {
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (isCreateMethod(method[i]))
return true;
}
return false;
}
Searches for an instance of a public create method from the class |
public boolean hasDefaultConstructor(Class c) {
try
{
Constructor ctr = c.getConstructor(new Class[0]);
}
catch (NoSuchMethodException e)
{
if( log.isTraceEnabled() )
{
StringBuffer tmp = new StringBuffer("hasDefaultConstructor(");
tmp.append(") failure, ");
Classes.displayClassInfo(c, tmp);
log.trace(tmp.toString(), e);
}
return false;
}
return true;
}
Checks if a class has a default (no args) constructor |
public boolean hasDefaultCreateMethod(Class home) {
Method[] method = home.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (isCreateMethod(method[i]))
{
Class[] params = method[i].getParameterTypes();
if (params.length == 0)
return true;
}
}
return false;
}
Searches the class or interface, and its superclass or superinterface
for a create() method that takes no arguments |
public boolean hasEJBCreateMethod(Class c,
boolean isSession) {
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (isEjbCreateMethod(method[i]))
{
if (!isStatic(method[i]) && !isFinal(method[i])
&& ((isSession && hasVoidReturnType(method[i]))
|| (!isSession))
)
{
return true;
}
}
}
return false;
}
Searches for an instance of a public ejbCreate method from the class |
public boolean hasEJBFindByPrimaryKey(Class c) {
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (method[i].getName().equals(EJB_FIND_BY_PRIMARY_KEY))
return true;
}
return false;
}
checks if the class has an ejbFindByPrimaryKey method |
public boolean hasEJBHomeInterface(Class c) {
return isAssignableFrom("javax.ejb.EJBHome", c);
}
Finds javax.ejb.EJBHome interface from the class or its
superclasses |
public boolean hasEJBLocalHomeInterface(Class c) {
return isAssignableFrom("javax.ejb.EJBLocalHome", c);
}
Finds javax.ejb.EJBLocalHome interface from the class or its
superclasses |
public boolean hasEJBLocalObjectInterface(Class c) {
return isAssignableFrom("javax.ejb.EJBLocalObject", c);
}
Finds java.ejb.EJBLocalObject interface from the class |
public boolean hasEJBObjectInterface(Class c) {
return isAssignableFrom("javax.ejb.EJBObject", c);
}
Finds java.ejb.EJBObject interface from the class |
public boolean hasEntityBeanInterface(Class c) {
return isAssignableFrom("javax.ejb.EntityBean", c);
}
Finds java.ejb.EntityBean interface from the class |
public boolean hasFinalizer(Class c) {
try
{
Method finalizer = c.getDeclaredMethod(FINALIZE_METHOD, new Class[0]);
}
catch (NoSuchMethodException e)
{
return false;
}
return true;
}
Checks of the class defines a finalize() method |
public boolean hasFinderMethod(Class c) {
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (method[i].getName().startsWith("ejbFind"))
return true;
}
return false;
}
check if a class has one or more finder methods |
public boolean hasLegalRMIIIOPArguments(Method method) {
Class[] params = method.getParameterTypes();
for (int i = 0; i < params.length; ++i)
{
if (!isRMIIIOPType(params[i]))
return false;
}
return true;
}
|
public boolean hasLegalRMIIIOPExceptionTypes(Method method) {
/*
* All checked exception classes used in method declarations
* (other than java.rmi.RemoteException) MUST be conforming
* RMI/IDL exception types.
*
* Spec 28.2.3 (4)
*/
Iterator it = Arrays.asList(method.getExceptionTypes()).iterator();
while (it.hasNext())
{
Class exception = (Class)it.next();
if (!isRMIIDLExceptionType(exception))
return false;
}
return true;
}
|
public boolean hasLegalRMIIIOPReturnType(Method method) {
return isRMIIIOPType(method.getReturnType());
}
|
public boolean hasLocalReturnType(BeanMetaData bean,
Method m) {
try
{
Class clazz = classloader.loadClass(bean.getLocal());
return m.getReturnType().isAssignableFrom(clazz);
}
catch (Exception e)
{
// e.printStackTrace();
return false;
}
}
checks the return type of method matches the bean's local interface |
public boolean hasMatchingEJBCreate(Class bean,
Method create) {
try
{
return (bean.getMethod(getMatchingEJBCreateName(create.getName()), create.getParameterTypes()) != null);
}
catch (NoSuchMethodException e)
{
if( log.isTraceEnabled() )
{
StringBuffer tmp = new StringBuffer("hasMatchingEJBCreate(");
tmp.append(create.toString());
tmp.append(") failure, ");
Classes.displayClassInfo(bean, tmp);
log.trace(tmp.toString(), e);
}
return false;
}
}
|
public boolean hasMatchingEJBFind(Class bean,
Method finder) {
try
{
String methodName = "ejbF" + finder.getName().substring(1);
return (bean.getMethod(methodName, finder.getParameterTypes()) != null);
}
catch (NoSuchMethodException e)
{
if( log.isTraceEnabled() )
{
StringBuffer tmp = new StringBuffer("hasMatchingEJBFind(");
tmp.append(finder.toString());
tmp.append(") failure, ");
Classes.displayClassInfo(bean, tmp);
log.trace(tmp.toString(), e);
}
return false;
}
}
|
public boolean hasMatchingEJBHome(Class bean,
Method home) {
try
{
return (bean.getMethod(getMatchingEJBHomeName(home.getName()), home.getParameterTypes()) != null);
}
catch (NoSuchMethodException e)
{
if( log.isTraceEnabled() )
{
StringBuffer tmp = new StringBuffer("hasMatchingEJBHome(");
tmp.append(home.toString());
tmp.append(") failure, ");
Classes.displayClassInfo(bean, tmp);
log.trace(tmp.toString(), e);
}
return false;
}
}
|
public boolean hasMatchingEJBPostCreate(Class bean,
Method create) {
try
{
return (bean.getMethod(getMatchingEJBPostCreateName(create.getName()),
create.getParameterTypes()) != null);
}
catch (NoSuchMethodException e)
{
if( log.isTraceEnabled() )
{
StringBuffer tmp = new StringBuffer("hasMatchingEJBPostCreate(");
tmp.append(create.toString());
tmp.append(") failure, ");
Classes.displayClassInfo(bean, tmp);
log.trace(tmp.toString(), e);
}
return false;
}
}
Check whether a bean has a matching ejbPostCreate methods for
a given ejbCreate method |
public boolean hasMatchingExceptions(Method source,
Method target) {
// target must be a superset of source
Class[] a = source.getExceptionTypes();
Class[] b = target.getExceptionTypes();
Class rteClass = null;
Class errorClass = null;
try
{
rteClass = classloader.loadClass("java.lang.RuntimeException");
errorClass = classloader.loadClass("java.lang.Error");
}
catch (ClassNotFoundException cnfe)
{
// Ignored, if this happens we have more serious problems :)
}
for (int i = 0; i < a.length; ++i)
{
if (rteClass.isAssignableFrom(a[i])
|| errorClass.isAssignableFrom(a[i]))
{
// Skip over subclasses of java.lang.RuntimeException and
// java.lang.Error
continue;
}
boolean found = false;
for (int j = 0; j < b.length; ++j)
{
if (b[j].isAssignableFrom(a[i]))
{
found = true;
break;
}
}
if (!found)
{
return false;
}
}
return true;
}
Check whether two given methods declare the same Exceptions |
public boolean hasMatchingMethod(Class bean,
Method method) {
try
{
bean.getMethod(method.getName(), method.getParameterTypes());
return true;
}
catch (NoSuchMethodException e)
{
if( log.isTraceEnabled() )
{
StringBuffer tmp = new StringBuffer("hasMatchingMethod(");
tmp.append(method.toString());
tmp.append(") failure, ");
Classes.displayClassInfo(bean, tmp);
log.trace(tmp.toString(), e);
}
return false;
}
}
Check if a class (or its superclasses) declare a given method |
public boolean hasMatchingReturnType(Method a,
Method b) {
return (a.getReturnType() == b.getReturnType());
}
Check whether two methods have the same return type |
public boolean hasMessageDrivenBeanInterface(Class c) {
return isAssignableFrom("javax.ejb.MessageDrivenBean", c);
}
Finds java.ejb.MessageDrivenBean interface from the class |
public boolean hasMessageListenerInterface(Class c) {
return isAssignableFrom("javax.jms.MessageListener", c);
}
Finds javax.jms.MessageListener interface from the class |
public boolean hasMoreThanOneCreateMethods(Class c) {
int count = 0;
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (isCreateMethod(method[i]))
{
++count;
}
}
return (count > 1);
}
Check whether a class has more than one create method |
public boolean hasNoArguments(Method method) {
Class[] params = method.getParameterTypes();
return (params.length == 0) ? true : false;
}
checks if the method accepts any parameters. |
public boolean hasOnMessageMethod(Class c) {
Method[] method = c.getMethods();
for (int i = 0; i < method.length; ++i)
{
if (isOnMessageMethod(method[i]))
return true;
}
return false;
}
Searches for an instance of a public onMessage method from the class |
public boolean hasPrimaryKeyReturnType(EntityMetaData entity,
Method m) {
try
{
return
m.getReturnType().isAssignableFrom(classloader.loadClass(entity.getPrimaryKeyClass()));
}
catch (ClassNotFoundException cnfe)
{
// Only check equality
return
m.getReturnType().getName().equals(entity.getPrimaryKeyClass());
}
}
checks the return type of method matches the entity's primary key
class or is a super class of the primary key class |
public boolean hasRemoteReturnType(BeanMetaData bean,
Method m) {
try
{
Class clazz = classloader.loadClass(bean.getRemote());
return m.getReturnType().isAssignableFrom(clazz);
}
catch (Exception e)
{
// e.printStackTrace();
return false;
}
}
checks the return type of method matches the bean's remote interface |
public boolean hasSessionBeanInterface(Class c) {
return isAssignableFrom("javax.ejb.SessionBean", c);
}
Finds java.ejb.SessionBean interface from the class |
public boolean hasSessionSynchronizationInterface(Class c) {
return isAssignableFrom("javax.ejb.SessionSynchronization", c);
}
Finds javax.ejb.SessionSynchronization interface from the class |
public boolean hasSingleArgument(Method method,
Class argClass) {
Class[] params = method.getParameterTypes();
if (params.length == 1)
{
if (params[0].equals(argClass))
return true;
}
return false;
}
checks if the method accepts a single parameter of a specified type. |
public boolean hasVoidReturnType(Method method) {
return (method.getReturnType() == Void.TYPE);
}
checks if a method has a void return type |
public boolean isAbstract(Class c) {
return (Modifier.isAbstract(c.getModifiers()));
}
checks if the given class is declared as abstract |
public boolean isAbstract(Method m) {
return (Modifier.isAbstract(m.getModifiers()));
}
checks if the given method is declared as abstract |
public boolean isAllFieldsPublic(Class c) {
try
{
Field list[] = c.getFields();
for (int i = 0; i < list.length; i++)
{
if (!Modifier.isPublic(list[i].getModifiers()))
return false;
}
}
catch (Exception e)
{
return false;
}
return true;
}
Checks whether all the fields in the class are declared as public. |
public boolean isAssignableFrom(String className,
Class assignableFromClass) {
try
{
Class clazz = this.classloader.loadClass(className);
return clazz.isAssignableFrom(assignableFromClass);
}
catch (ClassNotFoundException e)
{
log.warn("Failed to find class: " + className, e);
}
return false;
}
|
public boolean isAssignableFrom(Class clazz,
String assignableFromClassName) {
try
{
Class assignableFromClass = this.classloader.loadClass(assignableFromClassName);
return clazz.isAssignableFrom(assignableFromClass);
}
catch (ClassNotFoundException e)
{
log.warn("Failed to find class: " + assignableFromClassName, e);
}
return false;
}
|
abstract public boolean isCreateMethod(Method m)
|
abstract public boolean isEjbCreateMethod(Method m)
|
public boolean isFinal(Member member) {
return (Modifier.isFinal(member.getModifiers()));
}
checks if a class's member (method, constructor or field) has a
final modifier. |
public boolean isFinal(Class c) {
return (Modifier.isFinal(c.getModifiers()));
}
checks if the given class is declared as final |
public boolean isFinderMethod(Method m) {
return (m.getName().startsWith("find"));
}
Check if this is a finder method |
public boolean isMultiObjectFinder(Method f) {
return (java.util.Collection.class.isAssignableFrom(f.getReturnType())
|| java.util.Enumeration.class.isAssignableFrom(f.getReturnType()));
}
checks if finder method returns either Collection or Enumeration |
public boolean isOnMessageMethod(Method m) {
if ("onMessage".equals(m.getName()))
{
Class[] paramTypes = m.getParameterTypes();
if (paramTypes.length == 1)
{
if (Message.class.equals(paramTypes[0]))
return true;
}
}
return false;
}
Check if the given message is the onMessage() method |
public boolean isPublic(Member member) {
return (Modifier.isPublic(member.getModifiers()));
}
checks if a class's member (method, constructor or field) has a
public modifier. |
public boolean isPublic(Class c) {
return (Modifier.isPublic(c.getModifiers()));
}
checks if the given class is declared as public |
protected boolean isRMIIDLValueType(Class type) {
/*
* A value type MUST NOT either directly or indirectly implement the
* java.rmi.Remote interface.
*
* Spec 28.2.4 (4)
*/
if (java.rmi.Remote.class.isAssignableFrom(type))
return false;
/*
* If class is a non-static inner class then its containing class must
* also be a conforming RMI/IDL value type.
*
* Spec 28.2.4 (3)
*/
if (type.getDeclaringClass() != null && !isStatic(type))
{
if (!isRMIIDLValueType(type.getDeclaringClass()))
return false;
}
return true;
}
|
protected boolean isRMIIIOPType(Class type) {
/*
* Java Language to IDL Mapping
*
* ftp://ftp.omg.org/pub/docs/ptc/99-03-09.pdf
*
* A conforming RMI/IDL type is a Java type whose values may be
* transmitted across an RMI/IDL remote interface at run-time.
* A Java data type is a conforming RMI/IDL type if it is:
*
* - one of the Java primitive types (see Primitive Types on
* page 28-2).
* - a conforming remote interface (as defined in RMI/IDL
* Remote Interfaces on page 28-2).
* - a conforming value type (as defined in RMI/IDL Value Types
* on page 28-4).
* - an array of conforming RMI/IDL types (see RMI/IDL Arrays on
* page 28-5).
* - a conforming exception type (see RMI/IDL Exception Types on
* page 28-5).
* - a conforming CORBA object reference type (see CORBA Object
* Reference Types on page 28-6).
* - a conforming IDL entity type see IDL Entity Types on page
* 28-6).
*/
/*
* Primitive types.
*
* Spec 28.2.2
*/
if (type.isPrimitive())
return true;
/*
* Conforming array.
*
* Spec 28.2.5
*/
if (type.isArray())
return isRMIIIOPType(type.getComponentType());
/*
* Conforming CORBA reference type
*
* Spec 28.2.7
*/
if (org.omg.CORBA.Object.class.isAssignableFrom(type))
return true;
/*
* Conforming IDL Entity type
*
* Spec 28.2.8
*/
if (org.omg.CORBA.portable.IDLEntity.class.isAssignableFrom(type))
return true;
/*
* Conforming remote interface.
*
* Spec 28.2.3
*/
if (isRMIIDLRemoteInterface(type))
return true;
/*
* Conforming exception.
*
* Spec 28.2.6
*/
if (isRMIIDLExceptionType(type))
return true;
/*
* Conforming value type.
*
* Spec 28.2.4
*/
if (isRMIIDLValueType(type))
return true;
return false;
}
|
public boolean isSingleObjectFinder(EntityMetaData entity,
Method finder) {
return hasPrimaryKeyReturnType(entity, finder);
}
checks if finder returns the primary key type |
public boolean isStatic(Member member) {
return (Modifier.isStatic(member.getModifiers()));
}
checks if a class's member (method, constructor or field) has a
static modifier. |
public boolean isStatic(Class c) {
return (Modifier.isStatic(c.getModifiers()));
}
checks if the given class is declared as static (inner classes only) |
public boolean throwsCreateException(Method method) {
Class[] exception = method.getExceptionTypes();
for (int i = 0; i < exception.length; ++i)
{
if (isAssignableFrom("javax.ejb.CreateException", exception[i]))
return true;
}
return false;
}
checks if the method includes java.ejb.CreateException in its
throws clause. |
public boolean throwsFinderException(Method method) {
Class[] exception = method.getExceptionTypes();
for (int i = 0; i < exception.length; ++i)
{
if (isAssignableFrom("javax.ejb.FinderException", exception[i]))
return true;
}
return false;
}
checks if the methods includes javax.ejb.FinderException in its
throws clause. |
public boolean throwsNoException(Method method) {
boolean hasCheckedException = false;
Class[] exceptions = method.getExceptionTypes();
for (int e = 0; e < exceptions.length; e++)
{
Class ex = exceptions[e];
boolean isError = Error.class.isAssignableFrom(ex);
boolean isRuntimeException = RuntimeException.class.isAssignableFrom(ex);
boolean isRemoteException = RemoteException.class.isAssignableFrom(ex);
if (isError == false && isRuntimeException == false && isRemoteException == false)
hasCheckedException = true;
}
return hasCheckedException == false;
}
checks if the method throws no checked exceptions in its throws clause. |
public boolean throwsRemoteException(Method method) {
Class[] exception = method.getExceptionTypes();
for (int i = 0; i < exception.length; ++i)
{
// Fix for bug #607805: an IOException is OK for local interfaces
// Fix for bug #626430: java.lang.Exception is also OK
if (exception[i].equals(java.io.IOException.class)
|| exception[i].equals(java.lang.Exception.class))
{
continue;
}
// Not true see bug report #434739
// if (java.rmi.RemoteException.class.isAssignableFrom(exception[i]))
// According to the RMI spec. a remote interface must throw an RemoteException
// or any of its super classes therefore the check must be done vice versa
if (isAssignableFrom(exception[i], "java.rmi.RemoteException"))
{
return true;
}
}
return false;
}
Checks if the method includes java.rmi.RemoteException or its
subclass in its throws clause.
See bug report #434739 and #607805 |