Source Code Cross Referenced for MavenFig.java in  » Development » jfig » org » igfay » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » jfig » org.igfay.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.igfay.util;
002:
003:        import org.apache.log4j.Logger;
004:
005:        import org.igfay.jfig.JFig;
006:
007:        import java.lang.reflect.InvocationTargetException;
008:        import java.lang.reflect.Method;
009:
010:        /**
011:         * @author conrad4
012:         *
013:         * This class brings the power and flexibility of JFig to Maven.
014:         * It takes advantage of the JFig functionality to automatically load selected values as properties.
015:         * You can put your Maven properties in your config file, then use MavenFig to process configuration and call Maven.
016:         *
017:         * This gives you the advantage of storing all your configuration in one central location in
018:         * addition to the additional JFig functionality.
019:         */
020:        public class MavenFig {
021:            private static Logger logger = Logger.getLogger(MavenFig.class);
022:
023:            private static final String FOREHEAD_CONF_FILE = "forehead.conf.file";
024:            private static final String MAVEN_HOME = "maven.home";
025:            private static final String MAVEN_MAIN_CLASS = "maven.main.class";
026:            private static final String JAVA_ENDORSED_DIRS = "java.endorsed.dirs";
027:            private static final String JAVAX_XML_PARSERS_SAXPARSERFACTORY = "javax.xml.parsers.SAXParserFactory";
028:            private static final String JAVAX_XML_PARSERS_DOCUMENTBUILDERFACTORY = "javax.xml.parsers.DocumentBuilderFactory";
029:            private static final String TOOLS_JAR = "tools.jar";
030:
031:            public static void main(String[] args) {
032:                JFig.getInstance();
033:
034:                String mavenClass = System.getProperty(MAVEN_MAIN_CLASS,
035:                        "com.werken.forehead.Forehead");
036:
037:                if (!requiredPropertiesAreDefined()) {
038:                    logger
039:                            .fatal("ERROR: You must define certain system properties for MavenFig to operate correctly.  "
040:                                    + "You can use the mavenfig script provided in the jFig distribution to automatically set them, "
041:                                    + "or you can refer to the maven.config.xml if you want to set these properties via jFig and invoke this class directly.  "
042:                                    + "  These properties are required: "
043:                                    + FOREHEAD_CONF_FILE
044:                                    + ", "
045:                                    + MAVEN_HOME
046:                                    + ", "
047:                                    + MAVEN_MAIN_CLASS
048:                                    + JAVA_ENDORSED_DIRS
049:                                    + ", "
050:                                    + JAVAX_XML_PARSERS_SAXPARSERFACTORY
051:                                    + ", "
052:                                    + JAVAX_XML_PARSERS_DOCUMENTBUILDERFACTORY
053:                                    + ", " + TOOLS_JAR + ", ");
054:                    return;
055:                }
056:
057:                try {
058:                    // Run maven via reflection. 
059:                    // The Maven bat file has the maven class name parameterized so we maintain that functionality here. 
060:                    Class clazz = Class.forName(mavenClass);
061:                    Object object = clazz.newInstance();
062:                    Class[] parameterTypes = new Class[] { String[].class };
063:                    Method mainMethod = clazz.getMethod("main", parameterTypes);
064:                    Object[] arguments = new Object[] { args };
065:
066:                    mainMethod.invoke(object, arguments);
067:                } catch (SecurityException e) {
068:                    logger.debug("Exception", e);
069:                } catch (IllegalArgumentException e) {
070:                    logger.debug("Exception", e);
071:                } catch (NoSuchMethodException e) {
072:                    logger.debug("Exception", e);
073:                } catch (InvocationTargetException e) {
074:                    logger.debug("Exception", e);
075:                } catch (InstantiationException e) {
076:                    logger.debug("Exception", e);
077:                } catch (IllegalAccessException e) {
078:                    logger.debug("Exception", e);
079:                } catch (ClassNotFoundException e) {
080:                    logger.debug("Exception", e);
081:                }
082:            }
083:
084:            /**
085:             * Checks if the system properties required by maven are all defined correctly.
086:             *  
087:             * @return true if they are defined correctly, false if not.
088:             */
089:            private static boolean requiredPropertiesAreDefined() {
090:
091:                if (!isPropertyDefined(FOREHEAD_CONF_FILE)) {
092:                    return false;
093:                }
094:
095:                if (!isPropertyDefined(JAVAX_XML_PARSERS_DOCUMENTBUILDERFACTORY)) {
096:                    return false;
097:                }
098:
099:                if (!isPropertyDefined(JAVAX_XML_PARSERS_SAXPARSERFACTORY)) {
100:                    return false;
101:                }
102:
103:                if (!isPropertyDefined(MAVEN_HOME)) {
104:                    return false;
105:                }
106:
107:                if (!isPropertyDefined(TOOLS_JAR)) {
108:                    return false;
109:                }
110:
111:                return true;
112:            }
113:
114:            /**
115:             * Check a single property for existence.
116:             * 
117:             * @param propertyToCheck
118:             * @return true if the property is set, false if not
119:             */
120:            private static boolean isPropertyDefined(String propertyToCheck) {
121:                if (System.getProperty(propertyToCheck) == null) {
122:                    logger
123:                            .fatal("ERROR: Missing property - "
124:                                    + propertyToCheck);
125:                    return false;
126:                }
127:                return true;
128:            }
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.