Source Code Cross Referenced for DataDictionaryModuleDefinition.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.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.Set;
024:
025:        import javax.jmi.reflect.JmiException;
026:
027:        import org.apache.tools.ant.BuildException;
028:
029:        import com.metaboss.enterprise.bs.BSException;
030:        import com.metaboss.sdlctools.applications.anttasks.builder.MetaBossBuilderTask;
031:        import com.metaboss.sdlctools.applications.anttasks.builder.ModuleDefinition;
032:        import com.metaboss.sdlctools.applications.anttasks.builder.ToolInvocationDefinition;
033:        import com.metaboss.sdlctools.applications.anttasks.builder.modules.subelements.IncludeAdapterDefinition;
034:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.CoreCodeGeneratorInvocationDefinition;
035:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.JarPackagerInvocationDefinition;
036:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.JavaCompilerInvocationDefinitionUtils;
037:        import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
038:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
039:        import com.metaboss.sdlctools.models.metabossmodel.designlibrarymodel.DesignLibrary;
040:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
041:        import com.metaboss.sdlctools.services.codegeneration.CodeGenerationStylesheetAccessor;
042:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STDataDictionaryStylesheet;
043:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STDesignLibraryStylesheet;
044:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEnterpriseStylesheet;
045:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STSystemStylesheet;
046:        import com.metaboss.util.StringUtils;
047:
048:        /** The definition of how to build system interface module */
049:        public class DataDictionaryModuleDefinition extends ModuleDefinition {
050:            // Initialise metadata for supplying in the constructor
051:            private static ElementMetadata sElementMetadata = new ElementMetadata();
052:            static {
053:                sElementMetadata.ElementTypeName = "DataDictionaryModule";
054:                sElementMetadata.SupportsModelElementRefs = true;
055:                sElementMetadata.AllowedModelElementTypes = new Class[] {
056:                        Enterprise.class,
057:                        com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System.class,
058:                        DesignLibrary.class, DataDictionary.class };
059:            }
060:            private Set mDataDictionariesToDo = new HashSet();
061:            private String mDestinationArchiveName = null;
062:            private List mIncludedAdapters = new ArrayList();
063:
064:            /** The only available constructor */
065:            public DataDictionaryModuleDefinition(MetaBossBuilderTask pOwnerTask) {
066:                super (pOwnerTask, sElementMetadata);
067:            }
068:
069:            /** The special creator asking to build BusinessServiceAdapterDefinition */
070:            public IncludeAdapterDefinition createIncludeAdapter() {
071:                IncludeAdapterDefinition lAdapterDefinition = new IncludeAdapterDefinition(
072:                        this );
073:                mIncludedAdapters.add(lAdapterDefinition);
074:                return lAdapterDefinition;
075:            }
076:
077:            /** Called when initialisation of parameters has been completed and generation is about to commence */
078:            public void completeInitialisation() throws BuildException {
079:                try {
080:                    // Work on included elements
081:                    ModelElement[] lIncludedModelElements = getIncludedModelElements();
082:                    // First collect list of al domains to generate implementations for
083:                    for (int lElementsIndex = 0; lElementsIndex < lIncludedModelElements.length; lElementsIndex++) {
084:                        ModelElement lIncludedModelElement = lIncludedModelElements[lElementsIndex];
085:                        mDataDictionariesToDo
086:                                .addAll(Arrays
087:                                        .asList(getOwnerTask()
088:                                                .findModelElementsByXPath(
089:                                                        lIncludedModelElement,
090:                                                        "descendant-or-self::DataDictionary",
091:                                                        new Class[] { DataDictionary.class })));
092:                    }
093:
094:                    // Work on the module name
095:                    String lModuleName = getModuleName();
096:                    if (lModuleName == null) {
097:                        ModelElement lRootModelElement = getRootModelElement();
098:                        if (lRootModelElement instanceof  Enterprise) {
099:                            // Set up module name for the domain
100:                            STEnterpriseStylesheet lEntepriseStylesheet = CodeGenerationStylesheetAccessor
101:                                    .getEnterpriseStylesheet(lRootModelElement
102:                                            .getName());
103:                            lModuleName = lEntepriseStylesheet
104:                                    .getDataDictionaryModuleName();
105:                        } else if (lRootModelElement instanceof  com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) {
106:                            // Set up module name for the system
107:                            STSystemStylesheet lSystemStylesheet = CodeGenerationStylesheetAccessor
108:                                    .getSystemStylesheet(lRootModelElement
109:                                            .getRef());
110:                            lModuleName = lSystemStylesheet
111:                                    .getDataDictionaryModuleName();
112:                        }
113:                        if (lRootModelElement instanceof  DesignLibrary) {
114:                            // Set up module name for the DesignLibrary
115:                            STDesignLibraryStylesheet lDesignLibraryStylesheet = CodeGenerationStylesheetAccessor
116:                                    .getDesignLibraryStylesheet(lRootModelElement
117:                                            .getRef());
118:                            lModuleName = lDesignLibraryStylesheet
119:                                    .getDataDictionaryModuleName();
120:                        } else {
121:                            // We are given a data dictionary
122:                            STDataDictionaryStylesheet lDataDictionaryStylesheet = CodeGenerationStylesheetAccessor
123:                                    .getDataDictionaryStylesheet(lRootModelElement
124:                                            .getRef());
125:                            lModuleName = lDataDictionaryStylesheet
126:                                    .getDataDictionaryModuleName();
127:                        }
128:                    }
129:                    // We now have a automatically generated modules name. Se if we need to use it or the explicit one
130:                    StringBuffer lModuleNameBuffer = new StringBuffer(
131:                            lModuleName);
132:                    // Finish building the archive name
133:                    String lVersionToken = getOwnerTask().getVersionToken();
134:                    if (lVersionToken != null) {
135:                        lModuleNameBuffer.append("_");
136:                        lModuleNameBuffer.append(lVersionToken);
137:                    }
138:                    lModuleNameBuffer.append(".jar");
139:                    mDestinationArchiveName = lModuleNameBuffer.toString();
140:
141:                    // Need to complete initialisation of the servicemodule adapters and verify that all adapter implementations are associated with the included servicemodules
142:                    for (Iterator lAdaptersIterator = mIncludedAdapters
143:                            .iterator(); lAdaptersIterator.hasNext();) {
144:                        IncludeAdapterDefinition lIncludedAdapterDefinition = (IncludeAdapterDefinition) lAdaptersIterator
145:                                .next();
146:                        lIncludedAdapterDefinition
147:                                .setDefaultRootModelElement(getRootModelElement());
148:                        lIncludedAdapterDefinition.completeInitialisation();
149:                        DataDictionary[] lIncludedDataDictionaries = lIncludedAdapterDefinition
150:                                .getIncludedDataDictionaries();
151:                        for (int i = 0; i < lIncludedDataDictionaries.length; i++) {
152:                            DataDictionary lIncludedDataDictionary = lIncludedDataDictionaries[i];
153:                            if (!mDataDictionariesToDo
154:                                    .contains(lIncludedDataDictionary))
155:                                throw new BuildException(
156:                                        "The <IncludeAdapter> subelement must refer to the DataDictionary referenced in the parent <"
157:                                                + getElementMetadata().ElementTypeName
158:                                                + "> element.");
159:                        }
160:                    }
161:                } catch (JmiException e) {
162:                    throw new BuildException(
163:                            "Caught exception while preparing to build module. "
164:                                    + e.getMessage());
165:                } catch (BSException e) {
166:                    throw new BuildException(
167:                            "Caught exception while preparing to build module. "
168:                                    + e.getMessage());
169:                }
170:            }
171:
172:            // Returns plan to invoke any number of code generators necessary to build the module  
173:            public ToolInvocationDefinition[] getGenerationPlan() {
174:                List lInvocations = new ArrayList();
175:                for (Iterator lDataDictionariesIterator = mDataDictionariesToDo
176:                        .iterator(); lDataDictionariesIterator.hasNext();) {
177:                    DataDictionary lDataDictionary = (DataDictionary) lDataDictionariesIterator
178:                            .next();
179:                    // Generate system core
180:                    CoreCodeGeneratorInvocationDefinition lCoreGeneratorInvocationDefinition = new CoreCodeGeneratorInvocationDefinition(
181:                            getOwnerTask());
182:                    lCoreGeneratorInvocationDefinition
183:                            .setDataDictionaryRef(lDataDictionary.getRef());
184:                    lInvocations.add(lCoreGeneratorInvocationDefinition);
185:                    // May need to generate adapters
186:                    for (Iterator lAdaptersIterator = mIncludedAdapters
187:                            .iterator(); lAdaptersIterator.hasNext();) {
188:                        IncludeAdapterDefinition lAdapterDefinition = (IncludeAdapterDefinition) lAdaptersIterator
189:                                .next();
190:                        ToolInvocationDefinition[] lToolInvocations = lAdapterDefinition
191:                                .getGenerationPlan();
192:                        if (lToolInvocations != null
193:                                && lToolInvocations.length > 0)
194:                            lInvocations
195:                                    .addAll(Arrays.asList(lToolInvocations));
196:                    }
197:                }
198:                // Return what we have		
199:                return (ToolInvocationDefinition[]) lInvocations
200:                        .toArray(new ToolInvocationDefinition[lInvocations
201:                                .size()]);
202:            }
203:
204:            // Returns tasks to invoke any number of compilers necessary to build the module  
205:            public ToolInvocationDefinition[] getCompilationPlan() {
206:                try {
207:                    List lInvocations = new ArrayList();
208:                    for (Iterator lDataDictionariesIterator = mDataDictionariesToDo
209:                            .iterator(); lDataDictionariesIterator.hasNext();) {
210:                        DataDictionary lDataDictionary = (DataDictionary) lDataDictionariesIterator
211:                                .next();
212:                        if (getOwnerTask().getTypesSrcDir() != null) {
213:                            // Compile custom enterprise types
214:                            lInvocations
215:                                    .add(JavaCompilerInvocationDefinitionUtils
216:                                            .createForCustomDataDictionaryTypes(
217:                                                    this , lDataDictionary));
218:                        }
219:                        // Compile generated enterprise types
220:                        lInvocations.add(JavaCompilerInvocationDefinitionUtils
221:                                .createForDataDictionaryTypes(this ,
222:                                        lDataDictionary));
223:
224:                        // May need to compile adapters
225:                        for (Iterator lAdaptersIterator = mIncludedAdapters
226:                                .iterator(); lAdaptersIterator.hasNext();) {
227:                            IncludeAdapterDefinition lAdapterDefinition = (IncludeAdapterDefinition) lAdaptersIterator
228:                                    .next();
229:                            ToolInvocationDefinition[] lToolInvocations = lAdapterDefinition
230:                                    .getCompilationPlan();
231:                            if (lToolInvocations != null
232:                                    && lToolInvocations.length > 0)
233:                                lInvocations.addAll(Arrays
234:                                        .asList(lToolInvocations));
235:                        }
236:                    }
237:                    // Return what we have		
238:                    return (ToolInvocationDefinition[]) lInvocations
239:                            .toArray(new ToolInvocationDefinition[lInvocations
240:                                    .size()]);
241:                } catch (BSException e) {
242:                    throw new BuildException(
243:                            "Caught exception while generating packaging plan. "
244:                                    + e.getMessage());
245:                }
246:            }
247:
248:            // Returns tasks to invoke any number of packagers necessary to build the module  
249:            public ToolInvocationDefinition[] getPackagingPlan()
250:                    throws BuildException {
251:                try {
252:                    JarPackagerInvocationDefinition lJarPackager = new JarPackagerInvocationDefinition(
253:                            getOwnerTask());
254:                    lJarPackager.setDestFileName(mDestinationArchiveName);
255:                    // There may be some additional files to include
256:                    lJarPackager.addFileSetIncludes(getAdditionalFiles());
257:
258:                    for (Iterator lDataDictionariesIterator = mDataDictionariesToDo
259:                            .iterator(); lDataDictionariesIterator.hasNext();) {
260:                        DataDictionary lDataDictionary = (DataDictionary) lDataDictionariesIterator
261:                                .next();
262:                        STDataDictionaryStylesheet lDataDictionaryStylesheet = CodeGenerationStylesheetAccessor
263:                                .getDataDictionaryStylesheet(lDataDictionary);
264:                        String lClassSubdirectory = StringUtils.replace(
265:                                lDataDictionaryStylesheet.getPackageName(),
266:                                ".", File.separator);
267:                        lJarPackager.addClassInclude(lClassSubdirectory
268:                                + File.separator + "*.class");
269:                        lJarPackager.addClassInclude(lClassSubdirectory
270:                                + File.separator + "**" + File.separator
271:                                + "*.class");
272:                        lJarPackager.addGensrcInclude(lClassSubdirectory
273:                                + File.separator + "*.properties");
274:                        lJarPackager.addGensrcInclude(lClassSubdirectory
275:                                + File.separator + "**" + File.separator
276:                                + "*.properties");
277:
278:                        // May need to package module adapters
279:                        for (Iterator lAdaptersIterator = mIncludedAdapters
280:                                .iterator(); lAdaptersIterator.hasNext();) {
281:                            IncludeAdapterDefinition lAdapterDefinition = (IncludeAdapterDefinition) lAdaptersIterator
282:                                    .next();
283:                            String[] lJarClassIncludes = lAdapterDefinition
284:                                    .getJarClassIncludes();
285:                            if (lJarClassIncludes != null
286:                                    && lJarClassIncludes.length > 0)
287:                                lJarPackager
288:                                        .addClassIncludes(lJarClassIncludes);
289:                            String[] lJarSourceIncludes = lAdapterDefinition
290:                                    .getJarSourceIncludes();
291:                            if (lJarSourceIncludes != null
292:                                    && lJarSourceIncludes.length > 0)
293:                                lJarPackager
294:                                        .addGensrcIncludes(lJarSourceIncludes);
295:                        }
296:                    }
297:                    // Return what we have		
298:                    return new ToolInvocationDefinition[] { lJarPackager };
299:                } catch (BSException e) {
300:                    throw new BuildException(
301:                            "Caught exception while generating packaging plan. "
302:                                    + e.getMessage());
303:                }
304:            }
305:        }
ww___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.