Source Code Cross Referenced for ServiceImplementationGeneratorApplication.java in  » UML » MetaBoss » com » metaboss » sdlctools » applications » cmdlinetools » 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 » com.metaboss.sdlctools.applications.cmdlinetools 
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 com.metaboss.sdlctools.applications.cmdlinetools;
016:
017:        import java.util.ArrayList;
018:        import java.util.Properties;
019:        import java.util.StringTokenizer;
020:
021:        import javax.naming.Context;
022:        import javax.naming.InitialContext;
023:
024:        import com.metaboss.enterprise.bs.BSException;
025:        import com.metaboss.sdlctools.models.ModelRepository;
026:        import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
027:        import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
028:        import com.metaboss.sdlctools.models.metabossmodel.ModelElementClass;
029:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
030:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
031:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
032:        import com.metaboss.sdlctools.services.codegeneration.BSServiceImplementationGenerator;
033:        import com.metaboss.util.PropertiesUtils;
034:
035:        /** This class offers command line access to the code generation of the service implementations.
036:         * It expects following arguments :
037:         * <OL>
038:         * <LI>Implementation mapping. Since every implementation generator must reside in subpackage of the
039:         * com.metaboss.sdlctools.services.codegeneration.serviceimplementationgenerator package, implementation mapping argument is only expected to contain
040:         * relative package name. <I>For example to invoke developer's simulator implementation generator implemented in "com.metaboss.sdlctools.services.codegeneration.serviceimplementationgenerator.devsimulator"
041:         * this argument must only contain "devsimulator"</I>
042:         * There is also the reserved word - "default" - if it is used this application will look for implementation
043:         * mapping in the jndi properties (if default mapping is not configurred - naming error will occur). This feature 
044:         * really does not make a lot of sence for the implementation generator (since there is no such a thing as default implementation... well actually
045:         * there is, but it is normally handcoded)
046:         * It is provided just to satisfy ant integration. This argument can also contain a comma separated list of implementation mappings
047:         * in case more than one implementation is required. The result will be just like calling this application
048:         * separately for each mapping.</LI>
049:         * <LI>Destination directory. The directory to generate code to.</LI>
050:         * <LI>Ref. The reference to generate code for. Allowed types are Enterprise, System, Servicemodule or Service.
051:         * This argument can also contain a comma separated list of references in case this appliction needs to be run for more than one element of the model.
052:         * The result will be just like calling this application separately for each ref.</LI>
053:         * </OL>
054:         * It expects following java properties :
055:         * <UL>
056:         * <LI>MetaBoss.Home - this property should point to the top level installation directory of MetaBoss. <I>For example : "-DMetaBoss.Home=c:\MetaBoss-0.1"</I></LI>  
057:         * <LI>MetaBoss.ModelDir - this property should point to the top level directory of the model. <I>For example : "-DMetaBoss.ModelDir=c:\MetaBoss-0.1\example\EnterpriseModel"</I></LI>
058:         * <LI>Any number of properties in form "MetaBoss.&lt;implementation mapping&gt;.&lt;property name&gt; to be passed to actual implementation.
059:         *  <i>For example to pass property to the devsimulator implementation it must be in form "MetaBoss.devsimulator.&lt;property name&gt;</i>"</LI>
060:         * </UL>   
061:         */
062:        public class ServiceImplementationGeneratorApplication {
063:            public static void main(String[] args) {
064:                try {
065:                    // Call common initialisation
066:                    ApplicationUtils.initialiseApplication();
067:
068:                    // Scan the arguments (must be three)
069:                    if (args == null || args.length != 3)
070:                        throw new IllegalArgumentException(
071:                                "Invalid arguments passed to the generator. Expecting four arguments : <implementation name> <destination directory> <reference>");
072:                    // arg[0] is the implementation mapping - comma separated list of implementations to invoke
073:                    String lImplementationNames = args[0];
074:                    // arg[1] is the absolute path to the destination directory
075:                    String lDestinationDirectory = args[1];
076:                    // arg[2] is the ref - comma separated list of references to work on
077:                    String lReferences = args[2];
078:
079:                    // First load all requested generators
080:                    ArrayList lGeneratorsList = new ArrayList();
081:                    StringTokenizer lImplementationNamesTokenizer = new StringTokenizer(
082:                            lImplementationNames, ",", false);
083:                    while (lImplementationNamesTokenizer.hasMoreTokens()) {
084:                        String lImplementationSuffix = lImplementationNamesTokenizer
085:                                .nextToken();
086:                        // Prepare the property based on implementation asked for.
087:                        Properties lContextProps = new Properties();
088:                        // This is the case where we do not want to use implementations cached for us by 
089:                        // context because this will not allow us to load different implementations. 
090:                        // The com.metaboss.naming.component.DisableContextCaching property switches this off. 
091:                        if (!lImplementationSuffix.equals("default"))
092:                            lContextProps
093:                                    .setProperty(
094:                                            "com.metaboss.naming.component.com.metaboss.sdlctools.services.codegeneration.BSServiceImplementationGenerator",
095:                                            "com.metaboss.sdlctools.services.codegeneration.serviceimplementationgenerator."
096:                                                    + lImplementationSuffix);
097:                        // Also pass all possible MetaBoss environment properties
098:                        lContextProps.putAll(PropertiesUtils.filterProperties(
099:                                System.getProperties(), "MetaBoss.", false));
100:                        Context ctx = new InitialContext(lContextProps);
101:                        lGeneratorsList
102:                                .add(ctx
103:                                        .lookup(BSServiceImplementationGenerator.COMPONENT_URL));
104:                    }
105:                    BSServiceImplementationGenerator[] lGenerators = (BSServiceImplementationGenerator[]) lGeneratorsList
106:                            .toArray(new BSServiceImplementationGenerator[lGeneratorsList
107:                                    .size()]);
108:                    // Now iterate through references calling all generators on each reference
109:                    Context lContext = new InitialContext();
110:                    ModelRepository lModelRepository = (ModelRepository) lContext
111:                            .lookup(ModelRepository.COMPONENT_URL);
112:                    MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) lModelRepository
113:                            .getDefaultModelExtent();
114:                    ModelElementClass lModelElementClass = lMetaBossModelPackage
115:                            .getModelElement();
116:                    StringTokenizer lReferencesTokenizer = new StringTokenizer(
117:                            lReferences, ",", false);
118:                    while (lReferencesTokenizer.hasMoreTokens()) {
119:                        String lRef = lReferencesTokenizer.nextToken();
120:                        ModelElement lModelElement = lModelElementClass
121:                                .getByRef(lRef);
122:                        if (lModelElement instanceof  Enterprise)
123:                            runGenerators(
124:                                    lGenerators,
125:                                    ApplicationUtils
126:                                            .getAllServiceRefs((Enterprise) lModelElement),
127:                                    lDestinationDirectory);
128:                        else if (lModelElement instanceof  com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System)
129:                            runGenerators(
130:                                    lGenerators,
131:                                    ApplicationUtils
132:                                            .getAllServiceRefs((com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) lModelElement),
133:                                    lDestinationDirectory);
134:                        else if (lModelElement instanceof  Servicemodule)
135:                            runGenerators(
136:                                    lGenerators,
137:                                    ApplicationUtils
138:                                            .getAllServiceRefs((Servicemodule) lModelElement),
139:                                    lDestinationDirectory);
140:                        else if (lModelElement instanceof  Service)
141:                            runGenerators(lGenerators,
142:                                    new String[] { lModelElement.getRef() },
143:                                    lDestinationDirectory);
144:                        else
145:                            throw new IllegalArgumentException(
146:                                    "Invalid reference passed to the generator. Expecting reference to the Service, Servicemodule, System or Enterprisere. Got "
147:                                            + lRef);
148:                    }
149:                    System.exit(0);
150:                } catch (Throwable t) {
151:                    ApplicationUtils.handleException(t);
152:                    System.exit(1);
153:                }
154:            }
155:
156:            // Helper. Executes all generators for all services    
157:            private static void runGenerators(
158:                    BSServiceImplementationGenerator[] pGenerators,
159:                    String[] pServiceRefs, String pGenerationDirectoryPath)
160:                    throws BSException {
161:                for (int i = 0; i < pGenerators.length; i++)
162:                    for (int j = 0; j < pServiceRefs.length; j++)
163:                        pGenerators[i].generateSourceCodeForService(
164:                                pGenerationDirectoryPath, pServiceRefs[j]);
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.