KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > invicta > Invicta


1 package net.sf.invicta;
2
3 import java.lang.reflect.InvocationTargetException JavaDoc;
4 import net.sf.invicta.process.InvictaMainFlow;
5 import net.sf.invicta.template.InvictaTemplateException;
6
7 /**
8  * The main class of the Invicta Java Application.
9  * Uses InvictaMainFlow for starting the engine process.
10  */

11 public class Invicta {
12         
13     /**
14      * Main method of the Invicta application.
15      * @param args
16      */

17     public static void main(String JavaDoc[] args) {
18
19         // Start Invicta process, log received errors.
20
try {
21             Invicta invicta = new Invicta();
22             boolean wasProcessed = invicta.process();
23             if (wasProcessed) {
24                 Logger.info("**** Invicta processed and modified its output files.");
25                 Logger.info("**** You should rerun your ANT build script.");
26                 Logger.info("**** Ignore the \"BUILD FAILED\" message !");
27                 System.exit(2);
28             }
29             
30         } catch (InvictaTemplateException e) {
31             Logger.error(e.getMessage());
32             if (Logger.isDebugMode()) {
33                 e.printStackTrace();
34                 if (e.getCause() != null)
35                     e.getCause().printStackTrace();
36             }
37             System.exit(1);
38         } catch (Exception JavaDoc e) {
39             Throwable JavaDoc actualException = e;
40             if (e instanceof InvocationTargetException JavaDoc) {
41                 actualException = ((InvocationTargetException JavaDoc)e).getTargetException();
42             }
43             Logger.error(actualException.getMessage());
44             if (Logger.isDebugMode()) {
45                 actualException.printStackTrace();
46             }
47             System.exit(1);
48         }
49         System.exit(0);
50     }
51
52     /**
53      * Start Invicta process.
54      * @return boolean
55      * @throws InvictaException
56      */

57     public boolean process() throws InvictaException {
58         InvictaMainFlow mainFlow = new InvictaMainFlow();
59         mainFlow.process();
60         return mainFlow.getWasProcessed();
61     }
62     
63 }
64
Popular Tags