Update of /cvsroot/xdoclet/xdoclet/modules/ejb/src/xdoclet/modules/ejb/dao
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3914/modules/ejb/src/xdoclet/modules/ejb/dao
Modified Files:
DaoTagsHandler.java
Log Message:
DAO changes. Allow a factory class to be used for generating DAO instances
(XDT-1068). Also eliminate duplicate finders & create methods in DAO
interface if the bean's finder/create methods have @dao.call tags but
automatic generation is being used (XDT-47).
Index: DaoTagsHandler.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet/modules/ejb/src/xdoclet/modules/ejb/dao/DaoTagsHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** DaoTagsHandler.java 29 Apr 2003 19:14:36 -0000 1.4
--- DaoTagsHandler.java 14 Apr 2005 23:58:04 -0000 1.5
***************
*** 11,14 ****
--- 11,15 ----
import xjavadoc.XClass;
+ import xjavadoc.XMethod;
import xdoclet.DocletContext;
***************
*** 16,19 ****
--- 17,21 ----
import xdoclet.XDocletException;
import xdoclet.modules.ejb.EjbTagsHandler;
+ import xdoclet.modules.ejb.home.HomeTagsHandler;
import xdoclet.util.LogUtil;
***************
*** 41,45 ****
public static String getDaoClassFor(XClass clazz)
{
! Log log = LogUtil.getLog(DaoTagsHandler.class, "daoClassName");
String fileName = clazz.getContainingPackage().getName();
--- 43,47 ----
public static String getDaoClassFor(XClass clazz)
{
! Log log = LogUtil.getLog(DaoTagsHandler.class, "getDaoClassFor");
String fileName = clazz.getContainingPackage().getName();
***************
*** 75,78 ****
--- 77,115 ----
}
+ /**
+ * Returns true if method should be added to the DAO, false otherwise.
The method should be included if it has a
+ * dao.call tag, unless it's a finder or create method which has already
been added automatically.
+ *
+ * @param method XMethod to be evaluated
+ * @return Whether to include in the DAO
+ * @exception XDocletException
+ */
+ public static boolean isDaoMethod(XMethod method) throws XDocletException
+ {
+ boolean include;
+ Log log = LogUtil.getLog(DaoTagsHandler.class, "isDaoMethod");
+
+ include = method.getDoc().hasTag("dao.call");
+ if (log.isDebugEnabled()) {
+ log.debug("method " + method.getName() + " has " + (include ? "a"
: "no") + " dao.call tag");
+ }
+ if (HomeTagsHandler.isCreateMethod(method)) {
+ String createMethods = getTagValue(FOR_CLASS, "ejb.dao",
"create-methods", null, "true", false, false);
+
+ log.debug("createMethods=" + createMethods);
+ if ("true".equals(createMethods)) {
+ include = false;
+ }
+ }
+ if (HomeTagsHandler.isFinderMethod(method)) {
+ String finderMethods = getTagValue(FOR_CLASS, "ejb.dao",
"finder-methods", null, "true", false, false);
+
+ log.debug("finderMethods=" + finderMethods);
+ if ("true".equals(finderMethods)) {
+ include = false;
+ }
+ }
+ return include;
+ }
/**
***************
*** 93,97 ****
}
-
/**
* Gets the DaoSubTaskActive attribute of the DaoTagsHandler class
--- 130,133 ----
***************
*** 117,121 ****
}
-
/**
* Evaluate the body block if ejb.dao tag present and DAO subtask being
used.
--- 153,156 ----
***************
*** 132,134 ****
--- 167,184 ----
}
+ /**
+ * Evaluates the body block if current method is a DAO method.
+ *
+ * @param template The body of the block tag
+ * @exception XDocletException
+ * @see #isDaoMethod(xjavadoc.XMethod)
+ * @doc.tag type="block"
+ */
+ public void ifDaoMethod(String template) throws XDocletException
+ {
+ if (isDaoMethod(getCurrentMethod())) {
+ generate(template);
+ }
+ }
+
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
xdoclet-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel