//
// Spec 12.2.9
//
if (!hasEJBHomeInterface(home))
{
fireSpecViolationEvent(entity, new Section("12.2.9.a"));
status = false;
}
// The methods defined in the entity bean's home interface MUST
// have valid RMI-IIOP argument types.
//
// The methods defined in the entity bean's home interface MUST
// have valid RMI-IIOP return types.
//
// The methods defined in the entity bean's home interface MUST
// have java.rmi.RemoteException in their throws clause.
//
// Spec 12.2.9
//
Iterator methods = Arrays.asList(home.getMethods()).iterator();
while (methods.hasNext())
{
Method method = (Method)methods.next();
if (!hasLegalRMIIIOPArguments(method))
{
fireSpecViolationEvent(entity, method,
new Section("12.2.9.b1"));
status = false;
}
if (!hasLegalRMIIIOPReturnType(method))
{
fireSpecViolationEvent(entity, method,
new Section("12.2.9.b2"));
status = false;
}
if (!throwsRemoteException(method))
{
fireSpecViolationEvent(entity, method,
new Section("12.2.9.b3"));
status = false;
}
}
// Each method defined in the entity bean's home interface must be
// one of the following:
//
// - a create method
// - a finder method
// - a home method
//
// Spec 12.2.9
//
methods = Arrays.asList(home.getMethods()).iterator();
while (methods.hasNext())
{
Method method = (Method)methods.next();
// Do not check the methods of the javax.ejb.EJBHome interface
if (method.getDeclaringClass().getName().equals(EJB_HOME_INTERFACE))
continue;
if (isCreateMethod(method))
{
// Each create(...) method in the entity bean's home
// interface MUST have a matching ejbCreate(...) method in
// the entity bean's class.
//
// Each create(...) method in the entity bean's home
// interface MUST have the same number and types of
// arguments to its matching ejbCreate(...) method.
//
// The return type for a create(...) method MUST be the
// entity bean's remote interface type.
//
// All the exceptions defined in the throws clause of the
// matching ejbCreate(...) and ejbPostCreate(...) methods of
// the enterprise bean class MUST be included in the throws
// clause of a matching create(...) method.
//
// The throws clause of a create(...) method MUST include
// the javax.ejb.CreateException.
//
// Spec 12.2.9
//
if (!hasMatchingEJBCreate(bean, method))
{
fireSpecViolationEvent(entity, method, new Section("12.2.9.d"));
status = false;
}
if (!hasRemoteReturnType(entity, method))
{
fireSpecViolationEvent(entity, method, new Section("12.2.9.e"));
status = false;
}
if (hasMatchingEJBCreate(bean, method)
&& hasMatchingEJBPostCreate(bean, method))
{
Method ejbCreate = getMatchingEJBCreate(bean, method);
Method ejbPostCreate = getMatchingEJBPostCreate(bean, method);
if (!(hasMatchingExceptions(ejbCreate, method)
&& hasMatchingExceptions(ejbPostCreate, method)))
{
fireSpecViolationEvent(entity, method,
new Section("12.2.9.f"));
}
}
if (!throwsCreateException(method))
{
fireSpecViolationEvent(entity, method, new Section("12.2.9.g"));
status = false;
}
}
else if (isFinderMethod(method))
{
// Each finder method MUST match one of the ejbFind<METHOD>
// methods defined in the entity bean class.
//
// The matching ejbFind<METHOD> method MUST have the same
// number and types of arguments.
//
// The return type for a find<METHOD> method MUST be the
// entity bean's remote interface type (single-object
// finder) or a collection thereof (for a multi-object
// finder).
//
// All the exceptions defined in the throws clause of an
// ejbFind method of the entity bean class MUST be included
// in the throws clause of the matching find method of the
// home interface.
//
// The throws clause of a finder method MUST include the
// javax.ejb.FinderException.
//
// Spec 12.2.9
//
if (entity.isBMP())
{ // Check for BMP violations
if ((!hasMatchingEJBFind(bean, method)))
{
fireSpecViolationEvent(entity, method,
new Section("12.2.9.h"));
status = false;
}
if (!(hasRemoteReturnType(entity, method)
|| isMultiObjectFinder(method)))
{
fireSpecViolationEvent(entity, method,
new Section("12.2.9.j"));
status = false;
}
if ((hasMatchingEJBFind(bean, method)))
{
Method ejbFind = getMatchingEJBFind(bean, method);
if (!(hasMatchingExceptions(ejbFind, method)))
{
fireSpecViolationEvent(entity, method,
new Section("12.2.9.k"));
status = false;
}
}
if (!throwsFinderException(method))
{
fireSpecViolationEvent(entity, method,
new Section("12.2.9.l"));
status = false;
}
} // if( entity.isBMP() )
if (entity.isCMP())
{
if (!(hasRemoteReturnType(entity, method)
|| isMultiObjectFinder(method)))
{
fireSpecViolationEvent(entity, method,
new Section("10.6.10.a"));
status = false;
}
if (!throwsFinderException(method))
{
fireSpecViolationEvent(entity, method,
new Section("10.6.10.b"));
status = false;
}
// For every finder method there must be a matching
// <query> element defined in the deployment descriptor
// with the exception of findByPrimaryKey
//
// JBoss Extension: 'findAll' is _also_ ignored.
//
if (!method.getName().equals("findByPrimaryKey")
&& !method.getName().equals("findAll")
&& !hasMatchingQuery(method, entity))
{
fireSpecViolationEvent(entity, method,
new Section("10.5.6"));
status = false;
}
} // if( entity.isCMP() )
}
else // Neither Create nor Finder method
{
// Each home method MUST match a method defined in the
// entity bean class.
//
// The matching ejbHome<METHOD> method MUST have the same
// number and types of arguments, and a matching return
// type.
//
// Spec 12.2.9
//
if (!hasMatchingEJBHome(bean, method))
{
fireSpecViolationEvent(entity, method,
new Section("12.2.9.m"));
status = false;
}
}
} // while( methods.hasNext() )