User: rinkrank
Date: 02/06/07 07:18:58
Modified: core/src/xdoclet GenerationManager.java
Log:
Improving log messages and reduced visibility of some methods. More verbose logging
Revision Changes Path
1.13 +55 -108 xdoclet/core/src/xdoclet/GenerationManager.java
Index: GenerationManager.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/GenerationManager.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -r1.12 -r1.13
--- GenerationManager.java 28 May 2002 21:30:18 -0000 1.12
+++ GenerationManager.java 7 Jun 2002 14:18:58 -0000 1.13
@@ -24,17 +24,15 @@
*
* @author Vincent Harcq ([EMAIL PROTECTED])
* @created March 30, 2002
- * @version $Revision: 1.12 $
+ * @version $Revision: 1.13 $
*/
-public class GenerationManager implements java.io.Serializable
+public class GenerationManager
{
private final static File newestJar = ModuleFinder.getNewestFileOnClassPath();
- private static transient Map parserDb = null;
+ private static Map parserDb = null;
- private boolean guessGenerationNeeded = true;
-
- private transient TemplateSubTask subTask = null;
+ private final TemplateSubTask subTask;
/**
* Describe what the GenerationManager constructor does
@@ -47,13 +45,27 @@
}
/**
+ * Return (and construct) the template database. It is a map between a
<code>String</code> representing the template
+ * file and an array of <String> representing the merge files that are part of
the generation.
+ *
+ * @return the <code>Map</code>
+ */
+ private static Map getParserDb()
+ {
+ if (parserDb == null) {
+ parserDb = new HashMap();
+ }
+ return parserDb;
+ }
+
+ /**
* During parsing we build the Template database. We store it on file.
*
* @param templateURL the template file
* @param files the merge files involved in the generation
* @exception XDocletException Describe the exception
*/
- public static void updateParserDb(URL templateURL, String[] files)
+ private static void updateParserDb(URL templateURL, String[] files)
throws XDocletException
{
// Merge existing list with new list
@@ -73,30 +85,6 @@
}
/**
- * Return (and construct) the template database. It is a map between a
<code>String</code> representing the template
- * file and an array of <String> representing the merge files that are part of
the generation.
- *
- * @return the <code>Map</code>
- */
- private static Map getParserDb()
- {
- if (parserDb == null) {
- parserDb = new HashMap();
- }
- return parserDb;
- }
-
- /**
- * Gets the GuessGenerationNeeded attribute of the GenerationManager object
- *
- * @return The GuessGenerationNeeded value
- */
- public boolean isGuessGenerationNeeded()
- {
- return guessGenerationNeeded;
- }
-
- /**
* Test if a Java source mmust be generated or not depending of timestamp of
elements involved.
*
* @param clazz the Class from wich we generate
@@ -115,25 +103,16 @@
return true;
}
- if (isGuessGenerationNeeded() == false) {
- log.debug("guessGenerationNeeded enabled");
- return true;
- }
-
- // 1. Check the classpath for timestamp on XDOCLET JAR and XJAVADOC JAR
- if (checkJars(file) == true)
+ // 1. Check whether a file on classpath is newer than the destination file
+ if (isClasspathNewerThanFile(file))
return true;
- // 2. Check the bean/superclasses timestamp
- if (checkClass(file, clazz) == true)
+ // 2. Check whether the class (or any superclass) is newer than the
destination file
+ if (isClassHierarchyNewerThanFile(clazz, file))
return true;
- // 3. Check the superclasses timestamp
- if (checkSuperclasses(clazz, file) == true)
- return true;
-
- // 4. Check the timestamp of template file and merge files
- if (checkTemplateFile(withTemplate, file) == true)
+ // 3. Check whether the template file or any merge files are newer than the
destination file
+ if (isTemplateNewerThanFile(withTemplate, file))
return true;
return false;
@@ -160,13 +139,8 @@
return true;
}
- if (isGuessGenerationNeeded() == false) {
- log.debug("guessGenerationNeeded enabled");
- return true;
- }
-
// 1. Check on Jar timestamp
- if (checkJars(file) == true)
+ if (isClasspathNewerThanFile(file) == true)
return true;
// 2. Check the timestamp of template file and merge files
@@ -188,89 +162,58 @@
return false;
}
- /**
- * Sets the GuessGenerationNeeded attribute of the GenerationManager object.
- *
- * @param guessGenerationNeeded The new GuessGenerationNeeded value
- */
- public void setGuessGenerationNeeded(boolean guessGenerationNeeded)
- {
- this.guessGenerationNeeded = guessGenerationNeeded;
- }
-
- protected boolean checkTemplateFile(boolean withTemplate, File file) throws
XDocletException
- {
- Log log = LogUtil.getLog(GenerationManager.class, "generation");
-
- if (withTemplate) {
- if (isGenerationNeeded(file, subTask.getTemplateURL())) {
- if (log.isDebugEnabled()) {
- log.debug("Generation needed for '" + file.getName() + "'
because of timestamp of template file.");
- }
-
- return true;
- }
- }
-
- return false;
- }
-
- protected boolean checkSuperclasses(XClass clazz, File file)
+ private boolean isClassHierarchyNewerThanFile(XClass clazz, File file)
{
Log log = LogUtil.getLog(GenerationManager.class, "generation");
- XClass supers = clazz.getSuperclass();
-
- while (supers != null) {
- if (supers.getQualifiedName().equals("java.lang.Object")) {
+ while (clazz != null) {
+ if (clazz.getQualifiedName().equals("java.lang.Object")) {
return false;
}
- if (file.lastModified() < supers.lastModified()) {
+ if (file.lastModified() < clazz.lastModified()) {
if (log.isDebugEnabled()) {
- log.debug("Generation needed for '" + file.getName() + "'
because of timestamp of " + supers.getQualifiedName());
+ log.debug("Generation needed for '" + file.getAbsolutePath() +
"' because " + clazz.getQualifiedName() + " is newer (it's in the class hierarchy)");
}
return true;
}
- if (log.isDebugEnabled()) {
- log.debug("Reject file '" + clazz.getQualifiedName() + "' because
of timestamp of " + supers.getQualifiedName());
- }
- supers = supers.getSuperclass();
+ clazz = clazz.getSuperclass();
}
return false;
}
- protected boolean checkClass(File file, XClass clazz)
+ private boolean isTemplateNewerThanFile(boolean withTemplate, File file) throws
XDocletException
{
Log log = LogUtil.getLog(GenerationManager.class, "generation");
- if (file.lastModified() < clazz.lastModified()) {
+ log.debug("Checking template. withTemplate=" + withTemplate);
+
+ if (withTemplate) {
+ if (isGenerationNeeded(file, subTask.getTemplateURL())) {
if (log.isDebugEnabled()) {
- log.debug("Generation needed for '" + file.getName() + "' because
of timestamp of " + clazz.getQualifiedName());
+ log.debug("Generation needed for '" + file.getAbsolutePath() +
"' because template file is newer.");
}
+
return true;
}
-
- if (log.isDebugEnabled()) {
- log.debug("Reject file '" + clazz.getQualifiedName() + "' because of
timestamp of " + clazz.getQualifiedName());
}
return false;
}
- protected boolean checkJars(File file)
+ private boolean isClasspathNewerThanFile(File file)
{
Log log = LogUtil.getLog(GenerationManager.class, "generation");
if (file.lastModified() < newestJar.lastModified()) {
if (log.isDebugEnabled()) {
- log.debug("Generation needed for '" + file.getName() + "' because
of timestamp of " + newestJar.getName());
+ log.debug("Generation needed for '" + file.getAbsolutePath() + "'
because " + newestJar.getName() + " is newer.");
}
return true;
}
if (log.isDebugEnabled()) {
- log.debug("Reject file '" + file.getName() + "' because of timestamp of
" + newestJar.getName());
+ log.debug("No files on classpath are newer than '" +
file.getAbsolutePath() + "'");
}
return false;
@@ -291,28 +234,32 @@
Log log = LogUtil.getLog(GenerationManager.class, "xml");
if (log.isDebugEnabled()) {
- log.debug("Generation need check for " + file.getName());
+ log.debug("Generation need check for " + file.getAbsolutePath());
}
// 1. Check Timestamp of Template file
- if (file.lastModified() < new
File(subTask.getTemplateURL().getFile()).lastModified()) {
+ File templateFile = new File(subTask.getTemplateURL().getFile());
+
+ if (templateFile.exists() && file.lastModified() <
templateFile.lastModified()) {
if (log.isDebugEnabled()) {
- log.debug("Generation needed for '" + file.getName() + "' because
of timestamp of " + subTask.getTemplateURL());
+ log.debug("Generation needed for '" + file.getAbsolutePath() + "'
because of timestamp of " + subTask.getTemplateURL());
}
return true;
}
if (log.isDebugEnabled()) {
- log.debug("Reject file '" + file.getName() + "' because of timestamp of
" + subTask.getTemplateURL());
+ log.debug("Reject file '" + file.getAbsolutePath() + "' because of
timestamp of " + subTask.getTemplateURL());
}
// 2. Check timestamp of Merge files found inside Template
String[] files;
- if (getParserDb().get(new File(templateURL.getFile()).getName()) == null) {
+ if (getParserDb().get(templateFile) == null) {
+ // Why is setOutput called here? We're only checking _IF_ we're going
to generate! (Aslak)
subTask.getParser().setOutput(file);
subTask.getParser().setTemplateURL(templateURL);
try {
+ // THIS IS WHERE IT GOES WRONG WHEN RUNNING 2ND TIME
(Aslak)
subTask.getParser().start();
}
catch (TemplateException e) {
@@ -358,14 +305,14 @@
for (Iterator iterator = mergeFiles.iterator(); iterator.hasNext(); ) {
File mergeFile = (File) iterator.next();
- log.debug("Generation check for '" + file.getName() + "' because of
" + mergeFile.getName());
+ log.debug("Generation check for '" + file.getAbsolutePath() + "'
because of " + mergeFile.getName());
if (mergeFile.exists()) {
if (file.lastModified() < mergeFile.lastModified()) {
- log.debug("Generation needed for '" + file.getName() + "'
because of timestamp of " + mergeFile.getName());
+ log.debug("Generation needed for '" +
file.getAbsolutePath() + "' because of timestamp of " + mergeFile.getName());
return true;
}
- log.debug("Reject file '" + file.getName() + "' because of
timestamp of " + mergeFile.getName());
+ log.debug("Reject file '" + file.getAbsolutePath() + "' because
of timestamp of " + mergeFile.getName());
}
}
}
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel