}
// NOTE: xdoclet-1.2.3 makes reference to method-level
// ejb.finder (it's not supported, as it's inconsistent across code base)
Collection finderMethods = CollectionUtils.select(Arrays.asList(javaClass.getMethods(true)),
new Predicate() {
public boolean evaluate(Object object) {
JavaMethod method = (JavaMethod) object;
boolean retVal = EjbUtils.hasFlag(ejbUtils.getMethodType(method), EjbUtils.IFACE_METHOD_FINDER);
retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(method, javaClass), viewType);
return retVal;
}
});
// Let's remove the "ejb" from it's name
finderMethods = CollectionUtils.collect(finderMethods,
new Transformer() {
public Object transform(Object object) {
return ejbUtils.externalizeMethodName((JavaMethod) object);
// return ejbUtils.removeFromMethodName((JavaMethod) object, "ejb");
}
});
Collection finderMethodsBySignature = CollectionUtils.select(Arrays.asList(javaClass.getTagsByName(
TagLibrary.EJB_FINDER, true)),
new Predicate() {
public boolean evaluate(Object object) {
EjbFinderTag finderTag = (EjbFinderTag) object;
boolean retVal = finderTag.getResultTypeMapping() == null ||
finderTag.getResultTypeMapping().equals(EjbUtils.REMOTE_INTERFACE);
retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(finderTag.getViewType()), viewType);
return retVal;
}
});
finderMethods.addAll(CollectionUtils.collect(finderMethodsBySignature,
new Transformer() {
public Object transform(Object object) {
EjbFinderTag finderTag = (EjbFinderTag) object;
return ejbUtils.getFinderMethodBySignature(finderTag.getSignature());
}
}));
// Add mandatory findByPrimaryKey if not already there
// Is this only for CMP ?? (xdoclet-1.2.3 says so, but i'll ignore
// it for consistency, but it has a point anyway..
// TODO: Centralize "findByPrimaryKey" /EjbPkTag somewhere..
// if (ejbUtils.isCMP(javaClass)) {
// Let's check if there is at least one "findByPrimaryKey"
int count = CollectionUtils.countMatches(finderMethods,
new Predicate() {
public boolean evaluate(Object object) {
JavaMethod method = (JavaMethod) object;
return "findByPrimaryKey".equals(method.getName());
}
});