Source Code Cross Referenced for BusinessServicesImplementationModuleDefinition.java in  » UML » MetaBoss » com » metaboss » sdlctools » applications » anttasks » builder » modules » 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 
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;
016:
017:        import java.util.ArrayList;
018:        import java.util.Arrays;
019:        import java.util.HashSet;
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.Set;
023:
024:        import javax.jmi.reflect.JmiException;
025:
026:        import org.apache.tools.ant.BuildException;
027:
028:        import com.metaboss.enterprise.bs.BSException;
029:        import com.metaboss.sdlctools.applications.anttasks.builder.MetaBossBuilderTask;
030:        import com.metaboss.sdlctools.applications.anttasks.builder.ModuleDefinition;
031:        import com.metaboss.sdlctools.applications.anttasks.builder.ToolInvocationDefinition;
032:        import com.metaboss.sdlctools.applications.anttasks.builder.modules.subelements.BusinessServiceDomainSupportImplementationDefinition;
033:        import com.metaboss.sdlctools.applications.anttasks.builder.modules.subelements.BusinessServiceGeneratedImplementationDefinition;
034:        import com.metaboss.sdlctools.applications.anttasks.builder.modules.subelements.IncludeBusinessServiceHandcodedImplementationDefinition;
035:        import com.metaboss.sdlctools.applications.anttasks.builder.modules.subelements.IncludeBusinessServiceProxyDefinition;
036:        import com.metaboss.sdlctools.applications.anttasks.builder.modules.subelements.IncludeDomainImplementationDefinition;
037:        import com.metaboss.sdlctools.applications.anttasks.builder.modules.subelements.IncludeStorageImplementationDefinition;
038:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.JarPackagerInvocationDefinition;
039:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.JavaCompilerInvocationDefinitionUtils;
040:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.CoreCodeGeneratorInvocationDefinition;
041:        import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
042:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
043:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
044:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
045:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
046:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.DomainRelationalStorageDefinition;
047:        import com.metaboss.sdlctools.services.codegeneration.CodeGenerationStylesheetAccessor;
048:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEnterpriseStylesheet;
049:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STServicemoduleStylesheet;
050:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STSystemStylesheet;
051:
052:        /** The definition of how to build system implementation module */
053:        public class BusinessServicesImplementationModuleDefinition extends
054:                ModuleDefinition {
055:            // Initialise metadata for supplying in the constructor
056:            private static ElementMetadata sElementMetadata = new ElementMetadata();
057:            static {
058:                sElementMetadata.ElementTypeName = "BusinessServicesImplementationModule";
059:                sElementMetadata.SupportsModelElementRefs = true;
060:                sElementMetadata.AllowedModelElementTypes = new Class[] {
061:                        Enterprise.class,
062:                        com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System.class,
063:                        Servicemodule.class };
064:            }
065:            private String mDestinationArchiveName = null;
066:            private Set mServicemodulesToDo = new HashSet();
067:            private List mHandcodedImplementationsToInclude = new ArrayList();
068:            private List mGeneratedImplementationsToInclude = new ArrayList();
069:            private List mDomainSupportImplementationsToInclude = new ArrayList();
070:            private List mServiceProxiesToInclude = new ArrayList();
071:            private List mDomainImplementationsToInclude = new ArrayList();
072:            private List mStorageImplementationsToInclude = new ArrayList();
073:
074:            /** The only available constructor */
075:            public BusinessServicesImplementationModuleDefinition(
076:                    MetaBossBuilderTask pOwnerTask) {
077:                super (pOwnerTask, sElementMetadata);
078:            }
079:
080:            /** The special creator asking to build Handcoded Implementation */
081:            public IncludeBusinessServiceHandcodedImplementationDefinition createIncludeHandcodedImplementation() {
082:                IncludeBusinessServiceHandcodedImplementationDefinition lImplementationDefinition = new IncludeBusinessServiceHandcodedImplementationDefinition(
083:                        this );
084:                mHandcodedImplementationsToInclude
085:                        .add(lImplementationDefinition);
086:                return lImplementationDefinition;
087:            }
088:
089:            /** The special creator asking to build Generated Implementation */
090:            public BusinessServiceGeneratedImplementationDefinition createGeneratedImplementation() {
091:                BusinessServiceGeneratedImplementationDefinition lImplementationDefinition = new BusinessServiceGeneratedImplementationDefinition(
092:                        this );
093:                mGeneratedImplementationsToInclude
094:                        .add(lImplementationDefinition);
095:                return lImplementationDefinition;
096:            }
097:
098:            /** The special creator asking to build DomainSupport Implementation */
099:            public BusinessServiceDomainSupportImplementationDefinition createDomainSupportImplementation() {
100:                BusinessServiceDomainSupportImplementationDefinition lImplementationDefinition = new BusinessServiceDomainSupportImplementationDefinition(
101:                        this );
102:                mDomainSupportImplementationsToInclude
103:                        .add(lImplementationDefinition);
104:                return lImplementationDefinition;
105:            }
106:
107:            /** The special creator asking to build BusinessServiceAdapterDefinition */
108:            public IncludeBusinessServiceProxyDefinition createIncludeServiceProxy() {
109:                IncludeBusinessServiceProxyDefinition lProxyDefinition = new IncludeBusinessServiceProxyDefinition(
110:                        this );
111:                mServiceProxiesToInclude.add(lProxyDefinition);
112:                return lProxyDefinition;
113:            }
114:
115:            /** The special creator asking to include one or more domain implementations */
116:            public IncludeDomainImplementationDefinition createIncludeDomainImplementation() {
117:                IncludeDomainImplementationDefinition lIncludeDefinition = new IncludeDomainImplementationDefinition(
118:                        this );
119:                mDomainImplementationsToInclude.add(lIncludeDefinition);
120:                return lIncludeDefinition;
121:            }
122:
123:            /** The special creator asking to include one or more storage implementations */
124:            public IncludeStorageImplementationDefinition createIncludeStorageImplementation() {
125:                IncludeStorageImplementationDefinition lIncludeDefinition = new IncludeStorageImplementationDefinition(
126:                        this );
127:                mStorageImplementationsToInclude.add(lIncludeDefinition);
128:                return lIncludeDefinition;
129:            }
130:
131:            /** Called when initialisation of parameters has been completed and generation is about to commence */
132:            public void completeInitialisation() throws BuildException {
133:                try {
134:                    // Work on included elements
135:                    ModelElement[] lIncludedModelElements = getIncludedModelElements();
136:                    // First collect list of al domains to generate implementations for
137:                    for (int lElementsIndex = 0; lElementsIndex < lIncludedModelElements.length; lElementsIndex++) {
138:                        ModelElement lIncludedModelElement = lIncludedModelElements[lElementsIndex];
139:                        mServicemodulesToDo.addAll(Arrays.asList(getOwnerTask()
140:                                .findModelElementsByXPath(
141:                                        lIncludedModelElement,
142:                                        "descendant-or-self::Servicemodule",
143:                                        new Class[] { Servicemodule.class })));
144:                    }
145:
146:                    // Work on the module name
147:                    String lModuleName = getModuleName();
148:                    if (lModuleName == null) {
149:                        ModelElement lRootModelElement = getRootModelElement();
150:                        if (lRootModelElement instanceof  Enterprise) {
151:                            // Set up module name for the domain
152:                            STEnterpriseStylesheet lEntepriseStylesheet = CodeGenerationStylesheetAccessor
153:                                    .getEnterpriseStylesheet(lRootModelElement
154:                                            .getName());
155:                            lModuleName = lEntepriseStylesheet
156:                                    .getBusinessServicesImplementationModuleName();
157:                        } else if (lRootModelElement instanceof  com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) {
158:                            // Set up module name for the system
159:                            STSystemStylesheet lSystemStylesheet = CodeGenerationStylesheetAccessor
160:                                    .getSystemStylesheet(lRootModelElement
161:                                            .getRef());
162:                            lModuleName = lSystemStylesheet
163:                                    .getBusinessServicesImplementationModuleName();
164:                        } else {
165:                            // We are given a servicemodule
166:                            STServicemoduleStylesheet lServicemodulesStylesheet = CodeGenerationStylesheetAccessor
167:                                    .getServicemoduleStylesheet(lRootModelElement
168:                                            .getRef());
169:                            lModuleName = lServicemodulesStylesheet
170:                                    .getBusinessServicesImplementationModuleName();
171:                        }
172:                    }
173:                    // We now have a automatically generated modules name. Se if we need to use it or the explicit one
174:                    StringBuffer lModuleNameBuffer = new StringBuffer(
175:                            lModuleName);
176:                    // Finish building the archive name
177:                    String lVersionToken = getOwnerTask().getVersionToken();
178:                    if (lVersionToken != null) {
179:                        lModuleNameBuffer.append("_");
180:                        lModuleNameBuffer.append(lVersionToken);
181:                    }
182:                    lModuleNameBuffer.append(".jar");
183:                    mDestinationArchiveName = lModuleNameBuffer.toString();
184:
185:                    // Now complete initialisation of the subelements
186:
187:                    // ---- Handcoded service implementations
188:                    for (Iterator lIncludedIterator = mHandcodedImplementationsToInclude
189:                            .iterator(); lIncludedIterator.hasNext();) {
190:                        IncludeBusinessServiceHandcodedImplementationDefinition lInclusionDefinitionElement = (IncludeBusinessServiceHandcodedImplementationDefinition) lIncludedIterator
191:                                .next();
192:                        lInclusionDefinitionElement
193:                                .setDefaultRootModelElement(getRootModelElement());
194:                        lInclusionDefinitionElement.completeInitialisation();
195:                        Servicemodule[] lIncludedServicemodules = lInclusionDefinitionElement
196:                                .getIncludedServicemodules();
197:                        // Need to check that all servicemodules are included
198:                        for (int i = 0; i < lIncludedServicemodules.length; i++) {
199:                            Servicemodule lIncludedServicemodule = lIncludedServicemodules[i];
200:                            if (!mServicemodulesToDo
201:                                    .contains(lIncludedServicemodule))
202:                                throw new BuildException(
203:                                        "The <IncludeHandcodedImplementation> subelement must refer to the contained Servicemodule");
204:                        }
205:                    }
206:
207:                    // ---- Generated service implementations
208:                    for (Iterator lIncludedIterator = mGeneratedImplementationsToInclude
209:                            .iterator(); lIncludedIterator.hasNext();) {
210:                        BusinessServiceGeneratedImplementationDefinition lInclusionDefinitionElement = (BusinessServiceGeneratedImplementationDefinition) lIncludedIterator
211:                                .next();
212:                        lInclusionDefinitionElement
213:                                .setDefaultRootModelElement(getRootModelElement());
214:                        lInclusionDefinitionElement.completeInitialisation();
215:                        Service[] lIncludedServices = lInclusionDefinitionElement
216:                                .getIncludedServices();
217:                        // Need to check that all services belong to the included servicemodules
218:                        for (int i = 0; i < lIncludedServices.length; i++) {
219:                            Service lIncludedService = lIncludedServices[i];
220:                            if (!mServicemodulesToDo.contains(lIncludedService
221:                                    .getServicemodule()))
222:                                throw new BuildException(
223:                                        "The <GeneratedImplementation> subelement must refer to the contained Service");
224:                        }
225:                    }
226:
227:                    // ---- Generated Domain support implementations
228:                    for (Iterator lIncludedIterator = mDomainSupportImplementationsToInclude
229:                            .iterator(); lIncludedIterator.hasNext();) {
230:                        BusinessServiceDomainSupportImplementationDefinition lInclusionDefinitionElement = (BusinessServiceDomainSupportImplementationDefinition) lIncludedIterator
231:                                .next();
232:                        lInclusionDefinitionElement
233:                                .setDefaultRootModelElement(getRootModelElement());
234:                        lInclusionDefinitionElement.completeInitialisation();
235:                        Domain[] lIncludedDomains = lInclusionDefinitionElement
236:                                .getIncludedDomains();
237:                        // Need to check that all domains are from the same systems as servicemodules
238:                        for (int i = 0; i < lIncludedDomains.length; i++) {
239:                            Domain lIncludedDomain = lIncludedDomains[i];
240:                            com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lDomainSystem = lIncludedDomain
241:                                    .getSystem();
242:                            boolean lFoundSameSystem = false;
243:                            for (Iterator lIter = mServicemodulesToDo
244:                                    .iterator(); lFoundSameSystem == false
245:                                    && lIter.hasNext();)
246:                                lFoundSameSystem = ((Servicemodule) lIter
247:                                        .next()).getSystem().equals(
248:                                        lDomainSystem);
249:                            if (!lFoundSameSystem)
250:                                throw new BuildException(
251:                                        "The <DomainSupportImplementation> subelement must refer to the contained Domain");
252:                        }
253:                    }
254:
255:                    // ---- Generated service proxy implementations
256:                    for (Iterator lIncludedIterator = mServiceProxiesToInclude
257:                            .iterator(); lIncludedIterator.hasNext();) {
258:                        IncludeBusinessServiceProxyDefinition lInclusionDefinitionElement = (IncludeBusinessServiceProxyDefinition) lIncludedIterator
259:                                .next();
260:                        lInclusionDefinitionElement
261:                                .setDefaultRootModelElement(getRootModelElement());
262:                        lInclusionDefinitionElement.completeInitialisation();
263:                        // Need to check that all services belong to the included servicemodules
264:                        Servicemodule[] lAffectedServicemodules = lInclusionDefinitionElement
265:                                .getAffectedServicemodules();
266:                        for (int i = 0; i < lAffectedServicemodules.length; i++) {
267:                            Servicemodule lAffectedServicemodule = lAffectedServicemodules[i];
268:                            if (!mServicemodulesToDo
269:                                    .contains(lAffectedServicemodule))
270:                                throw new BuildException(
271:                                        "The <IncludeServiceProxy> subelement must refer to the one of the Servicemodules (or the Service containeed within one of the Servicemodules) referenced in the parent <"
272:                                                + getElementMetadata().ElementTypeName
273:                                                + "> element.");
274:                        }
275:                    }
276:
277:                    // ---- Generated domain implementation
278:                    for (Iterator lIncludedIterator = mDomainImplementationsToInclude
279:                            .iterator(); lIncludedIterator.hasNext();) {
280:                        IncludeDomainImplementationDefinition lInclusionDefinitionElement = (IncludeDomainImplementationDefinition) lIncludedIterator
281:                                .next();
282:                        lInclusionDefinitionElement
283:                                .setDefaultRootModelElement(getRootModelElement());
284:                        lInclusionDefinitionElement.completeInitialisation();
285:                        Domain[] lIncludedDomains = lInclusionDefinitionElement
286:                                .getIncludedDomains();
287:                        // Need to check that all domains are from the same systems as servicemodules
288:                        for (int i = 0; i < lIncludedDomains.length; i++) {
289:                            Domain lIncludedDomain = lIncludedDomains[i];
290:                            com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lDomainSystem = lIncludedDomain
291:                                    .getSystem();
292:                            boolean lFoundSameSystem = false;
293:                            for (Iterator lIter = mServicemodulesToDo
294:                                    .iterator(); lFoundSameSystem == false
295:                                    && lIter.hasNext();)
296:                                lFoundSameSystem = ((Servicemodule) lIter
297:                                        .next()).getSystem().equals(
298:                                        lDomainSystem);
299:                            if (!lFoundSameSystem)
300:                                throw new BuildException(
301:                                        "The <IncludeDomainImplementation> subelement must refer to the contained Domain");
302:                        }
303:                    }
304:
305:                    // ---- Generated storage implementations
306:                    for (Iterator lIncludedIterator = mStorageImplementationsToInclude
307:                            .iterator(); lIncludedIterator.hasNext();) {
308:                        IncludeStorageImplementationDefinition lInclusionDefinitionElement = (IncludeStorageImplementationDefinition) lIncludedIterator
309:                                .next();
310:                        lInclusionDefinitionElement
311:                                .setDefaultRootModelElement(getRootModelElement());
312:                        lInclusionDefinitionElement.completeInitialisation();
313:                        DomainRelationalStorageDefinition[] lIncludedStorages = lInclusionDefinitionElement
314:                                .getIncludedStorages();
315:                        // Need to check that all domains are from the same systems as servicemodules
316:                        for (int i = 0; i < lIncludedStorages.length; i++) {
317:                            DomainRelationalStorageDefinition lIncludedStorage = lIncludedStorages[i];
318:                            com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lDomainSystem = lIncludedStorage
319:                                    .getDomain().getSystem();
320:                            boolean lFoundSameSystem = false;
321:                            for (Iterator lIter = mServicemodulesToDo
322:                                    .iterator(); lFoundSameSystem == false
323:                                    && lIter.hasNext();)
324:                                lFoundSameSystem = ((Servicemodule) lIter
325:                                        .next()).getSystem().equals(
326:                                        lDomainSystem);
327:                            if (!lFoundSameSystem)
328:                                throw new BuildException(
329:                                        "The <IncludeStorageImplementation> subelement must refer to the contained Storage Implementation");
330:                        }
331:                    }
332:                } catch (JmiException e) {
333:                    throw new BuildException(
334:                            "Caught exception while preparing to build module. "
335:                                    + e.getMessage());
336:                } catch (BSException e) {
337:                    throw new BuildException(
338:                            "Caught exception while preparing to build module. "
339:                                    + e.getMessage());
340:                }
341:            }
342:
343:            // Returns plan to invoke any number of code generators necessary to build the module  
344:            public ToolInvocationDefinition[] getGenerationPlan() {
345:                try {
346:                    List lInvocations = new ArrayList();
347:                    for (Iterator lServicemodulesIterator = mServicemodulesToDo
348:                            .iterator(); lServicemodulesIterator.hasNext();) {
349:                        Servicemodule lServicemodule = (Servicemodule) lServicemodulesIterator
350:                                .next();
351:                        // Will need to generate core of the system - necessary for compilation
352:                        CoreCodeGeneratorInvocationDefinition lSystemCoreGeneratorInvocationDefinition = new CoreCodeGeneratorInvocationDefinition(
353:                                getOwnerTask());
354:                        lSystemCoreGeneratorInvocationDefinition
355:                                .setSystemRef(lServicemodule.getSystem()
356:                                        .getRef());
357:                        lInvocations
358:                                .add(lSystemCoreGeneratorInvocationDefinition);
359:                        // Immediately compile data types because some other tools might use them
360:                        if (getOwnerTask().getTypesSrcDir() != null) {
361:                            // Compile custom enterprise types
362:                            lInvocations
363:                                    .add(JavaCompilerInvocationDefinitionUtils
364:                                            .createForCustomEnterpriseTypes(
365:                                                    this , lServicemodule
366:                                                            .getSystem()
367:                                                            .getEnterprise()));
368:                            // Compile ciustom generated system types
369:                            lInvocations
370:                                    .add(JavaCompilerInvocationDefinitionUtils
371:                                            .createForCustomSystemTypes(this ,
372:                                                    lServicemodule.getSystem()));
373:                        }
374:                        // Compile generated enterprise types
375:                        lInvocations.add(JavaCompilerInvocationDefinitionUtils
376:                                .createForEnterpriseTypes(this , lServicemodule
377:                                        .getSystem().getEnterprise()));
378:                        // Compile generated system types
379:                        lInvocations.add(JavaCompilerInvocationDefinitionUtils
380:                                .createForSystemTypes(this , lServicemodule
381:                                        .getSystem()));
382:                    }
383:                    // Iterate through stored generations and do it.
384:                    for (Iterator lImplementationsIterator = mGeneratedImplementationsToInclude
385:                            .iterator(); lImplementationsIterator.hasNext();) {
386:                        BusinessServiceGeneratedImplementationDefinition lBusinessServiceGeneratedImplementationDefinition = (BusinessServiceGeneratedImplementationDefinition) lImplementationsIterator
387:                                .next();
388:                        ToolInvocationDefinition[] lToolInvocations = lBusinessServiceGeneratedImplementationDefinition
389:                                .getGenerationPlan();
390:                        if (lToolInvocations != null
391:                                && lToolInvocations.length > 0)
392:                            lInvocations
393:                                    .addAll(Arrays.asList(lToolInvocations));
394:                    }
395:                    for (Iterator lImplementationsIterator = mDomainSupportImplementationsToInclude
396:                            .iterator(); lImplementationsIterator.hasNext();) {
397:                        BusinessServiceDomainSupportImplementationDefinition lBusinessServiceDomainSupportImplementationDefinition = (BusinessServiceDomainSupportImplementationDefinition) lImplementationsIterator
398:                                .next();
399:                        ToolInvocationDefinition[] lToolInvocations = lBusinessServiceDomainSupportImplementationDefinition
400:                                .getGenerationPlan();
401:                        if (lToolInvocations != null
402:                                && lToolInvocations.length > 0)
403:                            lInvocations
404:                                    .addAll(Arrays.asList(lToolInvocations));
405:                    }
406:                    for (Iterator lProxiesIterator = mServiceProxiesToInclude
407:                            .iterator(); lProxiesIterator.hasNext();) {
408:                        IncludeBusinessServiceProxyDefinition lServiceProxyDefinition = (IncludeBusinessServiceProxyDefinition) lProxiesIterator
409:                                .next();
410:                        ToolInvocationDefinition[] lToolInvocations = lServiceProxyDefinition
411:                                .getGenerationPlan();
412:                        if (lToolInvocations != null
413:                                && lToolInvocations.length > 0)
414:                            lInvocations
415:                                    .addAll(Arrays.asList(lToolInvocations));
416:                    }
417:                    for (Iterator lDomainImplementationsIterator = mDomainImplementationsToInclude
418:                            .iterator(); lDomainImplementationsIterator
419:                            .hasNext();) {
420:                        IncludeDomainImplementationDefinition lIncludeDomainDefinition = (IncludeDomainImplementationDefinition) lDomainImplementationsIterator
421:                                .next();
422:                        ToolInvocationDefinition[] lToolInvocations = lIncludeDomainDefinition
423:                                .getGenerationPlan();
424:                        if (lToolInvocations != null
425:                                && lToolInvocations.length > 0)
426:                            lInvocations
427:                                    .addAll(Arrays.asList(lToolInvocations));
428:                    }
429:                    for (Iterator lStorageImplementationsIterator = mStorageImplementationsToInclude
430:                            .iterator(); lStorageImplementationsIterator
431:                            .hasNext();) {
432:                        IncludeStorageImplementationDefinition lIncludeStorageDefinition = (IncludeStorageImplementationDefinition) lStorageImplementationsIterator
433:                                .next();
434:                        ToolInvocationDefinition[] lToolInvocations = lIncludeStorageDefinition
435:                                .getGenerationPlan();
436:                        if (lToolInvocations != null
437:                                && lToolInvocations.length > 0)
438:                            lInvocations
439:                                    .addAll(Arrays.asList(lToolInvocations));
440:                    }
441:                    // Handcoded are always last - just in case they use some of the generated stuff
442:                    for (Iterator lImplementationsIterator = mHandcodedImplementationsToInclude
443:                            .iterator(); lImplementationsIterator.hasNext();) {
444:                        IncludeBusinessServiceHandcodedImplementationDefinition lIncludeBusinessServiceHandcodedImplementationDefinition = (IncludeBusinessServiceHandcodedImplementationDefinition) lImplementationsIterator
445:                                .next();
446:                        ToolInvocationDefinition[] lToolInvocations = lIncludeBusinessServiceHandcodedImplementationDefinition
447:                                .getGenerationPlan();
448:                        if (lToolInvocations != null
449:                                && lToolInvocations.length > 0)
450:                            lInvocations
451:                                    .addAll(Arrays.asList(lToolInvocations));
452:                    }
453:                    // Return what we have		
454:                    return (ToolInvocationDefinition[]) lInvocations
455:                            .toArray(new ToolInvocationDefinition[lInvocations
456:                                    .size()]);
457:                } catch (BSException e) {
458:                    throw new BuildException(
459:                            "Caught exception while generating packaging plan. "
460:                                    + e.getMessage());
461:                }
462:            }
463:
464:            // Returns tasks to do after generation. (Normally compillation would go in here  
465:            public ToolInvocationDefinition[] getCompilationPlan() {
466:                try {
467:                    List lInvocations = new ArrayList();
468:                    for (Iterator lServicemodulesIterator = mServicemodulesToDo
469:                            .iterator(); lServicemodulesIterator.hasNext();) {
470:                        Servicemodule lServicemodule = (Servicemodule) lServicemodulesIterator
471:                                .next();
472:                        // Will need to compile enterprise types
473:                        lInvocations.add(JavaCompilerInvocationDefinitionUtils
474:                                .createForEnterpriseTypes(this , lServicemodule
475:                                        .getSystem().getEnterprise()));
476:                        // Will need to compile system data types
477:                        lInvocations.add(JavaCompilerInvocationDefinitionUtils
478:                                .createForSystemTypes(this , lServicemodule
479:                                        .getSystem()));
480:                        lInvocations.add(JavaCompilerInvocationDefinitionUtils
481:                                .createForServicemoduleInterfaces(this ,
482:                                        lServicemodule));
483:                        // Domain interfaces
484:                        for (Iterator lDomainsIterator = lServicemodule
485:                                .getSystem().getDomains().iterator(); lDomainsIterator
486:                                .hasNext();) {
487:                            Domain lDomain = (Domain) lDomainsIterator.next();
488:                            lInvocations
489:                                    .add(JavaCompilerInvocationDefinitionUtils
490:                                            .createForDomainInterfaces(this ,
491:                                                    lDomain));
492:                        }
493:                    }
494:                    // Iterate through stored generations and do it.
495:                    for (Iterator lImplementationsIterator = mGeneratedImplementationsToInclude
496:                            .iterator(); lImplementationsIterator.hasNext();) {
497:                        BusinessServiceGeneratedImplementationDefinition lBusinessServiceGeneratedImplementationDefinition = (BusinessServiceGeneratedImplementationDefinition) lImplementationsIterator
498:                                .next();
499:                        ToolInvocationDefinition[] lToolInvocations = lBusinessServiceGeneratedImplementationDefinition
500:                                .getCompilationPlan();
501:                        if (lToolInvocations != null
502:                                && lToolInvocations.length > 0)
503:                            lInvocations
504:                                    .addAll(Arrays.asList(lToolInvocations));
505:                    }
506:                    for (Iterator lImplementationsIterator = mDomainSupportImplementationsToInclude
507:                            .iterator(); lImplementationsIterator.hasNext();) {
508:                        BusinessServiceDomainSupportImplementationDefinition lBusinessServiceDomainSupportImplementationDefinition = (BusinessServiceDomainSupportImplementationDefinition) lImplementationsIterator
509:                                .next();
510:                        ToolInvocationDefinition[] lToolInvocations = lBusinessServiceDomainSupportImplementationDefinition
511:                                .getCompilationPlan();
512:                        if (lToolInvocations != null
513:                                && lToolInvocations.length > 0)
514:                            lInvocations
515:                                    .addAll(Arrays.asList(lToolInvocations));
516:                    }
517:                    for (Iterator lProxiesIterator = mServiceProxiesToInclude
518:                            .iterator(); lProxiesIterator.hasNext();) {
519:                        IncludeBusinessServiceProxyDefinition lServiceProxyDefinition = (IncludeBusinessServiceProxyDefinition) lProxiesIterator
520:                                .next();
521:                        ToolInvocationDefinition[] lToolInvocations = lServiceProxyDefinition
522:                                .getCompilationPlan();
523:                        if (lToolInvocations != null
524:                                && lToolInvocations.length > 0)
525:                            lInvocations
526:                                    .addAll(Arrays.asList(lToolInvocations));
527:                    }
528:                    for (Iterator lDomainImplementationsIterator = mDomainImplementationsToInclude
529:                            .iterator(); lDomainImplementationsIterator
530:                            .hasNext();) {
531:                        IncludeDomainImplementationDefinition lIncludeDomainDefinition = (IncludeDomainImplementationDefinition) lDomainImplementationsIterator
532:                                .next();
533:                        ToolInvocationDefinition[] lToolInvocations = lIncludeDomainDefinition
534:                                .getCompilationPlan();
535:                        if (lToolInvocations != null
536:                                && lToolInvocations.length > 0)
537:                            lInvocations
538:                                    .addAll(Arrays.asList(lToolInvocations));
539:                    }
540:                    for (Iterator lStorageImplementationsIterator = mStorageImplementationsToInclude
541:                            .iterator(); lStorageImplementationsIterator
542:                            .hasNext();) {
543:                        IncludeStorageImplementationDefinition lIncludeStorageDefinition = (IncludeStorageImplementationDefinition) lStorageImplementationsIterator
544:                                .next();
545:                        ToolInvocationDefinition[] lToolInvocations = lIncludeStorageDefinition
546:                                .getCompilationPlan();
547:                        if (lToolInvocations != null
548:                                && lToolInvocations.length > 0)
549:                            lInvocations
550:                                    .addAll(Arrays.asList(lToolInvocations));
551:                    }
552:                    // Handcoded are always last - just in case they use some of the generated stuff
553:                    for (Iterator lImplementationsIterator = mHandcodedImplementationsToInclude
554:                            .iterator(); lImplementationsIterator.hasNext();) {
555:                        IncludeBusinessServiceHandcodedImplementationDefinition lIncludeBusinessServiceHandcodedImplementationDefinition = (IncludeBusinessServiceHandcodedImplementationDefinition) lImplementationsIterator
556:                                .next();
557:                        ToolInvocationDefinition[] lToolInvocations = lIncludeBusinessServiceHandcodedImplementationDefinition
558:                                .getCompilationPlan();
559:                        if (lToolInvocations != null
560:                                && lToolInvocations.length > 0)
561:                            lInvocations
562:                                    .addAll(Arrays.asList(lToolInvocations));
563:                    }
564:                    // Return what we have		
565:                    return (ToolInvocationDefinition[]) lInvocations
566:                            .toArray(new ToolInvocationDefinition[lInvocations
567:                                    .size()]);
568:                } catch (BSException e) {
569:                    throw new BuildException(
570:                            "Caught exception while generating packaging plan. "
571:                                    + e.getMessage());
572:                }
573:            }
574:
575:            // Returns tasks to invoke any number of packagers necessary to build the module  
576:            public ToolInvocationDefinition[] getPackagingPlan() {
577:                try {
578:                    JarPackagerInvocationDefinition lJarPackager = new JarPackagerInvocationDefinition(
579:                            getOwnerTask());
580:                    lJarPackager.setDestFileName(mDestinationArchiveName);
581:                    // There may be some additional files to include
582:                    lJarPackager.addFileSetIncludes(getAdditionalFiles());
583:
584:                    // Iterate through stored generations and do it.
585:                    for (Iterator lImplementationsIterator = mGeneratedImplementationsToInclude
586:                            .iterator(); lImplementationsIterator.hasNext();) {
587:                        BusinessServiceGeneratedImplementationDefinition lBusinessServiceGeneratedImplementationDefinition = (BusinessServiceGeneratedImplementationDefinition) lImplementationsIterator
588:                                .next();
589:                        String[] lJarClassIncludes = lBusinessServiceGeneratedImplementationDefinition
590:                                .getJarClassIncludes();
591:                        if (lJarClassIncludes != null
592:                                && lJarClassIncludes.length > 0)
593:                            lJarPackager.addClassIncludes(lJarClassIncludes);
594:                    }
595:                    for (Iterator lImplementationsIterator = mDomainSupportImplementationsToInclude
596:                            .iterator(); lImplementationsIterator.hasNext();) {
597:                        BusinessServiceDomainSupportImplementationDefinition lBusinessServiceDomainSupportImplementationDefinition = (BusinessServiceDomainSupportImplementationDefinition) lImplementationsIterator
598:                                .next();
599:                        String[] lJarClassIncludes = lBusinessServiceDomainSupportImplementationDefinition
600:                                .getJarClassIncludes();
601:                        if (lJarClassIncludes != null
602:                                && lJarClassIncludes.length > 0)
603:                            lJarPackager.addClassIncludes(lJarClassIncludes);
604:                    }
605:                    for (Iterator lProxiesIterator = mServiceProxiesToInclude
606:                            .iterator(); lProxiesIterator.hasNext();) {
607:                        IncludeBusinessServiceProxyDefinition lServiceProxyDefinition = (IncludeBusinessServiceProxyDefinition) lProxiesIterator
608:                                .next();
609:                        String[] lJarClassIncludes = lServiceProxyDefinition
610:                                .getJarClassIncludes();
611:                        if (lJarClassIncludes != null
612:                                && lJarClassIncludes.length > 0)
613:                            lJarPackager.addClassIncludes(lJarClassIncludes);
614:                    }
615:                    for (Iterator lDomainImplementationsIterator = mDomainImplementationsToInclude
616:                            .iterator(); lDomainImplementationsIterator
617:                            .hasNext();) {
618:                        IncludeDomainImplementationDefinition lIncludeDomainDefinition = (IncludeDomainImplementationDefinition) lDomainImplementationsIterator
619:                                .next();
620:                        String[] lJarClassIncludes = lIncludeDomainDefinition
621:                                .getJarClassIncludes();
622:                        if (lJarClassIncludes != null
623:                                && lJarClassIncludes.length > 0)
624:                            lJarPackager.addClassIncludes(lJarClassIncludes);
625:                    }
626:                    for (Iterator lStorageImplementationsIterator = mStorageImplementationsToInclude
627:                            .iterator(); lStorageImplementationsIterator
628:                            .hasNext();) {
629:                        IncludeStorageImplementationDefinition lIncludeStorageDefinition = (IncludeStorageImplementationDefinition) lStorageImplementationsIterator
630:                                .next();
631:                        String[] lJarClassIncludes = lIncludeStorageDefinition
632:                                .getJarClassIncludes();
633:                        if (lJarClassIncludes != null
634:                                && lJarClassIncludes.length > 0)
635:                            lJarPackager.addClassIncludes(lJarClassIncludes);
636:                    }
637:                    // Handcoded are always last - just in case they use some of the generated stuff
638:                    for (Iterator lImplementationsIterator = mHandcodedImplementationsToInclude
639:                            .iterator(); lImplementationsIterator.hasNext();) {
640:                        IncludeBusinessServiceHandcodedImplementationDefinition lBusinessServiceHandcodedImplementationDefinition = (IncludeBusinessServiceHandcodedImplementationDefinition) lImplementationsIterator
641:                                .next();
642:                        String[] lJarClassIncludes = lBusinessServiceHandcodedImplementationDefinition
643:                                .getJarClassIncludes();
644:                        if (lJarClassIncludes != null
645:                                && lJarClassIncludes.length > 0)
646:                            lJarPackager.addClassIncludes(lJarClassIncludes);
647:                    }
648:                    // Return what we have		
649:                    return new ToolInvocationDefinition[] { lJarPackager };
650:                } catch (BSException e) {
651:                    throw new BuildException(
652:                            "Caught exception while generating packaging plan. "
653:                                    + e.getMessage());
654:                }
655:            }
656:        }
w___w___w.__j__a_v__a_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.