Source Code Cross Referenced for Compiler.java in  » Scripting » InstantJ » instantj » compile » 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 » Scripting » InstantJ » instantj.compile 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * InstantJ
003:         * 
004:         * Copyright (C) 2002 Nils Meier
005:         * Additional changes (C) 2002 Andy Thomas 
006:         * 
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         * 
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         * 
017:         */package instantj.compile;
018:
019:        import java.util.Collection;
020:        import java.util.HashMap;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        /**
025:         * The abstract Compiler base - it relies on a concrete sub-class
026:         * that provides the compilation functionality. Use compile()
027:         * to compile source and get a new Class.
028:         *
029:         * @see instantj.compile.sun.SunSourceCompiler
030:         * @author <A href="mailto:nils@meiers.net">Nils Meier</A>
031:         */
032:        public abstract class Compiler {
033:
034:            /** we keep a reference to one instance */
035:            private static Compiler instance;
036:
037:            /** the compiler key  */
038:            private static String DEFAULT_COMPILER_KEY = "instantj.compile.compiler";
039:
040:            /** the compiler classname */
041:            private static String DEFAULT_COMPILER = "instantj.compile.sun.SunSourceCompiler";
042:
043:            /**
044:             * Access a sub-class instance
045:             */
046:            private static Compiler getInstance() {
047:                // compiler switch?
048:                try {
049:                    String s = System.getProperty(DEFAULT_COMPILER_KEY);
050:                    if (s != null && s.length() > 0)
051:                        DEFAULT_COMPILER = s;
052:                } catch (Throwable t) {
053:                }
054:                // create new?
055:                if (instance == null)
056:                    try {
057:                        instance = (Compiler) Class.forName(DEFAULT_COMPILER)
058:                                .newInstance();
059:                    } catch (Throwable t) {
060:                        throw new CompilerError("Initializing compiler "
061:                                + DEFAULT_COMPILER + " failed with "
062:                                + t.getClass().getName() + "/" + t.getMessage());
063:                    }
064:                // done
065:                return instance;
066:            }
067:
068:            /**
069:             * Compiles source into a Class
070:             * @param source the input to compile
071:             * @param verbose whether to make compiler messages verbose
072:             * @return the compiled class
073:             */
074:            public static CompiledClass compile(Source source, boolean verbose)
075:                    throws CompilationFailedException {
076:                return compile(source, verbose, null);
077:            }
078:
079:            /**
080:             * Compiles source into a Class
081:             * @param source the input to compile
082:             * @param verbose whether to make compiler messages verbose
083:             * @param options compiler switches (depending on compiler implementation, 0=none, Integer.MAX_VALUE=all)
084:             * @return the compiled class
085:             */
086:            public static CompiledClass compile(Source source, boolean verbose,
087:                    List options) throws CompilationFailedException {
088:                return compile(source, verbose, options, null);
089:            }
090:
091:            /**
092:             * Compiles source into a Class
093:             * @param source the input to compile
094:             * @param verbose whether to make compiler messages verbose
095:             * @param options compiler switches (depending on compiler implementation, 0=none, Integer.MAX_VALUE=all)
096:             * @param deps dependencies to other CompiledClasses 
097:             * @return the compiled class
098:             */
099:            public static CompiledClass compile(Source source, boolean verbose,
100:                    List options, Collection deps)
101:                    throws CompilationFailedException {
102:                // Compile it 
103:                return getInstance().compileImpl(source, verbose, options,
104:                        CompiledClass.map(new HashMap(), deps));
105:            }
106:
107:            /**
108:             * Abstract compilation method that has to be provided by the concrete type
109:             */
110:            protected abstract CompiledClass compileImpl(Source source,
111:                    boolean verbose, List options, Map deps)
112:                    throws CompilationFailedException;
113:
114:        } //Compiler
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.