KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > XDocletMain


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet;
6
7 import org.apache.commons.logging.Log;
8 import xjavadoc.XJavaDoc;
9
10 import xdoclet.template.TemplateException;
11 import xdoclet.util.LogUtil;
12 import xdoclet.util.Translator;
13
14 /**
15  * This class serves as an entry-point for starting XDoclet.
16  *
17  * @author Ara Abrahamian (ara_e@email.com)
18  * @author Aslak Hellesoy
19  * @created April 30, 2001
20  */

21 public class XDocletMain
22 {
23     /**
24      * Starts XDoclet
25      *
26      * @param xJavaDoc
27      * @exception XDocletException
28      */

29     protected void start(XJavaDoc xJavaDoc) throws XDocletException
30     {
31         Log log = LogUtil.getLog(XDocletMain.class, "start");
32
33         try {
34             log.debug("Context successfully loaded.");
35
36             SubTask[] subtasks = DocletContext.getInstance().getSubTasks();
37
38             for (int i = 0; i < subtasks.length; i++) {
39                 if (subtasks[i] != null) {
40                     if (log.isDebugEnabled()) {
41                         log.debug("SubTask " + subtasks[i].getSubTaskName() + " initialized.");
42                     }
43
44                     subtasks[i].init(xJavaDoc);
45                     DocletContext.getInstance().setActiveSubTask(subtasks[i]);
46
47                     log.info(Translator.getString(XDocletMessages.class, XDocletMessages.RUNNING_TASKNAME, new String JavaDoc[]{"<" + subtasks[i].getSubTaskName() + "/>"}));
48                     subtasks[i].execute();
49                 }
50             }
51         }
52         catch (XDocletException e) {
53             log.error(Translator.getString(XDocletMessages.class, XDocletMessages.RUNNING_FAILED));
54             log.error("<<" + e.getMessage() + ">>");
55
56             if (e.getNestedException() != null) {
57                 e.getNestedException().printStackTrace();
58             }
59
60             if (e.getNestedException() instanceof TemplateException) {
61                 TemplateException te = (TemplateException) e.getNestedException();
62
63                 if (log.isDebugEnabled()) {
64                     log.error("Template Exception = " + te);
65                     log.error("Nested Exception = " + te.getNestedException());
66                 }
67             }
68             throw e;
69         }
70     }
71 }
72
Popular Tags