*
* Spec 9.2.2
*/
if (!hasEntityBeanInterface(bean))
{
fireSpecViolationEvent(entity, new Section("9.2.2.a"));
status = false;
}
/*
* The entity bean class MUST be defined as public.
*
* Spec 9.2.2
*/
if (!isPublic(bean))
{
fireSpecViolationEvent(entity, new Section("9.2.2.b"));
status = false;
}
/*
* The entity bean class MUST NOT be defined as abstract.
*
* Spec 9.2.2
*/
if (isAbstract(bean))
{
fireSpecViolationEvent(entity, new Section("9.2.2.c"));
status = false;
}
/*
* The entity bean class MUST NOT be defined as final.
*
* Spec 9.2.2
*/
if (isFinal(bean))
{
fireSpecViolationEvent(entity, new Section("9.2.2.d"));
status = false;
}
/*
* The entity bean class MUST define a public constructor that
* takes no arguments
*
* Spec 9.2.2
*/
if (!hasDefaultConstructor(bean))
{
fireSpecViolationEvent(entity, new Section("9.2.2.e"));
status = false;
}
/*
* The entity bean class MUST NOT define the finalize() method.
*
* Spec 9.2.2
*/
if (hasFinalizer(bean))
{
fireSpecViolationEvent(entity, new Section("9.2.2.f"));
status = false;
}
/*
* The ejbCreate(...) method signatures MUST follow these rules:
*
* - The method MUST be declared as public
* - The method MUST NOT be declared as final or static
* - The return type MUST be the entity bean's primary key type
* - The method arguments MUST be legal types for RMI/IIOP
* - The method return value type MUST be legal type for RMI/IIOP
*
* Spec 9.2.3
*/
if (hasEJBCreateMethod(bean, false))
{
Iterator it = getEJBCreateMethods(bean);
while (it.hasNext())
{
Method ejbCreate = (Method)it.next();
if (!isPublic(ejbCreate))
{
fireSpecViolationEvent(entity, ejbCreate, new Section("9.2.3.a"));
status = false;
}
if ((isFinal(ejbCreate)) || (isStatic(ejbCreate)))
{
fireSpecViolationEvent(entity, ejbCreate, new Section("9.2.3.b"));
status = false;
}
if (!hasPrimaryKeyReturnType(entity, ejbCreate))
{
fireSpecViolationEvent(entity, ejbCreate, new Section("9.2.3.c"));
status = false;
}
if (!hasLegalRMIIIOPArguments(ejbCreate))
{
fireSpecViolationEvent(entity, ejbCreate, new Section("9.2.3.d"));
status = false;
}
if (!hasLegalRMIIIOPReturnType(ejbCreate))
{
fireSpecViolationEvent(entity, ejbCreate, new Section("9.2.3.e"));
status = false;
}
}
}
/*
* For each ejbCreate(...) method, the entity bean class MUST
* define a matching ejbPostCreate(...) method.
*
* The ejbPostCreate(...) method MUST follow these rules:
*
* - the method MUST be declared as public
* - the method MUST NOT be declared as final or static
* - the return type MUST be void
* - the method arguments MUST be the same as the matching
* ejbCreate(...) method
*
* Spec 9.2.4
*/
if (hasEJBCreateMethod(bean, false))
{
Iterator it = getEJBCreateMethods(bean);
while (it.hasNext())
{
Method ejbCreate = (Method)it.next();
if (!hasMatchingEJBPostCreate(bean, ejbCreate))
{
fireSpecViolationEvent(entity, ejbCreate, new Section("9.2.4.a"));
status = false;
}
if (hasMatchingEJBPostCreate(bean, ejbCreate))
{
Method ejbPostCreate = getMatchingEJBPostCreate(bean, ejbCreate);
if (!isPublic(ejbPostCreate))
{
fireSpecViolationEvent(entity, ejbPostCreate, new Section("9.2.4.b"));
status = false;
}
if (isStatic(ejbPostCreate))
{
fireSpecViolationEvent(entity, ejbPostCreate, new Section("9.2.4.c"));
status = false;
}
if (isFinal(ejbPostCreate))
{
fireSpecViolationEvent(entity, ejbPostCreate, new Section("9.2.4.d"));
status = false;
}
if (!hasVoidReturnType(ejbPostCreate))
{
fireSpecViolationEvent(entity, ejbPostCreate, new Section("9.2.4.e"));
status = false;
}
}
}
}
/*
* Every entity bean MUST define the ejbFindByPrimaryKey method.
*
* The return type for the ejbFindByPrimaryKey method MUST be the
* primary key type.
*
* The ejbFindByPrimaryKey method MUST be a single-object finder.
*
* Spec 9.2.5
*/
if (entity.isBMP() && (!hasEJBFindByPrimaryKey(bean)))
{
fireSpecViolationEvent(entity, new Section("9.2.5.a"));
status = false;
}
if (hasEJBFindByPrimaryKey(bean))
{
Method ejbFindByPrimaryKey = getEJBFindByPrimaryKey(bean);
if (!hasPrimaryKeyReturnType(entity, ejbFindByPrimaryKey))
{
fireSpecViolationEvent(entity, ejbFindByPrimaryKey, new Section("9.2.5.b"));
status = false;
}
if (!isSingleObjectFinder(entity, ejbFindByPrimaryKey))
{
fireSpecViolationEvent(entity, ejbFindByPrimaryKey, new Section("9.2.5.c"));
status = false;
}
}
/*
* A finder method MUST be declared as public.
*
* A finder method MUST NOT be declared as static.
*
* A finder method MUST NOT be declared as final.
*
* The finder method argument types MUST be legal types
* for RMI/IIOP
*
* The finder method return type MUST be either the entity bean's
* primary key type, or java.lang.util.Enumeration interface or
* java.lang.util.Collection interface.
*
* Spec 9.2.5
*/
if (hasFinderMethod(bean))
{
Iterator it = getEJBFindMethods(bean);
while (it.hasNext())
{
Method finder = (Method)it.next();
if (!isPublic(finder))
{
fireSpecViolationEvent(entity, finder, new Section("9.2.5.d"));
status = false;
}
if (isFinal(finder))
{
fireSpecViolationEvent(entity, finder, new Section("9.2.5.e"));
status = false;
}
if (isStatic(finder))
{
fireSpecViolationEvent(entity, finder, new Section("9.2.5.f"));
status = false;
}
if (!hasLegalRMIIIOPArguments(finder))
{
fireSpecViolationEvent(entity, finder, new Section("9.2.5.g"));
status = false;
}
if (!(isSingleObjectFinder(entity, finder)
|| isMultiObjectFinder(finder)))
{
fireSpecViolationEvent(entity, finder, new Section("9.2.5.h"));
status = false;
}
}
}
}
catch (ClassNotFoundException e)
{
/*
* The Bean Provider MUST specify the fully-qualified name of the
* Java class that implements the enterprise bean's business
* methods.
*
* Spec 16.2
*/
fireSpecViolationEvent(entity, new Section("16.2.b"));
status = false;
}
return status;
}