Matching ejbCreate% and ejbPostCreate% Methods in Entity-Beans

This query determines if for each ejbCreate% method in an entity-bean there exists a matching ejbPostCreate% method.

Pre-packaged Query

Query name="Semmle/StyleChecks/J2EE/Entity-Bean/Each ejbCreate%(..) should have a matching ejbPostCreate%(..) method"

Reports all ejbCreate%(..) methods in Entity-Bean types that do not have a matching ejbPostCreate%(..) method within the same type. The check if two methods match is based only on the arity and types of the two methods. The postfixes of both methods must also be the same, but this however is not yet checked with the query.

from EntityBean ebean, Method mc
where mc.getName().matches("ejbCreate%") and
      mc.getDeclaringType() = ebean and
      not exists(Method mpc | mpc.getName().matches("ejbPostCreate%") and
mpc.getDeclaringType() = ebean and
sameParamTypes(mc,mpc)) select mc, "Check if method " + mc.toString() + " has a matching ejbPostCreate%() method"

References

Enterprise JavaBeans 2.1 - Specification, section 10.6.5 and 12.2.4

Digg!Reddit!Del.icio.us!Facebook!Slashdot!Technorati!StumbleUpon!Ma.gnolia!

Comments
Only registered users can write comments!
 
< Prev   Next >