Source Code Cross Referenced for WebServicesServerModuleDefinition.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) 


0001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
0002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
0003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
0004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
0005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
0006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
0008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
0011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
0012:        // POSSIBILITY OF SUCH DAMAGE.
0013:        //
0014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
0015:        package com.metaboss.sdlctools.applications.anttasks.builder.modules;
0016:
0017:        import java.io.File;
0018:        import java.util.ArrayList;
0019:        import java.util.Arrays;
0020:        import java.util.HashSet;
0021:        import java.util.Iterator;
0022:        import java.util.List;
0023:        import java.util.Set;
0024:
0025:        import javax.jmi.reflect.JmiException;
0026:
0027:        import org.apache.tools.ant.BuildException;
0028:        import org.apache.tools.ant.types.FileSet;
0029:        import org.apache.tools.ant.types.Path;
0030:        import org.apache.tools.ant.types.ZipFileSet;
0031:
0032:        import com.metaboss.enterprise.bs.BSException;
0033:        import com.metaboss.sdlctools.applications.anttasks.builder.MetaBossBuilderTask;
0034:        import com.metaboss.sdlctools.applications.anttasks.builder.ModuleDefinition;
0035:        import com.metaboss.sdlctools.applications.anttasks.builder.ToolInvocationDefinition;
0036:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.AntCopyInvocationDefinition;
0037:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.AntDeleteInvocationDefinition;
0038:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.AntMkdirInvocationDefinition;
0039:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.AntTextReplaceInvocationDefinition;
0040:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.AntWarInvocationDefinition;
0041:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.GenericGeneratorInvocationDefinition;
0042:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.JavaCompilerInvocationDefinition;
0043:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.WSCompileInvocationDefinition;
0044:        import com.metaboss.sdlctools.applications.anttasks.builder.tools.WSDeployInvocationDefinition;
0045:        import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
0046:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.AbstractNamespace;
0047:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
0048:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Namespace;
0049:        import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Structure;
0050:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
0051:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
0052:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
0053:        import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
0054:        import com.metaboss.sdlctools.services.codegeneration.CodeGenerationStylesheetAccessor;
0055:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STDataDictionaryStylesheet;
0056:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STEnterpriseStylesheet;
0057:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STNamespaceStylesheet;
0058:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STServiceStylesheet;
0059:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STServicemoduleStylesheet;
0060:        import com.metaboss.sdlctools.services.codegenerationstylesheet.STSystemStylesheet;
0061:        import com.metaboss.util.DirectoryUtils;
0062:
0063:        /** The definition of how to build the web services server module.
0064:         *<p>This module definition supports following attributes:
0065:         *<table border="1" cellpadding="2" cellspacing="0">
0066:         *  <tr>
0067:         *    <td valign="top">type</td>
0068:         *    <td valign="top">This optional attribute contains the name of the desired type of web services implementation.
0069:         *    Can be 'doc/literal' or 'rpc/encoded'. Default is 'rpc/encoded'.
0070:         *    </td>
0071:         *  </tr>
0072:         * </table>
0073:         * </p>
0074:         */
0075:        // TODO: Review when jwsdp latter than 1.5 comes out and hopefully fixes this problem
0076:        // Note that at the moment this generator has to deal with the ugly wscompile bug. Details as follows
0077:        // 1. Bug details.
0078:        // The WSCOMPILE utility generates code "too large" for the java compiler to compile.
0079:        // We have failed this bug with jax-rpc group. See https://jax-rpc.dev.java.net/issues/show_bug.cgi?id=18 for more
0080:        // details.
0081:        // 2. Solution is to generate class with exact same interface, but smarter implementation (the size of code in ours does not
0082:        // depend on the size of the wsdl definition.
0083:        // 3. Additional problem is that wscompile does not seem to allow "generate but do not compile" option. It also
0084:        // overwrites already generated files. In order to deal with that this file does the following.
0085:        //   a) Generate files, which MetaBoss is expected to generate
0086:        //   b) Run wscompile and ignore possible failure.
0087:        //   c) Generate files which wscompile generates incorrectly
0088:        //   d) Run java compiler
0089:        public class WebServicesServerModuleDefinition extends ModuleDefinition {
0090:            // Initialise metadata for supplying in the constructor
0091:            private static ElementMetadata sElementMetadata = new ElementMetadata();
0092:            static {
0093:                sElementMetadata.ElementTypeName = "WebServicesServerModule";
0094:                sElementMetadata.SupportsModelElementRefs = true;
0095:                sElementMetadata.AllowedModelElementTypes = new Class[] {
0096:                        Enterprise.class,
0097:                        com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System.class,
0098:                        Servicemodule.class, Service.class };
0099:            }
0100:            private Set mServicesToDo = new HashSet();
0101:            private Set mServicemodulesToDo = new HashSet(); // Servicemodules - owners of the services we need to do
0102:            private Set mExternalServicemodulesToDo = new HashSet(); // Servicemodules we need to include the types from
0103:            private Set mExternalNamespacesToDo = new HashSet(); // DataDictionaries we need to include the types from
0104:            private String mDestinationArchiveName = null;
0105:            private String mTempDirectoryName = null;
0106:            // We need to preserve the files which may potentially be overridden by others
0107:            private String mPrivateWorkDirectoryName = null;
0108:            // We need to have a content assembly area
0109:            private String mContentRootDirectoryName = null;
0110:
0111:            private List mAdditionalClasses = new ArrayList();
0112:            private List mAdditionalLibs = new ArrayList();
0113:
0114:            private List mIncludedServicemoduleAdapters = new ArrayList();
0115:            private List mIncludedServiceProxies = new ArrayList();
0116:
0117:            private static final String sType_DocLiteral = "doc/literal";
0118:            private static final String sType_RpcEncoded = "rpc/encoded";
0119:            private String mType = sType_RpcEncoded;
0120:            private String mWebservicesNamespacePrefix = null;
0121:
0122:            /** The only available constructor */
0123:            public WebServicesServerModuleDefinition(
0124:                    MetaBossBuilderTask pOwnerTask) {
0125:                super (pOwnerTask, sElementMetadata);
0126:            }
0127:
0128:            // The setter for the "type" attribute
0129:            public void setType(String pType) {
0130:                if (pType.equals(sType_DocLiteral) == false
0131:                        && pType.equals(sType_RpcEncoded) == false)
0132:                    throw new BuildException(
0133:                            "The 'type' attribute can only be set to '"
0134:                                    + sType_DocLiteral + "' or '"
0135:                                    + sType_RpcEncoded + "'.");
0136:                mType = pType;
0137:            }
0138:
0139:            // The getter for the "type" attribute
0140:            public String getType() {
0141:                return mType;
0142:            }
0143:
0144:            // The setter for the "WebservicesNamespacePrefix" attribute
0145:            public void setWebservicesNamespacePrefix(
0146:                    String pWebservicesNamespacePrefix) {
0147:                mWebservicesNamespacePrefix = pWebservicesNamespacePrefix;
0148:            }
0149:
0150:            // The getter for the "WebservicesNamespacePrefix" attribute
0151:            public String getWebservicesNamespacePrefix() {
0152:                return mWebservicesNamespacePrefix;
0153:            }
0154:
0155:            // Adds custom files to the classes area of the war file
0156:            public void addClasses(ZipFileSet pAdditionalSet) {
0157:                mAdditionalClasses.add(pAdditionalSet);
0158:            }
0159:
0160:            // Adds custom files to the lib area of the war file
0161:            public void addLib(ZipFileSet pAdditionalSet) {
0162:                mAdditionalLibs.add(pAdditionalSet);
0163:            }
0164:
0165:            /** Called when initialisation of parameters has been completed and generation is about to commence */
0166:            public void completeInitialisation() throws BuildException {
0167:                try {
0168:                    // This task has to use temporary directory - generate the name now
0169:                    mTempDirectoryName = DirectoryUtils
0170:                            .getUniqueTempDirectoryAbsolutePath();
0171:                    // We need to preserve the files which may potentially be overridden by others
0172:                    mPrivateWorkDirectoryName = mTempDirectoryName + "/Workdir";
0173:                    // We need to have a content assembly area
0174:                    mContentRootDirectoryName = mTempDirectoryName + "/Content";
0175:
0176:                    // Work on included elements
0177:                    ModelElement[] lIncludedModelElements = getIncludedModelElements();
0178:                    // First collect list of all elements to generate implementations for
0179:                    for (int lElementsIndex = 0; lElementsIndex < lIncludedModelElements.length; lElementsIndex++) {
0180:                        ModelElement lIncludedModelElement = lIncludedModelElements[lElementsIndex];
0181:                        mServicesToDo.addAll(Arrays.asList(getOwnerTask()
0182:                                .findModelElementsByXPath(
0183:                                        lIncludedModelElement,
0184:                                        "descendant-or-self::Service",
0185:                                        new Class[] { Service.class })));
0186:                    }
0187:                    // Now collect the list of external and internal servicemodules
0188:                    // Internal is the one where we have to generate services as well as types
0189:                    // External is the one where we have to generate only types
0190:                    {
0191:                        for (Iterator lServicesIterator = mServicesToDo
0192:                                .iterator(); lServicesIterator.hasNext();) {
0193:                            Service lService = (Service) lServicesIterator
0194:                                    .next();
0195:                            mServicemodulesToDo
0196:                                    .add(lService.getServicemodule()); // Types would have been generated for this servicemodule already
0197:                            for (Iterator lCombinedTypesIterator = lService
0198:                                    .getCombinedTypes().iterator(); lCombinedTypesIterator
0199:                                    .hasNext();) {
0200:                                ModelElement lType = (ModelElement) lCombinedTypesIterator
0201:                                        .next();
0202:                                if (lType instanceof  Structure) {
0203:                                    Structure lStructureType = (Structure) lType;
0204:                                    Servicemodule lServicemodule = lStructureType
0205:                                            .getServicemodule();
0206:                                    AbstractNamespace lNamespace = lStructureType
0207:                                            .getNamespace();
0208:                                    if (lServicemodule != null)
0209:                                        mExternalServicemodulesToDo
0210:                                                .add(lServicemodule);
0211:                                    else if (lNamespace != null)
0212:                                        mExternalNamespacesToDo.add(lNamespace);
0213:                                } else if (lType instanceof  Message) {
0214:                                    Message lMessageType = (Message) lType;
0215:                                    Servicemodule lServicemodule = lMessageType
0216:                                            .getServicemodule();
0217:                                    AbstractNamespace lNamespace = lMessageType
0218:                                            .getNamespace();
0219:                                    if (lServicemodule != null)
0220:                                        mExternalServicemodulesToDo
0221:                                                .add(lServicemodule);
0222:                                    else if (lNamespace != null)
0223:                                        mExternalNamespacesToDo.add(lNamespace);
0224:                                }
0225:                            }
0226:                        }
0227:                        // Remove all servicemodules already catered for  
0228:                        mExternalServicemodulesToDo
0229:                                .removeAll(mServicemodulesToDo);
0230:                    }
0231:
0232:                    // Work on the module name
0233:                    String lModuleName = getModuleName();
0234:                    if (lModuleName == null) {
0235:                        ModelElement lRootModelElement = getRootModelElement();
0236:                        if (lRootModelElement instanceof  Enterprise) {
0237:                            // Set up module name for the domain
0238:                            STEnterpriseStylesheet lEntepriseStylesheet = CodeGenerationStylesheetAccessor
0239:                                    .getEnterpriseStylesheet(lRootModelElement
0240:                                            .getName());
0241:                            lModuleName = lEntepriseStylesheet
0242:                                    .getWebServicesServerModuleName();
0243:                        } else if (lRootModelElement instanceof  com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) {
0244:                            // Set up module name for the system
0245:                            STSystemStylesheet lSystemStylesheet = CodeGenerationStylesheetAccessor
0246:                                    .getSystemStylesheet(lRootModelElement
0247:                                            .getRef());
0248:                            lModuleName = lSystemStylesheet
0249:                                    .getWebServicesServerModuleName();
0250:                        } else {
0251:                            // We are given a servicemodule
0252:                            STServicemoduleStylesheet lServicemodulesStylesheet = CodeGenerationStylesheetAccessor
0253:                                    .getServicemoduleStylesheet(lRootModelElement
0254:                                            .getRef());
0255:                            lModuleName = lServicemodulesStylesheet
0256:                                    .getWebServicesServerModuleName();
0257:                        }
0258:                    }
0259:                    // We now have a automatically generated modules name. Se if we need to use it or the explicit one
0260:                    StringBuffer lModuleNameBuffer = new StringBuffer(
0261:                            lModuleName);
0262:                    // Finish building the archive name
0263:                    String lVersionToken = getOwnerTask().getVersionToken();
0264:                    if (lVersionToken != null) {
0265:                        lModuleNameBuffer.append("_");
0266:                        lModuleNameBuffer.append(lVersionToken);
0267:                    }
0268:                    lModuleNameBuffer.append(".war");
0269:                    mDestinationArchiveName = lModuleNameBuffer.toString();
0270:
0271:                    // All filesets listed in additional classes and additional libs will also have to be included in the compileclasspath
0272:                    if (mAdditionalClasses.isEmpty() == false
0273:                            || mAdditionalLibs.isEmpty() == false) {
0274:                        Path lAdditionaCompileClasspath = createCompileClasspath();
0275:                        for (Iterator lAdditionalClassesIterator = mAdditionalClasses
0276:                                .iterator(); lAdditionalClassesIterator
0277:                                .hasNext();) {
0278:                            ZipFileSet lFileSet = (ZipFileSet) lAdditionalClassesIterator
0279:                                    .next();
0280:                            lAdditionaCompileClasspath.addFileset(lFileSet);
0281:                        }
0282:                        for (Iterator lAdditionalLibsIterator = mAdditionalLibs
0283:                                .iterator(); lAdditionalLibsIterator.hasNext();) {
0284:                            ZipFileSet lFileSet = (ZipFileSet) lAdditionalLibsIterator
0285:                                    .next();
0286:                            lAdditionaCompileClasspath.addFileset(lFileSet);
0287:                        }
0288:                    }
0289:                } catch (JmiException e) {
0290:                    throw new BuildException(
0291:                            "Caught exception while preparing to build module. "
0292:                                    + e.getMessage());
0293:                } catch (BSException e) {
0294:                    throw new BuildException(
0295:                            "Caught exception while preparing to build module. "
0296:                                    + e.getMessage());
0297:                }
0298:            }
0299:
0300:            // Returns plan to invoke any number of code generators necessary to build the module  
0301:            public ToolInvocationDefinition[] getGenerationPlan() {
0302:                if (mServicesToDo.isEmpty())
0303:                    return new ToolInvocationDefinition[0];
0304:                List lInvocations = new ArrayList();
0305:                //TODO: We need to think how to best ensure that the system core is generated			
0306:                //		for (Iterator lServicesIterator = mServicesToDo.iterator();lServicesIterator.hasNext();)
0307:                //		{
0308:                //			Service lService = (Service)lServicesIterator.next();
0309:                //			Servicemodule lServicemodule = lService.getServicemodule();
0310:                //			com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = lServicemodule.getSystem();
0311:                //			Enterprise lEnterprise = lSystem.getEnterprise();
0312:                //			// Generate system core
0313:                //			SystemCoreGeneratorInvocationDefinition lSystemCoreGeneratorInvocationDefinition = new SystemCoreGeneratorInvocationDefinition(getOwnerTask());
0314:                //			lSystemCoreGeneratorInvocationDefinition.setRef(lSystem.getRef());
0315:                //			lInvocations.add(lSystemCoreGeneratorInvocationDefinition);
0316:                //			// Immediately compile data types because some other tools might use them
0317:                //			if (getOwnerTask().getTypesSrcDir() != null)
0318:                //			{
0319:                //				// Compile custom enterprise types
0320:                //				lInvocations.add(JavaCompilerInvocationDefinitionUtils.createForCustomEnterpriseTypes(this,lEnterprise));
0321:                //				// Compile ciustom generated system types
0322:                //				lInvocations.add(JavaCompilerInvocationDefinitionUtils.createForCustomSystemTypes(this,lServicemodule.getSystem()));
0323:                //			}
0324:                //			// Compile generated enterprise types
0325:                //			lInvocations.add(JavaCompilerInvocationDefinitionUtils.createForEnterpriseTypes(this,lEnterprise));
0326:                //			// Compile generated system types
0327:                //			lInvocations.add(JavaCompilerInvocationDefinitionUtils.createForSystemTypes(this,lServicemodule.getSystem()));
0328:                //		}
0329:
0330:                // We also need to generate types for the external servicemodules
0331:                if (mExternalServicemodulesToDo.isEmpty() == false
0332:                        || mExternalNamespacesToDo.isEmpty() == false) {
0333:                    Set lElementsSet = new HashSet();
0334:                    lElementsSet.addAll(mExternalServicemodulesToDo);
0335:                    lElementsSet.addAll(mExternalNamespacesToDo);
0336:
0337:                    // We have some external servicemodules we need to generate web service types for
0338:                    if (getType().equals(sType_RpcEncoded)) {
0339:                        // Main generator invocation
0340:                        GenericGeneratorInvocationDefinition lGenericGeneratorInvocationDefinition = new GenericGeneratorInvocationDefinition(
0341:                                getOwnerTask());
0342:                        lGenericGeneratorInvocationDefinition
0343:                                .setPlanName("implementation.enterprise.java.adapters.soap.tomcatjwsdp.rpcencoded");
0344:                        lGenericGeneratorInvocationDefinition
0345:                                .setModelElements(lElementsSet);
0346:                        if (mWebservicesNamespacePrefix != null)
0347:                            lGenericGeneratorInvocationDefinition
0348:                                    .addInvocationParameter(
0349:                                            "WebservicesNamespacePrefix",
0350:                                            mWebservicesNamespacePrefix);
0351:                        lInvocations.add(lGenericGeneratorInvocationDefinition);
0352:                    } else {
0353:                        // Main generator invocation
0354:                        GenericGeneratorInvocationDefinition lGenericGeneratorInvocationDefinition = new GenericGeneratorInvocationDefinition(
0355:                                getOwnerTask());
0356:                        lGenericGeneratorInvocationDefinition
0357:                                .setPlanName("implementation.enterprise.java.adapters.soap.tomcatjwsdp.docliteral");
0358:                        lGenericGeneratorInvocationDefinition
0359:                                .setModelElements(lElementsSet);
0360:                        if (mWebservicesNamespacePrefix != null)
0361:                            lGenericGeneratorInvocationDefinition
0362:                                    .addInvocationParameter(
0363:                                            "WebservicesNamespacePrefix",
0364:                                            mWebservicesNamespacePrefix);
0365:                        lInvocations.add(lGenericGeneratorInvocationDefinition);
0366:                    }
0367:                }
0368:
0369:                // We need to assemble content image in the temporary directory and run wscompile
0370:                {
0371:                    AntMkdirInvocationDefinition lMakeWorkDirInvocation = new AntMkdirInvocationDefinition(
0372:                            getOwnerTask(),
0373:                            "Create temporary working directory for the Web Services generation");
0374:                    lMakeWorkDirInvocation
0375:                            .setDirectoryPath(mPrivateWorkDirectoryName);
0376:                    lInvocations.add(lMakeWorkDirInvocation);
0377:                }
0378:
0379:                // Generation of the web service implies using the generic adapter for all services
0380:                {
0381:                    if (getType().equals(sType_RpcEncoded)) {
0382:                        GenericGeneratorInvocationDefinition lGenericGeneratorInvocationDefinition = new GenericGeneratorInvocationDefinition(
0383:                                getOwnerTask());
0384:                        lGenericGeneratorInvocationDefinition
0385:                                .setPlanName("implementation.enterprise.java.adapters.soap.tomcatjwsdp.rpcencoded");
0386:                        lGenericGeneratorInvocationDefinition
0387:                                .setModelElements(mServicesToDo);
0388:                        if (mWebservicesNamespacePrefix != null)
0389:                            lGenericGeneratorInvocationDefinition
0390:                                    .addInvocationParameter(
0391:                                            "WebservicesNamespacePrefix",
0392:                                            mWebservicesNamespacePrefix);
0393:                        lInvocations.add(lGenericGeneratorInvocationDefinition);
0394:                    } else {
0395:                        GenericGeneratorInvocationDefinition lGenericGeneratorInvocationDefinition = new GenericGeneratorInvocationDefinition(
0396:                                getOwnerTask());
0397:                        lGenericGeneratorInvocationDefinition
0398:                                .setPlanName("implementation.enterprise.java.adapters.soap.tomcatjwsdp.docliteral");
0399:                        lGenericGeneratorInvocationDefinition
0400:                                .setModelElements(mServicesToDo);
0401:                        if (mWebservicesNamespacePrefix != null)
0402:                            lGenericGeneratorInvocationDefinition
0403:                                    .addInvocationParameter(
0404:                                            "WebservicesNamespacePrefix",
0405:                                            mWebservicesNamespacePrefix);
0406:                        lInvocations.add(lGenericGeneratorInvocationDefinition);
0407:                    }
0408:                }
0409:                {
0410:                    // Copy files we want to preserve
0411:                    AntCopyInvocationDefinition lCopyInvocation = new AntCopyInvocationDefinition(
0412:                            getOwnerTask(),
0413:                            "Copy generated content into the private working directory for preservation");
0414:                    lCopyInvocation
0415:                            .setDestinationDirectoryPath(mPrivateWorkDirectoryName);
0416:                    lCopyInvocation.setSourceDirectoryPath(getOwnerTask()
0417:                            .getGenDir().getAbsolutePath());
0418:                    lCopyInvocation.addSourceInclude("web.xml");
0419:                    lCopyInvocation.addSourceInclude("jaxrpc-ri.xml");
0420:                    lInvocations.add(lCopyInvocation);
0421:                }
0422:
0423:                // Return what we have		
0424:                return (ToolInvocationDefinition[]) lInvocations
0425:                        .toArray(new ToolInvocationDefinition[lInvocations
0426:                                .size()]);
0427:            }
0428:
0429:            // Returns tasks to invoke any number of compilers necessary to build the module  
0430:            public ToolInvocationDefinition[] getCompilationPlan() {
0431:                if (mServicesToDo.isEmpty())
0432:                    return new ToolInvocationDefinition[0];
0433:                try {
0434:                    List lInvocations = new ArrayList();
0435:
0436:                    // Assemble content image in the temporary directory and run wscompile
0437:                    AntMkdirInvocationDefinition lMakeContentDirInvocation = new AntMkdirInvocationDefinition(
0438:                            getOwnerTask(),
0439:                            "Create temporary content image directory for the Web Services generation");
0440:                    lMakeContentDirInvocation
0441:                            .setDirectoryPath(mContentRootDirectoryName);
0442:                    lInvocations.add(lMakeContentDirInvocation);
0443:
0444:                    // First iterate through the external servicemodules and namespaces and copy type schemas
0445:                    for (Iterator lExternalServicemodulesIterator = mExternalServicemodulesToDo
0446:                            .iterator(); lExternalServicemodulesIterator
0447:                            .hasNext();) {
0448:                        Servicemodule lServicemodule = (Servicemodule) lExternalServicemodulesIterator
0449:                                .next();
0450:                        String lServicemoduleRef = lServicemodule.getRef();
0451:                        STServicemoduleStylesheet lServicemoduleStylesheet = CodeGenerationStylesheetAccessor
0452:                                .getServicemoduleStylesheet(lServicemodule);
0453:
0454:                        // Copy all files to the content image area
0455:                        AntCopyInvocationDefinition lCopyInvocation = new AntCopyInvocationDefinition(
0456:                                getOwnerTask(),
0457:                                "Copy generated content into the content image directory for the "
0458:                                        + lServicemoduleRef);
0459:                        lCopyInvocation
0460:                                .setDestinationDirectoryPath(mContentRootDirectoryName
0461:                                        + "/"
0462:                                        + lServicemoduleStylesheet
0463:                                                .getNamespaceURI());
0464:                        lCopyInvocation.setSourceDirectoryPath(getOwnerTask()
0465:                                .getGenDir().getAbsoluteFile()
0466:                                + "/"
0467:                                + lServicemoduleStylesheet
0468:                                        .getAdapterRootPackageDir()
0469:                                + "/soap/services/"
0470:                                + lServicemoduleStylesheet
0471:                                        .getSystemSubPackageName());
0472:                        lCopyInvocation
0473:                                .addSourceInclude("WebServicesTypes.xsd");
0474:                        lInvocations.add(lCopyInvocation);
0475:                    }
0476:                    for (Iterator lExternalNamespacesIterator = mExternalNamespacesToDo
0477:                            .iterator(); lExternalNamespacesIterator.hasNext();) {
0478:                        AbstractNamespace lAbstractNamespace = (AbstractNamespace) lExternalNamespacesIterator
0479:                                .next();
0480:                        if (lAbstractNamespace instanceof  DataDictionary) {
0481:                            DataDictionary lDataDictionary = (DataDictionary) lAbstractNamespace;
0482:                            String lDataDictionaryRef = lDataDictionary
0483:                                    .getRef();
0484:                            STDataDictionaryStylesheet lDataDictionaryStylesheet = CodeGenerationStylesheetAccessor
0485:                                    .getDataDictionaryStylesheet(lDataDictionary);
0486:
0487:                            // Copy all files to the content image area
0488:                            AntCopyInvocationDefinition lCopyInvocation = new AntCopyInvocationDefinition(
0489:                                    getOwnerTask(),
0490:                                    "Copy generated content into the content image directory for the "
0491:                                            + lDataDictionaryRef);
0492:                            lCopyInvocation
0493:                                    .setDestinationDirectoryPath(mContentRootDirectoryName
0494:                                            + "/"
0495:                                            + lDataDictionaryStylesheet
0496:                                                    .getNamespaceURI());
0497:                            if (lDataDictionary.getSystem() != null)
0498:                                lCopyInvocation
0499:                                        .setSourceDirectoryPath(getOwnerTask()
0500:                                                .getGenDir().getAbsoluteFile()
0501:                                                + "/"
0502:                                                + lDataDictionaryStylesheet
0503:                                                        .getAdapterRootPackageDir()
0504:                                                + "/soap/types");
0505:                            else
0506:                                lCopyInvocation
0507:                                        .setSourceDirectoryPath(getOwnerTask()
0508:                                                .getGenDir().getAbsoluteFile()
0509:                                                + "/"
0510:                                                + lDataDictionaryStylesheet
0511:                                                        .getAdapterRootPackageDir()
0512:                                                + "/soap/types/"
0513:                                                + lDataDictionaryStylesheet
0514:                                                        .getNormalisedName()
0515:                                                        .toLowerCase());
0516:                            lCopyInvocation
0517:                                    .addSourceInclude("WebServicesTypes.xsd");
0518:                            lInvocations.add(lCopyInvocation);
0519:                        } else if (lAbstractNamespace instanceof  Namespace) {
0520:                            Namespace lNamespace = (Namespace) lAbstractNamespace;
0521:                            DataDictionary lOwnerDataDictionary = lNamespace
0522:                                    .getOwnerDataDictionary();
0523:                            String lNamespaceRef = lNamespace.getRef();
0524:                            STNamespaceStylesheet lNamespaceStylesheet = CodeGenerationStylesheetAccessor
0525:                                    .getNamespaceStylesheet(lNamespace);
0526:                            STDataDictionaryStylesheet lOwnerDataDictionaryStylesheet = CodeGenerationStylesheetAccessor
0527:                                    .getDataDictionaryStylesheet(lOwnerDataDictionary);
0528:
0529:                            // Copy all files to the content image area
0530:                            AntCopyInvocationDefinition lCopyInvocation = new AntCopyInvocationDefinition(
0531:                                    getOwnerTask(),
0532:                                    "Copy generated content into the content image directory for the "
0533:                                            + lNamespaceStylesheet);
0534:                            lCopyInvocation
0535:                                    .setDestinationDirectoryPath(mContentRootDirectoryName
0536:                                            + "/"
0537:                                            + lNamespaceStylesheet
0538:                                                    .getNamespaceURI());
0539:                            if (lOwnerDataDictionary.getSystem() != null)
0540:                                lCopyInvocation
0541:                                        .setSourceDirectoryPath(getOwnerTask()
0542:                                                .getGenDir().getAbsoluteFile()
0543:                                                + "/"
0544:                                                + lOwnerDataDictionaryStylesheet
0545:                                                        .getAdapterRootPackageDir()
0546:                                                + "/soap/types/"
0547:                                                + lNamespaceStylesheet
0548:                                                        .getDictionarySubPackageName()
0549:                                                        .replace('.', '/'));
0550:                            else
0551:                                lCopyInvocation
0552:                                        .setSourceDirectoryPath(getOwnerTask()
0553:                                                .getGenDir().getAbsoluteFile()
0554:                                                + "/"
0555:                                                + lOwnerDataDictionaryStylesheet
0556:                                                        .getAdapterRootPackageDir()
0557:                                                + "/soap/types/"
0558:                                                + lOwnerDataDictionaryStylesheet
0559:                                                        .getNormalisedName()
0560:                                                        .toLowerCase()
0561:                                                + "/"
0562:                                                + lNamespaceStylesheet
0563:                                                        .getDictionarySubPackageName()
0564:                                                        .replace('.', '/'));
0565:                            lCopyInvocation
0566:                                    .addSourceInclude("WebServicesTypes.xsd");
0567:                            lInvocations.add(lCopyInvocation);
0568:                        }
0569:                    }
0570:
0571:                    // Now iterate through the services we need to do and copy type schemas as well as WSDLs
0572:                    for (Iterator lServicesIterator = mServicesToDo.iterator(); lServicesIterator
0573:                            .hasNext();) {
0574:                        Service lService = (Service) lServicesIterator.next();
0575:                        String lServiceRef = lService.getRef();
0576:                        Servicemodule lServicemodule = lService
0577:                                .getServicemodule();
0578:                        STServicemoduleStylesheet lServicemoduleStylesheet = CodeGenerationStylesheetAccessor
0579:                                .getServicemoduleStylesheet(lServicemodule);
0580:                        STServiceStylesheet lServiceStylesheet = CodeGenerationStylesheetAccessor
0581:                                .getServiceStylesheet(lService);
0582:
0583:                        // Copy all files to the content image area
0584:                        AntCopyInvocationDefinition lCopyInvocation = new AntCopyInvocationDefinition(
0585:                                getOwnerTask(),
0586:                                "Copy generated content into the content image directory for the "
0587:                                        + lServiceRef);
0588:                        lCopyInvocation
0589:                                .setDestinationDirectoryPath(mContentRootDirectoryName
0590:                                        + "/"
0591:                                        + lServicemoduleStylesheet
0592:                                                .getNamespaceURI());
0593:                        lCopyInvocation.setSourceDirectoryPath(getOwnerTask()
0594:                                .getGenDir().getAbsoluteFile()
0595:                                + "/"
0596:                                + lServicemoduleStylesheet
0597:                                        .getAdapterRootPackageDir()
0598:                                + "/soap/services/"
0599:                                + lServicemoduleStylesheet
0600:                                        .getSystemSubPackageName());
0601:                        lCopyInvocation
0602:                                .addSourceInclude("WebServicesTypes.xsd");
0603:                        lCopyInvocation.addSourceInclude(lServiceStylesheet
0604:                                .getNormalisedName()
0605:                                + ".wsdl");
0606:                        lCopyInvocation.addSourceInclude(lServiceStylesheet
0607:                                .getNormalisedName()
0608:                                + "_wscompileconfig.xml");
0609:                        lInvocations.add(lCopyInvocation);
0610:
0611:                        // Replace relative path with the absolute in the web services compile configuration file
0612:                        AntTextReplaceInvocationDefinition lTextReplaceInvocation = new AntTextReplaceInvocationDefinition(
0613:                                getOwnerTask(),
0614:                                "Replace relative content path with the absolute one for the "
0615:                                        + lServiceRef);
0616:                        lTextReplaceInvocation
0617:                                .setFile(mContentRootDirectoryName
0618:                                        + "/"
0619:                                        + lServicemoduleStylesheet
0620:                                                .getNamespaceURI()
0621:                                        + "/"
0622:                                        + lServiceStylesheet
0623:                                                .getNormalisedName()
0624:                                        + "_wscompileconfig.xml");
0625:                        lTextReplaceInvocation.setOldValue("location=\""
0626:                                + lServicemoduleStylesheet.getNamespaceURI());
0627:                        lTextReplaceInvocation.setNewValue("location=\""
0628:                                + mContentRootDirectoryName + "/"
0629:                                + lServicemoduleStylesheet.getNamespaceURI());
0630:                        lInvocations.add(lTextReplaceInvocation);
0631:
0632:                    }
0633:
0634:                    // Now run wscompile tool for all services we need to do
0635:                    for (Iterator lServicesIterator = mServicesToDo.iterator(); lServicesIterator
0636:                            .hasNext();) {
0637:                        Service lService = (Service) lServicesIterator.next();
0638:                        String lServiceRef = lService.getRef();
0639:                        Servicemodule lServicemodule = lService
0640:                                .getServicemodule();
0641:                        STServicemoduleStylesheet lServicemoduleStylesheet = CodeGenerationStylesheetAccessor
0642:                                .getServicemoduleStylesheet(lServicemodule);
0643:                        STServiceStylesheet lServiceStylesheet = CodeGenerationStylesheetAccessor
0644:                                .getServiceStylesheet(lService);
0645:
0646:                        // Run wscompile
0647:                        WSCompileInvocationDefinition lWSCompileInvocation = new WSCompileInvocationDefinition(
0648:                                getOwnerTask(),
0649:                                "Generate JAXRPC Web Service proxy for the "
0650:                                        + lServiceRef);
0651:                        lWSCompileInvocation.setIsServer(true);
0652:                        lWSCompileInvocation
0653:                                .setConfigFileLocation(mContentRootDirectoryName
0654:                                        + "/"
0655:                                        + lServicemoduleStylesheet
0656:                                                .getNamespaceURI()
0657:                                        + "/"
0658:                                        + lServiceStylesheet
0659:                                                .getNormalisedName()
0660:                                        + "_wscompileconfig.xml");
0661:                        lWSCompileInvocation
0662:                                .setModelFileLocation(mContentRootDirectoryName
0663:                                        + "/"
0664:                                        + lServicemoduleStylesheet
0665:                                                .getNamespaceURI()
0666:                                        + "/"
0667:                                        + lServiceStylesheet
0668:                                                .getNormalisedName()
0669:                                        + "_model.xml.gz");
0670:                        // Note that wscompile some times fails because it generates too large method body in the serializer registry
0671:                        // We can only fix that by ignoring the error and regenerating the file
0672:                        lWSCompileInvocation.setFailOnError(false);
0673:                        lInvocations.add(lWSCompileInvocation);
0674:                    }
0675:
0676:                    // Bug fix generator invocation
0677:                    // Generates alternative serialiser registry file because the one generated by JWSDP produces 'code too large' error for the big services
0678:                    if (getType().equals(sType_RpcEncoded)) {
0679:                        GenericGeneratorInvocationDefinition lGenericGeneratorInvocationDefinition = new GenericGeneratorInvocationDefinition(
0680:                                getOwnerTask());
0681:                        lGenericGeneratorInvocationDefinition
0682:                                .setPlanName("implementation.enterprise.java.adapters.soap.tomcatjwsdp.rpcencoded.bugfix");
0683:                        lGenericGeneratorInvocationDefinition
0684:                                .setModelElements(mServicesToDo);
0685:                        lGenericGeneratorInvocationDefinition
0686:                                .setExecutingAllOccurrences(true); // Neded to always execute this after the wscompile
0687:                        if (mWebservicesNamespacePrefix != null)
0688:                            lGenericGeneratorInvocationDefinition
0689:                                    .addInvocationParameter(
0690:                                            "WebservicesNamespacePrefix",
0691:                                            mWebservicesNamespacePrefix);
0692:                        lInvocations.add(lGenericGeneratorInvocationDefinition);
0693:
0694:                        // Copy all property files to the classes directory
0695:                        AntCopyInvocationDefinition lCopyInvocation = new AntCopyInvocationDefinition(
0696:                                getOwnerTask(),
0697:                                "Copy generated serializer registry property files into the classes directory");
0698:                        lCopyInvocation
0699:                                .setDestinationDirectoryPath(getOwnerTask()
0700:                                        .getClassDir().getAbsolutePath());
0701:                        lCopyInvocation.setSourceDirectoryPath(getOwnerTask()
0702:                                .getGenDir().getAbsolutePath());
0703:                        for (Iterator lServicesIterator = mServicesToDo
0704:                                .iterator(); lServicesIterator.hasNext();) {
0705:                            Service lService = (Service) lServicesIterator
0706:                                    .next();
0707:                            Servicemodule lServicemodule = lService
0708:                                    .getServicemodule();
0709:                            STServicemoduleStylesheet lServicemoduleStylesheet = CodeGenerationStylesheetAccessor
0710:                                    .getServicemoduleStylesheet(lServicemodule);
0711:                            STServiceStylesheet lServiceStylesheet = CodeGenerationStylesheetAccessor
0712:                                    .getServiceStylesheet(lService);
0713:                            lCopyInvocation
0714:                                    .addSourceInclude(lServicemoduleStylesheet
0715:                                            .getAdapterRootPackageDir()
0716:                                            + "/soap/services/"
0717:                                            + lServicemoduleStylesheet
0718:                                                    .getSystemSubPackageName()
0719:                                            + "/"
0720:                                            + lServiceStylesheet
0721:                                                    .getNormalisedName()
0722:                                                    .toLowerCase()
0723:                                            + "/"
0724:                                            + lServiceStylesheet
0725:                                                    .getNormalisedName()
0726:                                            + "WebService_SerializerRegistry.properties");
0727:                        }
0728:                        lCopyInvocation.setExecutingAllOccurrences(true); // Neded to always execute this after the wscompile
0729:                        lInvocations.add(lCopyInvocation);
0730:                    }
0731:
0732:                    // Compile stuff from the external servicemodules we depend on
0733:                    for (Iterator lExternalServicemodulesIterator = mExternalServicemodulesToDo
0734:                            .iterator(); lExternalServicemodulesIterator
0735:                            .hasNext();) {
0736:                        Servicemodule lServicemodule = (Servicemodule) lExternalServicemodulesIterator
0737:                                .next();
0738:                        STServicemoduleStylesheet lServicemoduleStylesheet = CodeGenerationStylesheetAccessor
0739:                                .getServicemoduleStylesheet(lServicemodule);
0740:                        //				 We need to think how to best ensure that the system core is generated			
0741:                        //				// Compile Servicemodule interface packages
0742:                        //				lInvocations.add(JavaCompilerInvocationDefinitionUtils.createForServicemoduleInterfaces(this,lServicemodule));
0743:                        // Compile Servicemodule Web Types package
0744:                        {
0745:                            JavaCompilerInvocationDefinition lCompiler = new JavaCompilerInvocationDefinition(
0746:                                    getOwnerTask(),
0747:                                    "Compile Web Service types for the "
0748:                                            + lServicemodule.getRef());
0749:                            lCompiler
0750:                                    .setClasspathName("MetaBossWebServiceCompileClasspath");
0751:                            Path lCompileClasspath = getCompileClasspath();
0752:                            if (lCompileClasspath != null)
0753:                                lCompiler
0754:                                        .setAdditionalClasspath(lCompileClasspath);
0755:                            lCompiler.setSourceRootDir(getOwnerTask()
0756:                                    .getGenDir());
0757:                            lCompiler.addSourceInclude(lServicemoduleStylesheet
0758:                                    .getAdapterRootPackageDir()
0759:                                    + "/soap/services/"
0760:                                    + lServicemoduleStylesheet
0761:                                            .getSystemSubPackageName()
0762:                                    + "/*.java");
0763:                            lInvocations.add(lCompiler);
0764:                        }
0765:                    }
0766:                    for (Iterator lExternalNamespacesIterator = mExternalNamespacesToDo
0767:                            .iterator(); lExternalNamespacesIterator.hasNext();) {
0768:                        AbstractNamespace lAbstractNamespace = (AbstractNamespace) lExternalNamespacesIterator
0769:                                .next();
0770:                        if (lAbstractNamespace instanceof  DataDictionary) {
0771:                            DataDictionary lDataDictionary = (DataDictionary) lAbstractNamespace;
0772:                            STDataDictionaryStylesheet lDataDictionaryStylesheet = CodeGenerationStylesheetAccessor
0773:                                    .getDataDictionaryStylesheet(lDataDictionary);
0774:                            // Compile DataDictionary Web Types package
0775:                            JavaCompilerInvocationDefinition lCompiler = new JavaCompilerInvocationDefinition(
0776:                                    getOwnerTask(),
0777:                                    "Compile Web Service types for the "
0778:                                            + lDataDictionary.getRef());
0779:                            lCompiler
0780:                                    .setClasspathName("MetaBossWebServiceCompileClasspath");
0781:                            Path lCompileClasspath = getCompileClasspath();
0782:                            if (lCompileClasspath != null)
0783:                                lCompiler
0784:                                        .setAdditionalClasspath(lCompileClasspath);
0785:                            lCompiler.setSourceRootDir(getOwnerTask()
0786:                                    .getGenDir());
0787:                            lCompiler
0788:                                    .addSourceInclude(lDataDictionaryStylesheet
0789:                                            .getAdapterRootPackageDir()
0790:                                            + "/soap/types/"
0791:                                            + (lDataDictionary.getSystem() == null ? (lDataDictionaryStylesheet
0792:                                                    .getNormalisedName()
0793:                                                    .toLowerCase() + "/")
0794:                                                    : "") + "*.java");
0795:                            lInvocations.add(lCompiler);
0796:                        } else if (lAbstractNamespace instanceof  Namespace) {
0797:                            Namespace lNamespace = (Namespace) lAbstractNamespace;
0798:                            DataDictionary lOwnerDataDictionary = lNamespace
0799:                                    .getOwnerDataDictionary();
0800:                            STNamespaceStylesheet lNamespaceStylesheet = CodeGenerationStylesheetAccessor
0801:                                    .getNamespaceStylesheet(lNamespace);
0802:                            STDataDictionaryStylesheet lOwnerDataDictionaryStylesheet = CodeGenerationStylesheetAccessor
0803:                                    .getDataDictionaryStylesheet(lOwnerDataDictionary);
0804:
0805:                            // Compile Namespace Web Types package
0806:                            JavaCompilerInvocationDefinition lCompiler = new JavaCompilerInvocationDefinition(
0807:                                    getOwnerTask(),
0808:                                    "Compile Web Service types for the "
0809:                                            + lNamespace.getRef());
0810:                            lCompiler
0811:                                    .setClasspathName("MetaBossWebServiceCompileClasspath");
0812:                            Path lCompileClasspath = getCompileClasspath();
0813:                            if (lCompileClasspath != null)
0814:                                lCompiler
0815:                                        .setAdditionalClasspath(lCompileClasspath);
0816:                            lCompiler.setSourceRootDir(getOwnerTask()
0817:                                    .getGenDir());
0818:                            lCompiler
0819:                                    .addSourceInclude(lOwnerDataDictionaryStylesheet
0820:                                            .getAdapterRootPackageDir()
0821:                                            + "/soap/types/"
0822:                                            + (lOwnerDataDictionary.getSystem() == null ? (lOwnerDataDictionaryStylesheet
0823:                                                    .getNormalisedName()
0824:                                                    .toLowerCase() + "/")
0825:                                                    : "")
0826:                                            + lNamespaceStylesheet
0827:                                                    .getDictionarySubPackageName()
0828:                                                    .replace('.', '/')
0829:                                            + "/*.java");
0830:                            lInvocations.add(lCompiler);
0831:                        }
0832:                    }
0833:                    // Compile stuff for the services and service modules involved
0834:                    for (Iterator lServicesIterator = mServicesToDo.iterator(); lServicesIterator
0835:                            .hasNext();) {
0836:                        Service lService = (Service) lServicesIterator.next();
0837:                        Servicemodule lServicemodule = lService
0838:                                .getServicemodule();
0839:                        STServicemoduleStylesheet lServicemoduleStylesheet = CodeGenerationStylesheetAccessor
0840:                                .getServicemoduleStylesheet(lServicemodule);
0841:                        STServiceStylesheet lServiceStylesheet = CodeGenerationStylesheetAccessor
0842:                                .getServiceStylesheet(lService);
0843:                        //				 We need to think how to best ensure that the system core is generated			
0844:                        //				// Compile Servicemodule interface packages
0845:                        //				lInvocations.add(JavaCompilerInvocationDefinitionUtils.createForServicemoduleInterfaces(this,lServicemodule));
0846:                        // Compile Servicemodule Web Types package
0847:                        {
0848:                            JavaCompilerInvocationDefinition lCompiler = new JavaCompilerInvocationDefinition(
0849:                                    getOwnerTask(),
0850:                                    "Compile Web Service types for the "
0851:                                            + lServicemodule.getRef());
0852:                            lCompiler
0853:                                    .setClasspathName("MetaBossWebServiceCompileClasspath");
0854:                            Path lCompileClasspath = getCompileClasspath();
0855:                            if (lCompileClasspath != null)
0856:                                lCompiler
0857:                                        .setAdditionalClasspath(lCompileClasspath);
0858:                            lCompiler.setSourceRootDir(getOwnerTask()
0859:                                    .getGenDir());
0860:                            lCompiler.addSourceInclude(lServicemoduleStylesheet
0861:                                    .getAdapterRootPackageDir()
0862:                                    + "/soap/services/"
0863:                                    + lServicemoduleStylesheet
0864:                                            .getSystemSubPackageName()
0865:                                    + "*.java");
0866:                            lInvocations.add(lCompiler);
0867:                        }
0868:                        // Compile Web Service proxy package
0869:                        {
0870:                            JavaCompilerInvocationDefinition lCompiler = new JavaCompilerInvocationDefinition(
0871:                                    getOwnerTask(),
0872:                                    "Compile Web Service adapter for the "
0873:                                            + lService.getRef());
0874:                            lCompiler
0875:                                    .setClasspathName("MetaBossWebServiceCompileClasspath");
0876:                            Path lCompileClasspath = getCompileClasspath();
0877:                            if (lCompileClasspath != null)
0878:                                lCompiler
0879:                                        .setAdditionalClasspath(lCompileClasspath);
0880:                            lCompiler.setSourceRootDir(getOwnerTask()
0881:                                    .getGenDir());
0882:                            lCompiler.addSourceInclude(lServicemoduleStylesheet
0883:                                    .getAdapterRootPackageDir()
0884:                                    + File.separator
0885:                                    + "/soap/services/"
0886:                                    + lServicemoduleStylesheet
0887:                                            .getSystemSubPackageName()
0888:                                    + "/"
0889:                                    + lServiceStylesheet.getNormalisedName()
0890:                                            .toLowerCase() + "/*.java");
0891:                            lInvocations.add(lCompiler);
0892:                        }
0893:                    }
0894:                    // Return what we have		
0895:                    return (ToolInvocationDefinition[]) lInvocations
0896:                            .toArray(new ToolInvocationDefinition[lInvocations
0897:                                    .size()]);
0898:                } catch (BSException e) {
0899:                    throw new BuildException(
0900:                            "Caught exception while generating packaging plan. "
0901:                                    + e.getMessage());
0902:                }
0903:            }
0904:
0905:            // Returns tasks to invoke any number of packagers necessary to build the module  
0906:            public ToolInvocationDefinition[] getPackagingPlan()
0907:                    throws BuildException {
0908:                if (mServicesToDo.isEmpty())
0909:                    return new ToolInvocationDefinition[0];
0910:                try {
0911:                    // Assemble raw war file in the temporary working directory and run wsdeploy
0912:                    List lInvocations = new ArrayList();
0913:
0914:                    // Build raw war file
0915:                    {
0916:                        AntWarInvocationDefinition lWarInvocationDefinition = new AntWarInvocationDefinition(
0917:                                getOwnerTask(),
0918:                                "Create the intermediate war file");
0919:                        lWarInvocationDefinition
0920:                                .setDestFilePath(mPrivateWorkDirectoryName
0921:                                        + "/" + mDestinationArchiveName);
0922:
0923:                        // Take web xml from the private working directory
0924:                        lWarInvocationDefinition
0925:                                .setWebXmlFilePath(mPrivateWorkDirectoryName
0926:                                        + "/web.xml");
0927:
0928:                        // Take jaxrpc-ri.xml from the private working directory
0929:                        {
0930:                            ZipFileSet lWebInfFileSet = new ZipFileSet();
0931:                            lWebInfFileSet.setDir(new File(
0932:                                    mPrivateWorkDirectoryName));
0933:                            lWebInfFileSet.createInclude().setName(
0934:                                    "jaxrpc-ri.xml");
0935:                            lWarInvocationDefinition
0936:                                    .addWebInfFileset(lWebInfFileSet);
0937:                        }
0938:
0939:                        // Take the lot from the Content directory
0940:                        {
0941:                            FileSet lContentFileSet = new FileSet();
0942:                            lContentFileSet.setDir(new File(
0943:                                    mContentRootDirectoryName));
0944:                            lContentFileSet.createInclude().setName("**/*.xsd");
0945:                            lContentFileSet.createInclude()
0946:                                    .setName("**/*.wsdl");
0947:                            lContentFileSet.createInclude().setName(
0948:                                    "**/*_model.xml.gz");
0949:                            lWarInvocationDefinition
0950:                                    .addFileset(lContentFileSet);
0951:                        }
0952:
0953:                        // Add all contents from the web services run classpath
0954:                        Path lWebServicesClasspath = getOwnerTask().getPath(
0955:                                "MetaBossWebServiceRunClasspath");
0956:                        String[] lClasspathElements = lWebServicesClasspath
0957:                                .list();
0958:                        if (lClasspathElements != null) {
0959:                            for (int i = 0; i < lClasspathElements.length; i++) {
0960:                                String lClasspathElementName = lClasspathElements[i];
0961:                                File lClasspathElementFile = new File(
0962:                                        lClasspathElementName);
0963:                                if (!lClasspathElementFile.exists())
0964:                                    throw new BuildException(
0965:                                            "Unexpected condition. Internally specified file '"
0966:                                                    + lClasspathElementName
0967:                                                    + "' does not exist");
0968:                                if (!lClasspathElementFile.isFile())
0969:                                    throw new BuildException(
0970:                                            "Unexpected condition. Internally specified file '"
0971:                                                    + lClasspathElementName
0972:                                                    + "' is not a file");
0973:                                ZipFileSet lFileSet = new ZipFileSet();
0974:                                lFileSet.setDir(lClasspathElementFile
0975:                                        .getParentFile());
0976:                                lFileSet.setIncludes(lClasspathElementFile
0977:                                        .getName());
0978:                                lWarInvocationDefinition
0979:                                        .addLibFileset(lFileSet);
0980:                            }
0981:                        }
0982:
0983:                        // Add all additional libs
0984:                        for (Iterator lAdditionalLibsIterator = mAdditionalLibs
0985:                                .iterator(); lAdditionalLibsIterator.hasNext();) {
0986:                            ZipFileSet lFileSet = (ZipFileSet) lAdditionalLibsIterator
0987:                                    .next();
0988:                            lWarInvocationDefinition.addLibFileset(lFileSet);
0989:                        }
0990:
0991:                        // Add all additional classes
0992:                        for (Iterator lAdditionalClassesIterator = mAdditionalClasses
0993:                                .iterator(); lAdditionalClassesIterator
0994:                                .hasNext();) {
0995:                            ZipFileSet lFileSet = (ZipFileSet) lAdditionalClassesIterator
0996:                                    .next();
0997:                            lWarInvocationDefinition
0998:                                    .addClassesFileset(lFileSet);
0999:                        }
1000:
1001:                        // Add all of our own classes (the ones we have just built
1002:                        {
1003:                            ZipFileSet lClassesFileSet = new ZipFileSet();
1004:                            lClassesFileSet
1005:                                    .setDir(getOwnerTask().getClassDir());
1006:
1007:                            // First from the external servicemodules we depend on
1008:                            for (Iterator lExternalServicemodulesIterator = mExternalServicemodulesToDo
1009:                                    .iterator(); lExternalServicemodulesIterator
1010:                                    .hasNext();) {
1011:                                Servicemodule lServicemodule = (Servicemodule) lExternalServicemodulesIterator
1012:                                        .next();
1013:                                STServicemoduleStylesheet lServicemoduleStylesheet = CodeGenerationStylesheetAccessor
1014:                                        .getServicemoduleStylesheet(lServicemodule);
1015:                                lClassesFileSet
1016:                                        .createInclude()
1017:                                        .setName(
1018:                                                lServicemoduleStylesheet
1019:                                                        .getAdapterRootPackageDir()
1020:                                                        + "/soap/services/"
1021:                                                        + lServicemoduleStylesheet
1022:                                                                .getSystemSubPackageName()
1023:                                                        + "/*.class");
1024:                                lClassesFileSet
1025:                                        .createInclude()
1026:                                        .setName(
1027:                                                lServicemoduleStylesheet
1028:                                                        .getAdapterRootPackageDir()
1029:                                                        + "/soap/services/"
1030:                                                        + lServicemoduleStylesheet
1031:                                                                .getSystemSubPackageName()
1032:                                                        + "/*.properties");
1033:                            }
1034:                            for (Iterator lExternalNamespacesIterator = mExternalNamespacesToDo
1035:                                    .iterator(); lExternalNamespacesIterator
1036:                                    .hasNext();) {
1037:                                AbstractNamespace lAbstractNamespace = (AbstractNamespace) lExternalNamespacesIterator
1038:                                        .next();
1039:                                if (lAbstractNamespace instanceof  DataDictionary) {
1040:                                    DataDictionary lDataDictionary = (DataDictionary) lAbstractNamespace;
1041:                                    STDataDictionaryStylesheet lDataDictionaryStylesheet = CodeGenerationStylesheetAccessor
1042:                                            .getDataDictionaryStylesheet(lDataDictionary);
1043:                                    // Include DataDictionary Web Types package
1044:                                    String lAdapterDirectory = lDataDictionaryStylesheet
1045:                                            .getAdapterRootPackageDir()
1046:                                            + "/soap/types"
1047:                                            + (lDataDictionary.getSystem() == null ? ("/" + lDataDictionaryStylesheet
1048:                                                    .getNormalisedName()
1049:                                                    .toLowerCase())
1050:                                                    : "");
1051:                                    lClassesFileSet.createInclude().setName(
1052:                                            lAdapterDirectory + "/*.class");
1053:                                    lClassesFileSet.createInclude()
1054:                                            .setName(
1055:                                                    lAdapterDirectory
1056:                                                            + "/*.properties");
1057:                                } else if (lAbstractNamespace instanceof  Namespace) {
1058:                                    Namespace lNamespace = (Namespace) lAbstractNamespace;
1059:                                    DataDictionary lOwnerDataDictionary = lNamespace
1060:                                            .getOwnerDataDictionary();
1061:                                    STNamespaceStylesheet lNamespaceStylesheet = CodeGenerationStylesheetAccessor
1062:                                            .getNamespaceStylesheet(lNamespace);
1063:                                    STDataDictionaryStylesheet lOwnerDataDictionaryStylesheet = CodeGenerationStylesheetAccessor
1064:                                            .getDataDictionaryStylesheet(lOwnerDataDictionary);
1065:                                    // Include Namespace Web Types package
1066:                                    String lAdapterDirectory = lOwnerDataDictionaryStylesheet
1067:                                            .getAdapterRootPackageDir()
1068:                                            + "/soap/types"
1069:                                            + (lOwnerDataDictionary.getSystem() == null ? ("/" + lOwnerDataDictionaryStylesheet
1070:                                                    .getNormalisedName()
1071:                                                    .toLowerCase())
1072:                                                    : "")
1073:                                            + "/"
1074:                                            + lNamespaceStylesheet
1075:                                                    .getDictionarySubPackageName()
1076:                                                    .replace('.', '/');
1077:                                    lClassesFileSet.createInclude().setName(
1078:                                            lAdapterDirectory + "/*.class");
1079:                                    lClassesFileSet.createInclude()
1080:                                            .setName(
1081:                                                    lAdapterDirectory
1082:                                                            + "/*.properties");
1083:                                }
1084:                            }
1085:
1086:                            // Compile stuff for the services and service modules involved
1087:                            for (Iterator lServicesIterator = mServicesToDo
1088:                                    .iterator(); lServicesIterator.hasNext();) {
1089:                                Service lService = (Service) lServicesIterator
1090:                                        .next();
1091:                                Servicemodule lServicemodule = lService
1092:                                        .getServicemodule();
1093:                                STServicemoduleStylesheet lServicemoduleStylesheet = CodeGenerationStylesheetAccessor
1094:                                        .getServicemoduleStylesheet(lServicemodule);
1095:                                STServiceStylesheet lServiceStylesheet = CodeGenerationStylesheetAccessor
1096:                                        .getServiceStylesheet(lService);
1097:
1098:                                lClassesFileSet
1099:                                        .createInclude()
1100:                                        .setName(
1101:                                                lServicemoduleStylesheet
1102:                                                        .getAdapterRootPackageDir()
1103:                                                        + File.separator
1104:                                                        + "/soap/services/"
1105:                                                        + lServicemoduleStylesheet
1106:                                                                .getSystemSubPackageName()
1107:                                                        + "/*.class");
1108:                                lClassesFileSet
1109:                                        .createInclude()
1110:                                        .setName(
1111:                                                lServicemoduleStylesheet
1112:                                                        .getAdapterRootPackageDir()
1113:                                                        + File.separator
1114:                                                        + "/soap/services/"
1115:                                                        + lServicemoduleStylesheet
1116:                                                                .getSystemSubPackageName()
1117:                                                        + "/*.properties");
1118:                                lClassesFileSet
1119:                                        .createInclude()
1120:                                        .setName(
1121:                                                lServicemoduleStylesheet
1122:                                                        .getAdapterRootPackageDir()
1123:                                                        + File.separator
1124:                                                        + "/soap/services/"
1125:                                                        + lServicemoduleStylesheet
1126:                                                                .getSystemSubPackageName()
1127:                                                        + "/"
1128:                                                        + lServiceStylesheet
1129:                                                                .getNormalisedName()
1130:                                                                .toLowerCase()
1131:                                                        + "/*.class");
1132:                                lClassesFileSet
1133:                                        .createInclude()
1134:                                        .setName(
1135:                                                lServicemoduleStylesheet
1136:                                                        .getAdapterRootPackageDir()
1137:                                                        + File.separator
1138:                                                        + "/soap/services/"
1139:                                                        + lServicemoduleStylesheet
1140:                                                                .getSystemSubPackageName()
1141:                                                        + "/"
1142:                                                        + lServiceStylesheet
1143:                                                                .getNormalisedName()
1144:                                                                .toLowerCase()
1145:                                                        + "/*.properties");
1146:                            }
1147:                            lWarInvocationDefinition
1148:                                    .addClassesFileset(lClassesFileSet);
1149:                        }
1150:
1151:                        lInvocations.add(lWarInvocationDefinition);
1152:                    }
1153:                    // Ensure that the destination directory is created (wsdeploy can not cope with the absent directory)
1154:                    {
1155:                        AntMkdirInvocationDefinition lMakeDestDirInvocation = new AntMkdirInvocationDefinition(
1156:                                getOwnerTask(),
1157:                                "Ensure the destination directory exists");
1158:                        lMakeDestDirInvocation.setDirectoryPath(getModuleDir()
1159:                                .getAbsolutePath());
1160:                        lInvocations.add(lMakeDestDirInvocation);
1161:                    }
1162:                    // Invoke wsdeploy
1163:                    {
1164:                        WSDeployInvocationDefinition lWsdeployInvocationDefinition = new WSDeployInvocationDefinition(
1165:                                getOwnerTask(), "Create the war file");
1166:                        lWsdeployInvocationDefinition
1167:                                .setInWarFileLocation(mPrivateWorkDirectoryName
1168:                                        + "/" + mDestinationArchiveName);
1169:                        lWsdeployInvocationDefinition
1170:                                .setOutWarFileLocation(getModuleDir()
1171:                                        .getAbsolutePath()
1172:                                        + "/" + mDestinationArchiveName);
1173:                        lInvocations.add(lWsdeployInvocationDefinition);
1174:                    }
1175:
1176:                    // Last is to remove the temporary directory
1177:                    {
1178:                        AntDeleteInvocationDefinition lDeleteTempDirInvocation = new AntDeleteInvocationDefinition(
1179:                                getOwnerTask(),
1180:                                "Clean up temporary directory after use");
1181:                        lDeleteTempDirInvocation
1182:                                .setDirectoryPath(mTempDirectoryName);
1183:                        lInvocations.add(lDeleteTempDirInvocation);
1184:                    }
1185:
1186:                    // Return what we have		
1187:                    return (ToolInvocationDefinition[]) lInvocations
1188:                            .toArray(new ToolInvocationDefinition[lInvocations
1189:                                    .size()]);
1190:                } catch (BSException e) {
1191:                    throw new BuildException(
1192:                            "Caught exception while generating packaging plan. "
1193:                                    + e.getMessage());
1194:                }
1195:            }
1196:        }
w_ww___.ja___v_a_2___s.c__om__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.