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


001:        package org.andromda.ant.task;
002:
003:        import java.io.FileNotFoundException;
004:
005:        import java.net.URL;
006:
007:        import org.andromda.core.AndroMDAServer;
008:        import org.andromda.core.configuration.Configuration;
009:        import org.apache.commons.lang.exception.ExceptionUtils;
010:        import org.apache.tools.ant.BuildException;
011:        import org.apache.tools.ant.taskdefs.MatchingTask;
012:
013:        /**
014:         * <p>
015:         * This class wraps the AndroMDA model processor so that AndroMDA Server can be
016:         * used as an Ant task. Represents the <code>&lt;andromda&gt;</code> custom
017:         * task which can be called from an Ant build script.
018:         * </p>
019:         *
020:         * @author Lofi Dewanto
021:         */
022:        public class AndroMDAServerStartTask extends MatchingTask {
023:            /**
024:             * Initialize the context class loader.
025:             */
026:            static {
027:                initializeContextClassLoader();
028:            }
029:
030:            /**
031:             * Stores the configuration URI.
032:             */
033:            private URL configurationUri;
034:
035:            /**
036:             * Sets the URI to the configuration file.
037:             *
038:             * @param configurationUri
039:             */
040:            public void setConfigurationUri(final URL configurationUri) {
041:                this .configurationUri = configurationUri;
042:            }
043:
044:            /**
045:             * <p>
046:             * Starts the AndroMDA server.
047:             * </p>
048:             * <p>
049:             * This is the main entry point of the application when running Ant. It is
050:             * called by ant whenever the surrounding task is executed (which could be
051:             * multiple times).
052:             * </p>
053:             *
054:             * @throws BuildException
055:             *             if something goes wrong
056:             */
057:            public void execute() throws BuildException {
058:                // Initialize before the execute as well in case we
059:                // want to execute more than once
060:                initializeContextClassLoader();
061:                try {
062:                    if (this .configurationUri == null) {
063:                        throw new BuildException(
064:                                "Configuration is not a valid URI --> '"
065:                                        + this .configurationUri + "'");
066:                    }
067:
068:                    // Create the configuration file from URI
069:                    final Configuration configuration = Configuration
070:                            .getInstance(this .configurationUri);
071:
072:                    // Create and start the server
073:                    final AndroMDAServer andromdaServer = AndroMDAServer
074:                            .newInstance();
075:                    if (andromdaServer != null) {
076:                        andromdaServer.start(configuration);
077:                    }
078:                } catch (Throwable throwable) {
079:                    final Throwable cause = ExceptionUtils.getCause(throwable);
080:                    if (cause != null) {
081:                        throwable = cause;
082:                    }
083:                    if (throwable instanceof  FileNotFoundException) {
084:                        throw new BuildException(
085:                                "No configuration could be loaded from --> '"
086:                                        + configurationUri + "'");
087:                    }
088:                    throw new BuildException(throwable);
089:                } finally {
090:                    // Set the context class loader back ot its system class loaders
091:                    // so that any processes running after won't be trying to use
092:                    // the ContextClassLoader for this class.
093:                    Thread.currentThread().setContextClassLoader(
094:                            ClassLoader.getSystemClassLoader());
095:                }
096:            }
097:
098:            /**
099:             * Set the context class loader so that any classes using it (the
100:             * contextContextClassLoader) have access to the correct loader.
101:             */
102:            private final static void initializeContextClassLoader() {
103:                Thread.currentThread().setContextClassLoader(
104:                        AndroMDAServerStartTask.class.getClassLoader());
105:            }
106:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.