Source Code Cross Referenced for ServiceDescriptionHandler.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » runtime » ccsl » jbi » messaging » 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.runtime.ccsl.jbi.messaging 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         * 		Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2007 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: ServiceDescriptionHandler.java 9243 2007-09-25 00:49:54Z lzheng $
023:         */
024:        package com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging;
025:
026:        import java.util.Iterator;
027:        import java.util.List;
028:        import java.util.Map;
029:        import java.util.Map.Entry;
030:
031:        import javax.jbi.JBIException;
032:        import javax.jbi.component.ComponentContext;
033:        import javax.jbi.servicedesc.ServiceEndpoint;
034:        import javax.wsdl.Definition;
035:        import javax.wsdl.Input;
036:        import javax.wsdl.Operation;
037:        import javax.wsdl.Output;
038:        import javax.wsdl.PortType;
039:        import javax.wsdl.factory.WSDLFactory;
040:        import javax.wsdl.xml.WSDLReader;
041:        import javax.xml.namespace.QName;
042:
043:        import org.apache.commons.logging.Log;
044:        import org.apache.commons.logging.LogFactory;
045:        import org.w3c.dom.Document;
046:
047:        public class ServiceDescriptionHandler {
048:
049:            public static final String WSDL_11_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/";
050:            public static final String WSDL_20_NAMESPACE = "http://www.w3.org/ns/wsdl";
051:
052:            private static Log log = LogFactory
053:                    .getLog(ServiceDescriptionHandler.class);
054:
055:            private ServiceInfo svcInfo = null;
056:            private Document svcDescDoc = null;
057:            private boolean wsdl11;
058:            private PortType portType;
059:
060:            protected ServiceDescriptionHandler() {
061:
062:            }
063:
064:            /**
065:             * @return the wsdl11
066:             */
067:            public boolean isWsdl11() {
068:                return wsdl11;
069:            }
070:
071:            /**
072:             * @param wsdl11 the wsdl11 to set
073:             */
074:            public void setWsdl11(boolean wsdl11) {
075:                this .wsdl11 = wsdl11;
076:            }
077:
078:            public List<Operation> getOperations() {
079:                if (wsdl11 && portType != null) {
080:                    return portType.getOperations();
081:                }
082:                return null;
083:            }
084:
085:            public Operation getFirstOperation() {
086:                if (wsdl11 && portType != null) {
087:                    if (portType.getOperations().size() > 0) {
088:                        return (Operation) portType.getOperations().get(0);
089:                    }
090:                }
091:                return null;
092:            }
093:
094:            public QName getInputMessageQName(Operation operation) {
095:                if (wsdl11) {
096:                    Input input = operation.getInput();
097:                    if (input != null) {
098:                        return input.getMessage().getQName();
099:                    }
100:                }
101:                return null;
102:            }
103:
104:            public String getInputName(Operation operation) {
105:                if (wsdl11) {
106:                    Input input = operation.getInput();
107:                    if (input != null) {
108:                        return input.getName();
109:                    }
110:                }
111:                return null;
112:            }
113:
114:            public QName getOutputMessageQName(Operation operation) {
115:                if (wsdl11) {
116:                    Output output = operation.getOutput();
117:                    if (output != null) {
118:                        return output.getMessage().getQName();
119:                    }
120:                }
121:                return null;
122:            }
123:
124:            public String getOutputName(Operation operation) {
125:                if (wsdl11) {
126:                    Output output = operation.getOutput();
127:                    if (output != null) {
128:                        return output.getName();
129:                    }
130:                }
131:                return null;
132:            }
133:
134:            public static ServiceDescriptionHandler getInstance(Document wsdlDoc) {
135:                ServiceDescriptionHandler instance = new ServiceDescriptionHandler();
136:                instance.svcInfo = null;
137:                instance.initFromDoc(wsdlDoc);
138:                return instance;
139:            }
140:
141:            public static ServiceDescriptionHandler getInstance(
142:                    ServiceInfo serviceInfo, ComponentContext context) {
143:                if (serviceInfo != null && serviceInfo.getServiceName() != null
144:                        && serviceInfo.getEndpointName() != null) {
145:                    ServiceEndpoint ep = context.getEndpoint(serviceInfo
146:                            .getServiceName(), serviceInfo.getEndpointName());
147:                    try {
148:                        Document svcDesc = context.getEndpointDescriptor(ep);
149:                        if (svcDesc != null) {
150:                            log
151:                                    .debug("getEndpointDescriptor returnded WSDL, trying to process...");
152:                            ServiceDescriptionHandler instance = new ServiceDescriptionHandler();
153:                            instance.svcInfo = serviceInfo;
154:                            instance.initFromDoc(svcDesc);
155:                            return instance;
156:                        } else {
157:                            log.debug("getEndpointDescriptor returned null.");
158:                        }
159:                    } catch (JBIException e) {
160:                        log
161:                                .error(
162:                                        "Caught Exception retrieving service description",
163:                                        e);
164:                    }
165:                } else {
166:                    log
167:                            .info("Unable to retrieve Service Description, ServiceInfo is null.");
168:                }
169:                return null;
170:            }
171:
172:            private void initFromDoc(Document wsdlDoc) {
173:
174:                svcDescDoc = wsdlDoc;
175:
176:                String namespace = wsdlDoc.getDocumentElement()
177:                        .getNamespaceURI();
178:                if (WSDL_11_NAMESPACE.equals(namespace)) {
179:                    wsdl11 = true;
180:                    try {
181:                        log.debug("processing WSDL 1.1 document...");
182:                        processWsdl11Doc(wsdlDoc);
183:                    } catch (Exception e) {
184:                        log
185:                                .error(
186:                                        "Exception while processing Service Description",
187:                                        e);
188:                    }
189:                } else if (WSDL_20_NAMESPACE.equals(namespace)) {
190:                    wsdl11 = false;
191:
192:                } else {
193:                    log
194:                            .error("Unable to process Service Description document.  Returned doc is not WSDL 1.1 or 2.0");
195:                }
196:
197:            }
198:
199:            private void processWsdl11Doc(Document wsdlDoc) throws Exception {
200:                WSDLFactory wsdlFactory = WSDLFactory.newInstance();
201:                // Create the WSDL Reader object
202:                WSDLReader reader = wsdlFactory.newWSDLReader();
203:                // Read the WSDL and get the top-level Definition object
204:                Definition wsdlDefinition = reader.readWSDL(null, wsdlDoc);
205:                if (svcInfo != null) {
206:                    // Get the PortType specified by the ServiceInfo setting
207:                    portType = wsdlDefinition.getPortType(svcInfo
208:                            .getInterfaceName());
209:                } else {
210:                    // Get the first PortType
211:                    Map portTypes = wsdlDefinition.getPortTypes();
212:                    Iterator iter = portTypes.entrySet().iterator();
213:                    if (iter.hasNext()) {
214:                        Entry entry = (Entry) iter.next();
215:                        portType = (PortType) entry.getValue();
216:                    }
217:
218:                }
219:                if (portType == null) {
220:                    log.error("WSDL does not have a portType defined.");
221:                    //Set to WSDL 2.0 so errors don't occur trying to use wrapper.
222:                    wsdl11 = false;
223:                }
224:                if (getFirstOperation() == null) {
225:                    log
226:                            .error("WSDL does not define an operation for portType: "
227:                                    + portType.getQName());
228:                    wsdl11 = false;
229:                }
230:            }
231:
232:        }
w_w_w._jav___a___2__s__.c_o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.