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