Source Code Cross Referenced for AndroMDAMavenRunner.java in  » UML » AndroMDA-3.2 » org » andromda » maven » 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 » AndroMDA 3.2 » org.andromda.maven 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.andromda.maven;
002:
003:        import java.io.FileNotFoundException;
004:
005:        import java.net.MalformedURLException;
006:        import java.net.URL;
007:
008:        import java.util.Iterator;
009:        import java.util.Map;
010:
011:        import org.andromda.core.AndroMDA;
012:        import org.andromda.core.common.ResourceUtils;
013:        import org.andromda.core.configuration.Configuration;
014:        import org.apache.commons.lang.StringUtils;
015:        import org.apache.commons.lang.exception.ExceptionUtils;
016:        import org.apache.tools.ant.BuildException;
017:        import org.apache.tools.ant.taskdefs.MatchingTask;
018:
019:        /**
020:         * This task is used with the AndroMDA Maven plugin.
021:         *
022:         * @author Chad Brandon
023:         * @see org.andromda.core.engine.ModelProcessor
024:         */
025:        public class AndroMDAMavenRunner extends MatchingTask {
026:            static {
027:                Thread.currentThread().setContextClassLoader(
028:                        AndroMDAMavenRunner.class.getClassLoader());
029:            }
030:
031:            /**
032:             * The URI to the configuration;
033:             */
034:            private String configurationUri;
035:
036:            /**
037:             * Sets the URI to the configuration file.
038:             *
039:             * @param configurationUri
040:             */
041:            public void setConfigurationUri(final String configurationUri) {
042:                this .configurationUri = configurationUri;
043:            }
044:
045:            /**
046:             * Stores the search location for mapping files.
047:             */
048:            private String mappingsSearchLocation;
049:
050:            /**
051:             * Sets the mappings search location.
052:             *
053:             * @param MappingsSearchLocation
054:             */
055:            public void setMappingsSearchLocation(
056:                    final String mappingsSearchLocation) {
057:                this .mappingsSearchLocation = mappingsSearchLocation;
058:            }
059:
060:            /**
061:             *  Runs AndroMDA.
062:             */
063:            public void execute() throws BuildException {
064:                try {
065:                    final URL uri = new URL(configurationUri);
066:                    final Configuration configuration = Configuration
067:                            .getInstance(this .replaceProperties(ResourceUtils
068:                                    .getContents(uri)));
069:                    configuration
070:                            .addMappingsSearchLocation(this .mappingsSearchLocation);
071:                    final AndroMDA andromda = AndroMDA.newInstance();
072:                    if (andromda != null) {
073:                        andromda.run(configuration);
074:                        andromda.shutdown();
075:                    }
076:                } catch (Throwable throwable) {
077:                    final Throwable cause = ExceptionUtils.getCause(throwable);
078:                    if (cause != null) {
079:                        throwable = cause;
080:                    }
081:                    if (throwable instanceof  FileNotFoundException) {
082:                        throw new BuildException(
083:                                "No configuration could be loaded from --> '"
084:                                        + configurationUri + "'");
085:                    } else if (throwable instanceof  MalformedURLException) {
086:                        throw new BuildException(
087:                                "Configuration is not a valid URI --> '"
088:                                        + configurationUri + "'");
089:                    }
090:                    throw new BuildException(throwable);
091:                } finally {
092:                    // Set the context class loader back ot its system class loaders
093:                    // so that any processes running after won't be trying to use
094:                    // the ContextClassLoader for this class.
095:                    Thread.currentThread().setContextClassLoader(
096:                            ClassLoader.getSystemClassLoader());
097:                }
098:            }
099:
100:            /**
101:             * Replaces all properties having the style
102:             * <code>${some.property}</code> with the value
103:             * of the specified property if there is one.
104:             *
105:             * @param fileContents the fileContents to perform replacement on.
106:             */
107:            protected String replaceProperties(String string) {
108:                final Map properties = this .getProject().getProperties();
109:                if (properties != null && !properties.isEmpty()) {
110:                    for (final Iterator iterator = properties.keySet()
111:                            .iterator(); iterator.hasNext();) {
112:                        final String name = (String) iterator.next();
113:                        final String property = "${" + name + "}";
114:                        final String value = (String) properties.get(name);
115:                        string = StringUtils.replace(string, property, value);
116:                    }
117:                }
118:
119:                // remove any left over property references
120:                string = AndroMDAMavenUtils.removePropertyReferences(string);
121:                return string;
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.