Source Code Cross Referenced for AbstractComponentDOMWsdlXMLGenerator.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » common » util » generators » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.common.util.generators 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id$
023:         */
024:        package com.bostechcorp.cbesb.common.util.generators;
025:
026:        import java.util.Enumeration;
027:        import java.util.Properties;
028:
029:        import org.jdom.Attribute;
030:        import org.jdom.DefaultJDOMFactory;
031:        import org.jdom.Element;
032:        import org.jdom.JDOMFactory;
033:        import org.jdom.Namespace;
034:
035:        /**
036:         * @author LPS
037:         *
038:         */
039:        public abstract class AbstractComponentDOMWsdlXMLGenerator extends
040:                AbstractDOMGenerator {
041:
042:            protected static String DEFINITIONS_T = "definitions";
043:            protected static String DEFINITIONS_XMLNS_A = "xmlns";
044:            protected static String DEFINITIONS_TNS_NS = "tns";
045:            protected static String DEFINITIONS_FILE_NS = "file";
046:            protected static String DEFINITIONS_HTTP_NS = "http";
047:            protected static String DEFINITIONS_SOAP_NS = "soap";
048:            protected static String DEFINITIONS_JBI_NS = "jbi";
049:            protected static String DEFINITIONS_JMS_NS = "jms";
050:            protected static String DEFINITIONS_FTP_NS = "ftp";
051:            protected static String DEFINITIONS_TCPIP_NS = "tcpip";
052:            protected static String DEFINITIONS_EMAIL_NS = "email";
053:            protected static String DEFINITIONS_TRANSFORMER_NS = "transformer";
054:            protected static String DEFINITIONS_SEQUENCER_NS = "sequencer";
055:            protected static String DEFINITIONS_SCRIPT_NS = "script";
056:            protected static String DEFINITIONS_CBR_NS = "cbr";
057:            protected static String DEFINITIONS_JDBC_NS = "jdbc";
058:            protected static String DEFINITIONS_PARSER_NS = "parser";
059:            protected static String DEFINITIONS_XSLT_NS = "xslt";
060:            protected static String DEFINITIONS_SCHEDULER_NS = "sched";
061:            protected static String DEFINITIONS_CBHTTP_NS = "cbhttp"; //defines custom CBESB http extensibulity elements
062:            protected static String DEFINITIONS_NAME_A = "name";
063:
064:            protected static String DEFINITIONS_TARGET_NAMESPACE_A = "targetNamespace";
065:
066:            protected static String PORT_TYPE_T = "portType";
067:
068:            protected static String BINDING_T = "binding";
069:            protected static String BINDING_TYPE_A = "type";
070:
071:            protected static String SERVICE_T = "service";
072:
073:            protected static String PORT_T = "port";
074:            protected static String PORT_BINDING_A = "binding";
075:
076:            protected static String TYPES_T = "types";
077:            protected static String MESSAGE_T = "message";
078:
079:            protected static String OPERATION_T = "operation";
080:            protected static String INPUT_T = "input";
081:            protected static String OUTPUT_T = "output";
082:            protected static String NAME_A = "name";
083:            protected static String MESSAGE_A = "message";
084:
085:            //Schema elements
086:            protected static Namespace xsdNamespace = Namespace.getNamespace(
087:                    "xsd", "http://www.w3.org/2001/XMLSchema");
088:            protected static String SCHEMA_T = "schema";
089:            protected static String ELEMENT_T = "element";
090:            protected static String IMPORT_T = "import";
091:            protected static String COMPLEX_TYPE_T = "complexType";
092:            protected static String CHOICE_T = "choice";
093:            protected static String NAMESPACE_A = "namespace";
094:            protected static Namespace ref = Namespace.getNamespace("ref",
095:                    "http://ws-i.org/profiles/basic/1.1/xsd");
096:            protected static Namespace de = Namespace.getNamespace("de",
097:                    "http://cbesb.bostechcorp.com/dataenvelope/1.0");
098:
099:            protected static String MAX_OCCURS_A = "maxOccurs";
100:            protected static String TYPE_A = "type";
101:            //
102:            //other standard elements
103:            protected static String PART_T = "part";
104:            protected static String ELEMENT_A = "element";
105:
106:            // basic tags that always appear in the wsdl Description
107:            protected JDOMFactory jdomFactory = new DefaultJDOMFactory();
108:            protected Element portTypeElement;
109:            protected Element bindingNameElement;
110:            protected Element serviceElement;
111:            protected Element portElement;
112:            protected Element typesElement;
113:            protected Element messageElement;
114:            Namespace xmlns;
115:            Namespace tns;
116:            Namespace componentxmlns;
117:            Namespace httpxmlns;
118:            Namespace soapxmlns;
119:            Namespace jbixmlns;
120:            Attribute SUname;
121:            Attribute targetNamespace;
122:            // file name 
123:            protected String fileName = "";
124:
125:            //protected String componentName="";
126:
127:            public AbstractComponentDOMWsdlXMLGenerator(String s) {
128:                super (s);
129:            }
130:
131:            /* (non-Javadoc)
132:             * @see com.bostechcorp.cbesb.common.util.AbstractDOMGenerator#buildDocumentStructure()
133:             */
134:            @Override
135:            protected void buildDocumentStructure() {
136:                jdomFactory = new DefaultJDOMFactory();
137:                rootElement = jdomFactory.element(DEFINITIONS_T);
138:
139:                portTypeElement = jdomFactory.element(PORT_TYPE_T, rootElement
140:                        .getNamespace());
141:                bindingNameElement = jdomFactory.element(BINDING_T, rootElement
142:                        .getNamespace());
143:                serviceElement = jdomFactory.element(SERVICE_T, rootElement
144:                        .getNamespace());
145:                portElement = jdomFactory.element(PORT_T, rootElement
146:                        .getNamespace());
147:                typesElement = jdomFactory.element(TYPES_T, rootElement
148:                        .getNamespace());
149:                messageElement = jdomFactory.element(MESSAGE_T, rootElement
150:                        .getNamespace());
151:
152:                rootElement.addContent(typesElement);
153:                rootElement.addContent(messageElement);
154:                rootElement.addContent(portTypeElement);
155:                rootElement.addContent(bindingNameElement);
156:                rootElement.addContent(serviceElement);
157:
158:                serviceElement.addContent(portElement);
159:
160:                addXSDSchema();
161:                addMessage();
162:            }
163:
164:            private void addXSDSchema() {
165:                Element schema = jdomFactory.element(SCHEMA_T);
166:                schema.setNamespace(xsdNamespace);
167:                schema.addNamespaceDeclaration(ref);
168:                schema.addNamespaceDeclaration(de);
169:                schema.setAttribute("targetNamespace", de.getURI());
170:                rootElement.addNamespaceDeclaration(de);
171:
172:                Element importElement = jdomFactory.element(IMPORT_T,
173:                        xsdNamespace);
174:                importElement.setAttribute(NAMESPACE_A, ref.getURI());
175:
176:                Element elementDataEnvelope = jdomFactory.element(ELEMENT_T,
177:                        xsdNamespace);
178:                elementDataEnvelope.setAttribute(NAME_A, "DataEnvelope");
179:
180:                Element complexType = jdomFactory.element(COMPLEX_TYPE_T,
181:                        xsdNamespace);
182:                Element choice = jdomFactory.element(CHOICE_T, xsdNamespace);
183:                choice.setAttribute(MAX_OCCURS_A, "unbounded");
184:
185:                Element elementXmlRecord = jdomFactory.element(ELEMENT_T,
186:                        xsdNamespace);
187:                elementXmlRecord.setAttribute(NAME_A, "XMLRecord");
188:                elementXmlRecord.setAttribute(TYPE_A, xsdNamespace.getPrefix()
189:                        + ":anyType");
190:
191:                Element elementStringRecord = jdomFactory.element(ELEMENT_T,
192:                        xsdNamespace);
193:                elementStringRecord.setAttribute(NAME_A, "StringRecord");
194:                elementStringRecord.setAttribute(TYPE_A, xsdNamespace
195:                        .getPrefix()
196:                        + ":swaRef");
197:
198:                Element elementBinaryRecord = jdomFactory.element(ELEMENT_T,
199:                        xsdNamespace);
200:                elementBinaryRecord.setAttribute(NAME_A, "BinaryRecord");
201:                elementBinaryRecord.setAttribute(TYPE_A, xsdNamespace
202:                        .getPrefix()
203:                        + ":swaRef");
204:
205:                choice.addContent(elementXmlRecord);
206:                choice.addContent(elementStringRecord);
207:                choice.addContent(elementBinaryRecord);
208:
209:                complexType.addContent(choice);
210:
211:                elementDataEnvelope.addContent(complexType);
212:
213:                schema.addContent(importElement);
214:                schema.addContent(elementDataEnvelope);
215:
216:                typesElement.addContent(schema);
217:            }
218:
219:            private void addMessage() {
220:                Element message = messageElement;
221:                message.setAttribute(NAME_A, "DataEnvelopeMessage");
222:
223:                Element part = jdomFactory.element(PART_T);
224:                part.setAttribute(NAME_A, "body");
225:                part.setAttribute(ELEMENT_A, "de:DataEnvelope");
226:
227:                message.addContent(part);
228:                //rootElement.addContent(message); // content already has a parent "definitions"
229:            }
230:
231:            public void setDefinitionNamespace(String componentType,
232:                    String saName, String suName, String endPointName)
233:                    throws Exception {
234:
235:                String serviceUnitName = saName + "_" + suName;
236:
237:                xmlns = Namespace
238:                        .getNamespace("http://schemas.xmlsoap.org/wsdl/");
239:                tns = Namespace.getNamespace("tns",
240:                        "http://bostechcorp.com/SU/" + serviceUnitName);
241:                componentxmlns = Namespace.getNamespace(componentType,
242:                        "http://cbesb.bostechcorp.com/wsdl/" + componentType
243:                                + "/1.0");
244:                targetNamespace = new Attribute("targetNamespace",
245:                        "http://bostechcorp.com/SU/" + serviceUnitName);
246:                SUname = new Attribute("name", serviceUnitName);
247:                rootElement.setAttribute(SUname);
248:                rootElement.setAttribute(targetNamespace);
249:                rootElement.setNamespace(xmlns);
250:                rootElement.addNamespaceDeclaration(tns);
251:                rootElement.addNamespaceDeclaration(componentxmlns);
252:                //optional namespace for Scheduleable components
253:                //xmlns:xsd="http://www.w3.org/2001/XMLSchema"
254:                //xmlns:sm="http://cbesb.bostechcorp.com/soap/sendmessage/1.0"
255:                Namespace xsdNs = Namespace.getNamespace("xsd",
256:                        "http://www.w3.org/2001/XMLSchema");
257:                Namespace smNs = Namespace.getNamespace("sm",
258:                        "http://cbesb.bostechcorp.com/soap/sendmessage/1.0");
259:                rootElement.addNamespaceDeclaration(smNs);
260:                rootElement.addNamespaceDeclaration(xsdNs);
261:            }
262:
263:            public void setDefinitionAttributes(String name,
264:                    String TargetNamespace) {
265:                rootElement.setAttribute(jdomFactory.attribute(
266:                        DEFINITIONS_NAME_A, name));
267:                rootElement.setAttribute(jdomFactory.attribute(
268:                        DEFINITIONS_TARGET_NAMESPACE_A, TargetNamespace));
269:            }
270:
271:            public void setPortTypeAttributes(String name) {
272:                portTypeElement.setAttribute(jdomFactory
273:                        .attribute(NAME_A, name));
274:                portTypeElement.setNamespace(Namespace.NO_NAMESPACE);
275:            }
276:
277:            /**
278:             * sets the operation
279:             * @param operationName
280:             * @param isInOut
281:             */
282:            public void setOperation(String operationName, boolean isInOut) {
283:                //setting the operation
284:                if (!operationName.endsWith("_Operation")) {
285:                    operationName = operationName.replaceAll("_Interface", "");
286:                    operationName += "_Operation";
287:                }
288:                Element operationElement = jdomFactory.element(OPERATION_T);
289:                operationElement.setAttribute(NAME_A, operationName);
290:
291:                Element inputElement = jdomFactory.element(INPUT_T);
292:                inputElement.setAttribute(MESSAGE_A, "tns:DataEnvelopeMessage");
293:
294:                Element outputElement = jdomFactory.element(OUTPUT_T);
295:                outputElement
296:                        .setAttribute(MESSAGE_A, "tns:DataEnvelopeMessage");
297:
298:                operationElement.addContent(inputElement);
299:                if (isInOut) {
300:                    operationElement.addContent(outputElement);
301:                }
302:
303:                portTypeElement.addContent(operationElement);
304:            }
305:
306:            //        public void setProviderAdditionalTags()
307:            //        {
308:            //            //
309:            //            //addXSDSchema();
310:            //            //addMessage();
311:            //        }
312:
313:            public void setBindingAttributes(String name, String type) {
314:                bindingNameElement.setAttribute(jdomFactory.attribute(NAME_A,
315:                        name));
316:                bindingNameElement.setAttribute(jdomFactory.attribute(
317:                        BINDING_TYPE_A, type));
318:                bindingNameElement.setNamespace(Namespace.NO_NAMESPACE);
319:                //Namespace ns = Namespace.getNamespace(componentType,componentType);
320:                // adding jbi inner binding
321:                /*
322:                Namespace jbiBindingNS = Namespace.getNamespace("jbi",
323:                        "http://java.sun.com/xml/ns/jbi/binding/service+engine" );
324:                
325:                Element innerBinding = jdomFactory.element(BINDING_T, jbiBindingNS);
326:                innerBinding.addNamespaceDeclaration(jbiBindingNS);
327:                innerBinding.setNamespace(jbiBindingNS);
328:                rootElement.addNamespaceDeclaration(jbiBindingNS);
329:
330:                bindingNameElement.addContent(innerBinding);
331:                 */
332:
333:                // adding component inner binding
334:                Element specificBinding = jdomFactory.element(BINDING_T,
335:                        rootElement.getNamespace());
336:                specificBinding.setNamespace(componentxmlns);
337:                bindingNameElement.addContent(specificBinding);
338:
339:            }
340:
341:            public void setServiceElementAtributes(String serviceName) {
342:                serviceElement.setAttribute(jdomFactory.attribute(NAME_A,
343:                        serviceName));
344:            }
345:
346:            public void setPortElementAttributes(String portName) {
347:                String bindingName = bindingNameElement.getAttribute(NAME_A)
348:                        .getValue();
349:                portElement.setAttribute(jdomFactory
350:                        .attribute(NAME_A, portName));
351:                portElement.setAttribute(jdomFactory.attribute(PORT_BINDING_A,
352:                        "tns:" + bindingName));
353:            }
354:
355:            protected void setTagAttributes(Element tag, String root,
356:                    Properties settings) {
357:                boolean bMatch = false;
358:                if (root != null && !root.equals("")) {
359:                    bMatch = true;
360:                }
361:                String rootMatch = root + ".";
362:
363:                Enumeration e = settings.propertyNames();
364:                while (e.hasMoreElements()) {
365:                    String key = (String) e.nextElement();
366:                    if (!bMatch) {
367:                        String value = settings.getProperty(key);
368:                        if (value.contains("{")) {
369:                            tag.setAttribute(key, value);
370:                        } else {
371:                            if ("SYSTEM_DEFAULT".equals(value)) {
372:                                tag.setAttribute(key, "");
373:                            } else {
374:                                tag.setAttribute(key.trim(), value);
375:                            }
376:                        }
377:                    } else if (key.indexOf(rootMatch) == 0) {
378:                        String subKey = key.substring(rootMatch.length());
379:                        String value = settings.getProperty(key);
380:                        if (value.contains("{")) {
381:                            //writer.println(subKey + "=\"" + value + "\"");
382:                            tag.setAttribute(subKey, value);
383:                        } else {
384:                            if ("SYSTEM_DEFAULT".equals(value)) {
385:                                //writer.println(subKey + "=\"\"");
386:                                tag.setAttribute(subKey, "");
387:                            } else {
388:                                //writer.println(subKey + "=\"" + value + "\"");
389:                                tag.setAttribute(subKey, value);
390:                            }
391:                        }
392:                    }
393:                }
394:            }
395:
396:            abstract protected String getFileOut();
397:
398:            /**
399:             * @deprecated
400:             * @param properties
401:             * @param role
402:             * @param componentType
403:             * @param endPointName
404:             * @param saName
405:             * @param componentName
406:             */
407:            abstract public void setComponentProperty(Properties properties,
408:                    String role, String componentType, String endPointName,
409:                    String saName, String componentName);
410:            /*{return filePath+fileName;}*/
411:
412:            /*public static void main(String[] args) 
413:            {
414:            	AbstractComponentDOMWsdlXMLGenerator  a = new AbstractComponentDOMWsdlXMLGenerator("c:/");
415:            	a.setDefinitionAttributes("sdefinitionName", "stargetNamespace");
416:            	a.setServiceElementAtributes("s Service name");
417:            	a.setPortTypeAttributes("s port type");
418:            	a.setPortElementAttributes("ds", "binding");
419:            	a.setBindingAttributes("name", "type", "someComponent");
420:            	
421:            	//for each type of component need to specify the Component definition and service/port content 
422:            	
423:            	//
424:            	a.write();
425:            }*/
426:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.