Source Code Cross Referenced for HTTPTransportFactory.java in  » ESB » celtix-1.0 » org » objectweb » celtix » bus » transports » http » 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 » celtix 1.0 » org.objectweb.celtix.bus.transports.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.bus.transports.http;
002:
003:        import java.io.IOException;
004:        import java.lang.ref.WeakReference;
005:        import java.lang.reflect.Field;
006:        import java.net.URL;
007:        import java.util.Map;
008:
009:        import javax.wsdl.WSDLException;
010:        import javax.xml.bind.JAXBException;
011:
012:        import org.objectweb.celtix.Bus;
013:        import org.objectweb.celtix.bindings.ClientBinding;
014:        import org.objectweb.celtix.bus.transports.http.protocol.pipe.Handler;
015:        import org.objectweb.celtix.bus.transports.http.protocol.pipe.PipeHTTPServerTransport;
016:        import org.objectweb.celtix.buslifecycle.BusLifeCycleListener;
017:        import org.objectweb.celtix.transports.ClientTransport;
018:        import org.objectweb.celtix.transports.ServerTransport;
019:        import org.objectweb.celtix.transports.TransportFactory;
020:        import org.objectweb.celtix.transports.http.configuration.HTTPClientPolicy;
021:        import org.objectweb.celtix.transports.http.configuration.HTTPServerPolicy;
022:        import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
023:        import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
024:        import org.objectweb.celtix.wsdl.JAXBExtensionHelper;
025:        import org.xmlsoap.schemas.wsdl.http.AddressType;
026:
027:        public class HTTPTransportFactory implements  TransportFactory {
028:            protected Bus bus;
029:            /* surefire runs in a classloader that won't allow the URL 
030:             * class to load the Handler.   We'll need to manually add 
031:             * it to the list.
032:             */
033:            static {
034:                addHandler();
035:            }
036:
037:            @SuppressWarnings("unchecked")
038:            static void addHandler() {
039:                try {
040:                    Field field = URL.class.getDeclaredField("handlers");
041:                    field.setAccessible(true);
042:                    Map handlers = (Map) field.get(null);
043:                    handlers.put("pipe", new Handler());
044:                } catch (Exception e) {
045:                    //ignore
046:                }
047:            }
048:
049:            public void init(Bus b) {
050:                bus = b;
051:                try {
052:                    JAXBExtensionHelper.addExtensions(bus.getWSDLManager()
053:                            .getExtenstionRegistry(), javax.wsdl.Port.class,
054:                            HTTPClientPolicy.class);
055:                    JAXBExtensionHelper.addExtensions(bus.getWSDLManager()
056:                            .getExtenstionRegistry(), javax.wsdl.Port.class,
057:                            HTTPServerPolicy.class);
058:                    JAXBExtensionHelper.addExtensions(bus.getWSDLManager()
059:                            .getExtenstionRegistry(), javax.wsdl.Port.class,
060:                            AddressType.class);
061:
062:                } catch (JAXBException e) {
063:                    //ignore, we can continue without the extension registered
064:                }
065:                String val = System.getProperty("java.protocol.handler.pkgs");
066:                if (val == null) {
067:                    System
068:                            .setProperty("java.protocol.handler.pkgs",
069:                                    "org.objectweb.celtix.bus.transports.http.protocol");
070:                } else if (val
071:                        .indexOf("org.objectweb.celtix.bus.transports.http.protocol") == -1) {
072:                    val += "|org.objectweb.celtix.bus.transports.http.protocol";
073:                    System.setProperty("java.protocol.handler.pkgs", val);
074:                }
075:                bus.getLifeCycleManager().registerLifeCycleListener(
076:                        new ShutdownListener(this ));
077:            }
078:
079:            public ServerTransport createServerTransport(
080:                    EndpointReferenceType address) throws WSDLException,
081:                    IOException {
082:                URL url = new URL(EndpointReferenceUtils.getAddress(address));
083:                if ("pipe".equals(url.getProtocol())) {
084:                    return new PipeHTTPServerTransport(bus, address);
085:                }
086:                return new JettyHTTPServerTransport(bus, address);
087:            }
088:
089:            public ServerTransport createTransientServerTransport(
090:                    EndpointReferenceType address) throws WSDLException {
091:
092:                // TODO Auto-generated method stub
093:                return null;
094:            }
095:
096:            public ClientTransport createClientTransport(
097:                    EndpointReferenceType ref, ClientBinding binding)
098:                    throws WSDLException, IOException {
099:                return new HTTPClientTransport(bus, ref, binding, this );
100:            }
101:
102:            protected Bus getBus() {
103:                return bus;
104:            }
105:
106:            private void shutdown() {
107:            }
108:
109:            private static class ShutdownListener extends
110:                    WeakReference<HTTPTransportFactory> implements 
111:                    BusLifeCycleListener {
112:
113:                ShutdownListener(HTTPTransportFactory factory) {
114:                    super (factory);
115:                }
116:
117:                public void initComplete() {
118:                    //nothing
119:                }
120:
121:                public void preShutdown() {
122:                    if (get() != null) {
123:                        HTTPTransportFactory factory = get();
124:                        factory.shutdown();
125:                        clear();
126:                    }
127:                }
128:
129:                public void postShutdown() {
130:                    //nothing
131:                }
132:            }
133:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.