Source Code Cross Referenced for MetaBossImplementationGeneratorTask.java in  » UML » MetaBoss » org » apache » tools » ant » taskdefs » optional » metaboss » 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 » UML » MetaBoss » org.apache.tools.ant.taskdefs.optional.metaboss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package org.apache.tools.ant.taskdefs.optional.metaboss;
016:
017:        import java.io.File;
018:        import java.util.Iterator;
019:        import java.util.Map;
020:        import java.util.Properties;
021:
022:        import org.apache.tools.ant.BuildException;
023:        import org.apache.tools.ant.Project;
024:        import org.apache.tools.ant.taskdefs.Java;
025:        import org.apache.tools.ant.types.Commandline;
026:        import org.apache.tools.ant.types.Environment;
027:        import org.apache.tools.ant.types.Path;
028:
029:        import com.metaboss.util.AntUtils;
030:
031:        /** The abstract base class for all metaboss generator invocation tasks. */
032:        public abstract class MetaBossImplementationGeneratorTask extends
033:                MetaBossModelToolTask {
034:            private File mDestinationDir = null;
035:            private Path mClasspath = null;
036:            private Environment mImplementationEnvironment = null;
037:            private String mRef = null;
038:            private String mGeneratorClassName = null;
039:            private String mImplementationname = "default"; // Default is reserved for mapping coming from to the jndi properties
040:
041:            /** Constructor. Leaves ref attribute name unassigned. Useful when there is more than one choice */
042:            protected MetaBossImplementationGeneratorTask() {
043:            }
044:
045:            /** The setter for the "generatorclassname" attribute */
046:            public void setGeneratorclassname(String pGeneratorclassname) {
047:                mGeneratorClassName = pGeneratorclassname;
048:            }
049:
050:            // The getter for the "generatorclassname" attribute
051:            protected String getGeneratorclassname() {
052:                if (mGeneratorClassName == null)
053:                    throw new BuildException(
054:                            "Missing 'generatorclassname' attribute, which is mandatory for <"
055:                                    + getTaskName() + "> task.");
056:                return mGeneratorClassName;
057:            }
058:
059:            /** The setter for the "destinationdir" attribute */
060:            public void setDestinationdir(File pDestinationDir) {
061:                mDestinationDir = pDestinationDir;
062:            }
063:
064:            // The getter for the "destinationdir" attribute
065:            protected File getDestinationdir() {
066:                if (mDestinationDir == null)
067:                    throw new BuildException(
068:                            "Missing 'destinationdir' attribute, which is mandatory for <"
069:                                    + getTaskName() + "> task.");
070:                return mDestinationDir;
071:            }
072:
073:            /** The setter for the "ref" attribute */
074:            public void setRef(String pRef) {
075:                mRef = pRef;
076:            }
077:
078:            // The getter for the "Ref" attribute. Passed to the destination application as an argument 
079:            protected String getRef() {
080:                if (mRef == null)
081:                    throw new BuildException(
082:                            "Missing 'ref' attribute, which is mandatory for <"
083:                                    + getTaskName() + "> task.");
084:                return mRef;
085:            }
086:
087:            /** The setter for the "implementationname" attribute */
088:            public void setImplementationname(String pImplementationname) {
089:                mImplementationname = pImplementationname;
090:            }
091:
092:            // The getter for the "implementationname" attribute
093:            protected String getImplementationname() {
094:                if (mImplementationname == null)
095:                    throw new BuildException(
096:                            "Missing 'implementationname' attribute, which is mandatory for <"
097:                                    + getTaskName() + "> task.");
098:                return mImplementationname;
099:            }
100:
101:            /** Adds the variable to the implementation environment - to be passed to the implementation */
102:            public void addImplementationEnvironment(
103:                    Environment.Variable pVariable) {
104:                if (mImplementationEnvironment == null)
105:                    mImplementationEnvironment = new Environment();
106:                mImplementationEnvironment.addVariable(pVariable);
107:            }
108:
109:            /** The setter for the "classpath" attribute */
110:            public void setClasspath(Path pClasspath) {
111:                mClasspath = pClasspath;
112:            }
113:
114:            // Builds classpath of all things required by generator
115:            protected Path getClasspath() throws BuildException {
116:                String lJavaHome = AntUtils
117:                        .getMandatoryEnvironmentProperty("JAVA_HOME");
118:                String lMetaBossHome = getMetaBossHome().getAbsolutePath();
119:
120:                Path lClasspath = new Path(getProject());
121:                lClasspath.createPathElement().setPath(
122:                        lJavaHome + File.separator + "lib" + File.separator
123:                                + "tools.jar");
124:                lClasspath.addExisting(getPath("MetaBossModelUserClasspath"));
125:                if (mClasspath != null)
126:                    lClasspath.addExisting(mClasspath);
127:                return lClasspath;
128:            }
129:
130:            // The method executing the task
131:            public void execute() throws BuildException {
132:                Project lThisProject = getProject();
133:                // Now create and execute the java task
134:                Java lJavaTask = (Java) lThisProject.createTask("java");
135:                lJavaTask.setTaskName(getTaskName());
136:                lJavaTask.setClassname(getGeneratorclassname());
137:                {
138:                    Environment.Variable lVariable = new Environment.Variable();
139:                    lVariable.setKey("MetaBoss.Home");
140:                    lVariable.setFile(getMetaBossHome());
141:                    lJavaTask.addSysproperty(lVariable);
142:                }
143:                {
144:                    Environment.Variable lVariable = new Environment.Variable();
145:                    lVariable.setKey("MetaBoss.ModelDir");
146:                    lVariable.setFile(getModelDir());
147:                    lJavaTask.addSysproperty(lVariable);
148:                }
149:
150:                Properties lInvocationParams = getInvocationParams();
151:                Iterator lIter = lInvocationParams.entrySet().iterator();
152:                while (lIter.hasNext()) {
153:                    Map.Entry lEntry = (Map.Entry) lIter.next();
154:                    Environment.Variable lVariable = new Environment.Variable();
155:                    lVariable.setKey("MetaBoss." + (String) lEntry.getKey());
156:                    lVariable.setValue((String) lEntry.getValue());
157:                    lJavaTask.addSysproperty(lVariable);
158:                }
159:
160:                // Application arguments
161:                Commandline.Argument lArg0 = lJavaTask.createArg();
162:                lArg0.setValue(getImplementationname());
163:                Commandline.Argument lArg1 = lJavaTask.createArg();
164:                lArg1.setValue(getDestinationdir().getAbsolutePath());
165:                Commandline.Argument lArg2 = lJavaTask.createArg();
166:                lArg2.setValue(getRef());
167:                // Deal with extra arguments
168:                String[] lExtraArguments = getExtraArguments();
169:                for (int i = 0; i < lExtraArguments.length; i++) {
170:                    Commandline.Argument lArgN = lJavaTask.createArg();
171:                    lArgN.setValue(lExtraArguments[i]);
172:                }
173:                Path lClasspath = lJavaTask.createClasspath();
174:                lClasspath.addExisting(getClasspath());
175:
176:                // Need fork because of class loader hierarchy problem (may need to come fix JarClassLoader)
177:                // when runs inprocess (and this means that jars from the classpath are most probably are loaded by
178:                // Ant's classloader) any class loaded by JarClassLoader (i.e.typetemplate) is not able to load
179:                // any of the classes from jars from the classpath. Forking seem to fix it
180:                lJavaTask.setFork(true);
181:                lJavaTask.setFailonerror(true);
182:                lJavaTask.execute();
183:            }
184:        }
ww__w__._ja___va_2__s___.c__o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.