Source Code Cross Referenced for IncludeBusinessServiceProxyDefinition.java in  » UML » MetaBoss » com » metaboss » sdlctools » applications » anttasks » builder » modules » subelements » 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.anttasks.builder.modules.subelements 
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.anttasks.builder.modules.subelements;
016:
017:        import java.io.File;
018:        import java.util.ArrayList;
019:        import java.util.Arrays;
020:        import java.util.HashSet;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Properties;
024:        import java.util.Set;
025:
026:        import javax.jmi.reflect.JmiException;
027:        import javax.naming.Context;
028:        import javax.naming.InitialContext;
029:        import javax.naming.NamingException;
030:
031:        import org.apache.tools.ant.BuildException;
032:
033:        import com.metaboss.enterprise.bs.BSException;
034:        import com.metaboss.sdlctools.applications.anttasks.builder.ModuleDefinition;
035:        import com.metaboss.sdlctools.applications.anttasks.builder.ModuleElementDefinition;
036:        import com.metaboss.sdlctools.applications.anttasks.builder.ToolInvocationDefinition;
037:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.JavaCompilerInvocationDefinitionUtils;
038:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.ProxyGeneratorInvocationDefinition;
039:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.CoreCodeGeneratorInvocationDefinition;
040:        import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
041:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
042:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
043:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
044:        import com.metaboss.sdlctools.services.codegeneration.BSServiceProxyGenerator;
045:        import com.metaboss.util.StringUtils;
046:
047:        /** The definition of how to build a business services adapter. */
048:        public class IncludeBusinessServiceProxyDefinition extends
049:                ModuleElementDefinition {
050:            // Initialise metadata for supplying in the constructor
051:            private static ElementMetadata sElementMetadata = new ElementMetadata();
052:            static {
053:                sElementMetadata.ElementTypeName = "IncludeBusinessServiceProxy";
054:                sElementMetadata.SupportsModelElementRefs = true;
055:                sElementMetadata.AllowedModelElementTypes = new Class[] {
056:                        Enterprise.class,
057:                        com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System.class,
058:                        Servicemodule.class, };
059:            }
060:            // Type suggest that we need to invoke particular implementation of the BSServiceProxyGenerator 
061:            private String mType = null;
062:            private BSServiceProxyGenerator mServiceProxyGenerator = null;
063:            private Set mServicemodulesToDo = new HashSet();
064:            private Set mServicesToDo = new HashSet();
065:
066:            /** The only available constructor */
067:            public IncludeBusinessServiceProxyDefinition(
068:                    ModuleDefinition pOwnerDefinition) {
069:                super (pOwnerDefinition, sElementMetadata);
070:            }
071:
072:            // The setter for the "type" attribute
073:            public void setType(String pType) {
074:                mType = pType;
075:            }
076:
077:            // The getter for the "type" attribute
078:            public String getType() {
079:                if (mType == null)
080:                    throw new BuildException(
081:                            "Missing 'type' attribute, which is mandatory for adapter definition.");
082:                return mType;
083:            }
084:
085:            // Called when initialisation of parameters has been completed and generation is about to commence
086:            public void completeInitialisation() throws BuildException {
087:                try {
088:                    // First obtain the implementation generator
089:                    Properties lContextProps = new Properties();
090:                    lContextProps
091:                            .setProperty(
092:                                    "com.metaboss.naming.component.com.metaboss.sdlctools.services.codegeneration.BSServiceProxyGenerator",
093:                                    "com.metaboss.sdlctools.services.codegeneration.serviceproxygenerator."
094:                                            + getType());
095:                    Context lContext = new InitialContext(lContextProps);
096:                    mServiceProxyGenerator = (BSServiceProxyGenerator) lContext
097:                            .lookup(BSServiceProxyGenerator.COMPONENT_URL);
098:
099:                    // Work on included model elements
100:                    ModelElement[] lIncludedModelElements = getIncludedModelElements();
101:                    // First collect list of all servicemodules and services to generate implementations for
102:                    for (int lElementsIndex = 0; lElementsIndex < lIncludedModelElements.length; lElementsIndex++) {
103:                        ModelElement lIncludedModelElement = lIncludedModelElements[lElementsIndex];
104:                        if (lIncludedModelElement instanceof  Service)
105:                            mServicesToDo.addAll(Arrays.asList(getOwnerTask()
106:                                    .findModelElementsByXPath(
107:                                            lIncludedModelElement,
108:                                            "descendant-or-self::Service",
109:                                            new Class[] { Service.class })));
110:                        else
111:                            mServicemodulesToDo
112:                                    .addAll(Arrays
113:                                            .asList(getOwnerTask()
114:                                                    .findModelElementsByXPath(
115:                                                            lIncludedModelElement,
116:                                                            "descendant-or-self::Servicemodule",
117:                                                            new Class[] { Servicemodule.class })));
118:                    }
119:                } catch (NamingException e) {
120:                    throw new BuildException(
121:                            "Unable to locate generator for the Service Proxy Implementation. Caught NamingException: "
122:                                    + e.getMessage());
123:                } catch (JmiException e) {
124:                    throw new BuildException(
125:                            "Caught exception while preparing to build module. "
126:                                    + e.getMessage());
127:                }
128:            }
129:
130:            /** Returns array of servicemodules included in this definition. Must be called after initialisation is complete */
131:            public Servicemodule[] getAffectedServicemodules() {
132:                HashSet lAffectedServicemodules = new HashSet();
133:                lAffectedServicemodules.addAll(mServicemodulesToDo);
134:                for (Iterator lServicesIterator = mServicesToDo.iterator(); lServicesIterator
135:                        .hasNext();) {
136:                    Service lService = (Service) lServicesIterator.next();
137:                    lAffectedServicemodules.add(lService.getServicemodule());
138:                }
139:                return (Servicemodule[]) lAffectedServicemodules
140:                        .toArray(new Servicemodule[lAffectedServicemodules
141:                                .size()]);
142:            }
143:
144:            /** Returns array of required adapter definitions. Must be called after initialisation is complete.
145:             * This mechanism basically allows the service proxy definition to request generation and build of the 
146:             * adapters it relies on */
147:            public IncludeAdapterDefinition[] getRequiredAdapterDefinitions() {
148:                try {
149:                    String[] lRequiredAdapterTypes = getGenerator()
150:                            .getRequiredAdapters();
151:                    if (lRequiredAdapterTypes != null
152:                            && lRequiredAdapterTypes.length > 0) {
153:                        IncludeAdapterDefinition[] lRequiredAdapterDefinitions = new IncludeAdapterDefinition[lRequiredAdapterTypes.length];
154:                        for (int i = 0; i < lRequiredAdapterTypes.length; i++) {
155:                            lRequiredAdapterDefinitions[i] = new IncludeAdapterDefinition(
156:                                    getOwnerModule());
157:                            lRequiredAdapterDefinitions[i]
158:                                    .setType(lRequiredAdapterTypes[i]);
159:                        }
160:                        return lRequiredAdapterDefinitions;
161:                    }
162:                    return new IncludeAdapterDefinition[0];
163:                } catch (BSException e) {
164:                    throw new BuildException(
165:                            "Caught exception while getting required Adapter Definitions. "
166:                                    + e.getMessage());
167:                }
168:            }
169:
170:            // Returns plan to invoke any number of code generators necessary to build the module  
171:            public ToolInvocationDefinition[] getGenerationPlan() {
172:                List lInvocations = new ArrayList();
173:                // Invoke for all servicemodules
174:                for (Iterator lServicemodulesIterator = mServicemodulesToDo
175:                        .iterator(); lServicemodulesIterator.hasNext();) {
176:                    Servicemodule lServicemodule = (Servicemodule) lServicemodulesIterator
177:                            .next();
178:                    // Will need to generate core of the system this is where servcie definitions are
179:                    CoreCodeGeneratorInvocationDefinition lSystemCoreGeneratorInvocationDefinition = new CoreCodeGeneratorInvocationDefinition(
180:                            getOwnerTask());
181:                    lSystemCoreGeneratorInvocationDefinition
182:                            .setSystemRef(lServicemodule.getSystem().getRef());
183:                    lInvocations.add(lSystemCoreGeneratorInvocationDefinition);
184:                    // Now generate proxise for servicemodules
185:                    ProxyGeneratorInvocationDefinition lProxyGeneratorInvocationDefinition = new ProxyGeneratorInvocationDefinition(
186:                            getOwnerTask());
187:                    lProxyGeneratorInvocationDefinition
188:                            .setServicemoduleRef(lServicemodule.getRef());
189:                    lProxyGeneratorInvocationDefinition.setType(getType());
190:                    lProxyGeneratorInvocationDefinition
191:                            .setGenerator(getGenerator());
192:                    lInvocations.add(lProxyGeneratorInvocationDefinition);
193:                }
194:
195:                // Invoke for all services which are do not belong to the servicemodules mentioned
196:                for (Iterator lServicesIterator = mServicesToDo.iterator(); lServicesIterator
197:                        .hasNext();) {
198:                    Service lService = (Service) lServicesIterator.next();
199:                    Servicemodule lOwnerServicemodule = lService
200:                            .getServicemodule();
201:                    if (!mServicemodulesToDo.contains(lOwnerServicemodule)) {
202:                        // Will need to generate core of the system this is where servcie definitions are
203:                        CoreCodeGeneratorInvocationDefinition lSystemCoreGeneratorInvocationDefinition = new CoreCodeGeneratorInvocationDefinition(
204:                                getOwnerTask());
205:                        lSystemCoreGeneratorInvocationDefinition
206:                                .setSystemRef(lOwnerServicemodule.getSystem()
207:                                        .getRef());
208:                        lInvocations
209:                                .add(lSystemCoreGeneratorInvocationDefinition);
210:                        // Now generate proxise for servicemodules
211:                        ProxyGeneratorInvocationDefinition lProxyGeneratorInvocationDefinition = new ProxyGeneratorInvocationDefinition(
212:                                getOwnerTask());
213:                        lProxyGeneratorInvocationDefinition
214:                                .setServiceRef(lService.getRef());
215:                        lProxyGeneratorInvocationDefinition.setType(getType());
216:                        lProxyGeneratorInvocationDefinition
217:                                .setGenerator(getGenerator());
218:                        lInvocations.add(lProxyGeneratorInvocationDefinition);
219:                    }
220:                }
221:                // Return what we have		
222:                return (ToolInvocationDefinition[]) lInvocations
223:                        .toArray(new ToolInvocationDefinition[lInvocations
224:                                .size()]);
225:            }
226:
227:            // Returns tasks to do after generation. (Normally compillation would go in here  
228:            public ToolInvocationDefinition[] getCompilationPlan() {
229:                try {
230:                    List lInvocations = new ArrayList();
231:                    // Invoke for all servicemodules
232:                    for (Iterator lServicemodulesIterator = mServicemodulesToDo
233:                            .iterator(); lServicemodulesIterator.hasNext();) {
234:                        Servicemodule lServicemodule = (Servicemodule) lServicemodulesIterator
235:                                .next();
236:                        // Will need to compile enterprise types
237:                        lInvocations.add(JavaCompilerInvocationDefinitionUtils
238:                                .createForEnterpriseTypes(this , lServicemodule
239:                                        .getSystem().getEnterprise()));
240:                        // Will need to compile system types
241:                        lInvocations.add(JavaCompilerInvocationDefinitionUtils
242:                                .createForSystemTypes(this , lServicemodule
243:                                        .getSystem()));
244:                        // Will need to compile servicemodule interfaces types
245:                        lInvocations.add(JavaCompilerInvocationDefinitionUtils
246:                                .createForServicemoduleInterfaces(this ,
247:                                        lServicemodule));
248:                        // Servicemodule proxy
249:                        lInvocations.add(JavaCompilerInvocationDefinitionUtils
250:                                .createForServicemoduleProxy(this , getType(),
251:                                        lServicemodule, getGenerator()));
252:                        // Service proxies
253:                        for (Iterator lServicesIterator = lServicemodule
254:                                .getServices().iterator(); lServicesIterator
255:                                .hasNext();) {
256:                            Service lService = (Service) lServicesIterator
257:                                    .next();
258:                            lInvocations
259:                                    .add(JavaCompilerInvocationDefinitionUtils
260:                                            .createForServiceProxy(this ,
261:                                                    getType(), lService,
262:                                                    getGenerator()));
263:                        }
264:                    }
265:                    // Invoke for all services
266:                    for (Iterator lServicesIterator = mServicesToDo.iterator(); lServicesIterator
267:                            .hasNext();) {
268:                        Service lService = (Service) lServicesIterator.next();
269:                        Servicemodule lOwnerServicemodule = lService
270:                                .getServicemodule();
271:                        if (!mServicemodulesToDo.contains(lOwnerServicemodule)) {
272:                            // Will need to compile enterprise types
273:                            lInvocations
274:                                    .add(JavaCompilerInvocationDefinitionUtils
275:                                            .createForEnterpriseTypes(this ,
276:                                                    lOwnerServicemodule
277:                                                            .getSystem()
278:                                                            .getEnterprise()));
279:                            // Will need to compile system types
280:                            lInvocations
281:                                    .add(JavaCompilerInvocationDefinitionUtils
282:                                            .createForSystemTypes(this ,
283:                                                    lOwnerServicemodule
284:                                                            .getSystem()));
285:                            // Will need to compile servicemodule interfaces types
286:                            lInvocations
287:                                    .add(JavaCompilerInvocationDefinitionUtils
288:                                            .createForServicemoduleInterfaces(
289:                                                    this , lOwnerServicemodule));
290:                            // Service proxy
291:                            lInvocations
292:                                    .add(JavaCompilerInvocationDefinitionUtils
293:                                            .createForServiceProxy(this ,
294:                                                    getType(), lService,
295:                                                    getGenerator()));
296:                        }
297:                    }
298:                    // Return what we have		
299:                    return (ToolInvocationDefinition[]) lInvocations
300:                            .toArray(new ToolInvocationDefinition[lInvocations
301:                                    .size()]);
302:                } catch (BSException e) {
303:                    throw new BuildException(
304:                            "Caught exception while generating packaging plan. "
305:                                    + e.getMessage());
306:                }
307:            }
308:
309:            /** Return tool invocations */
310:            public String[] getJarClassIncludes() throws BSException {
311:                List lJarClassIncludes = new ArrayList();
312:                // Package directory per servicemodule
313:                for (Iterator lServicemodulesIterator = mServicemodulesToDo
314:                        .iterator(); lServicemodulesIterator.hasNext();) {
315:                    Servicemodule lServicemodule = (Servicemodule) lServicemodulesIterator
316:                            .next();
317:                    String lProxyPackage = getGenerator()
318:                            .getPackageNameForServicemodule(
319:                                    lServicemodule.getRef());
320:                    String lProxySubdirectory = StringUtils.replace(
321:                            lProxyPackage, ".", File.separator);
322:                    lJarClassIncludes.add(lProxySubdirectory + File.separator
323:                            + "*.*"); // Whole tree including servicemodule dir
324:                    lJarClassIncludes.add(lProxySubdirectory + File.separator
325:                            + "**" + File.separator + "*.*"); // Whole tree including servicemodule dir
326:                }
327:                // Package directory per service
328:                for (Iterator lServicesIterator = mServicesToDo.iterator(); lServicesIterator
329:                        .hasNext();) {
330:                    Service lService = (Service) lServicesIterator.next();
331:                    Servicemodule lOwnerServicemodule = lService
332:                            .getServicemodule();
333:                    if (!mServicemodulesToDo.contains(lOwnerServicemodule)) {
334:                        String lProxyPackage = getGenerator()
335:                                .getPackageNameForService(lService.getRef());
336:                        String lProxySubdirectory = StringUtils.replace(
337:                                lProxyPackage, ".", File.separator);
338:                        lJarClassIncludes.add(lProxySubdirectory
339:                                + File.separator + "*.*"); // Only service dir
340:                    }
341:                }
342:                // Return what we have		
343:                return (String[]) lJarClassIncludes
344:                        .toArray(new String[lJarClassIncludes.size()]);
345:            }
346:
347:            /** @return generator for the adapter */
348:            private BSServiceProxyGenerator getGenerator() {
349:                if (mServiceProxyGenerator == null)
350:                    throw new BuildException("Element <"
351:                            + sElementMetadata.ElementTypeName
352:                            + ">has not been initialised properly.");
353:                return mServiceProxyGenerator;
354:            }
355:        }
w___w__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.