Source Code Cross Referenced for WSTCPAdapterRegistryImpl.java in  » 6.0-JDK-Modules-com.sun » wsit » com » sun » xml » ws » transport » tcp » server » glassfish » 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 » 6.0 JDK Modules com.sun » wsit » com.sun.xml.ws.transport.tcp.server.glassfish 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         * 
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         * 
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common Development
008:         * and Distribution License("CDDL") (collectively, the "License").  You
009:         * may not use this file except in compliance with the License. You can obtain
010:         * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011:         * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
012:         * language governing permissions and limitations under the License.
013:         * 
014:         * When distributing the software, include this License Header Notice in each
015:         * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016:         * Sun designates this particular file as subject to the "Classpath" exception
017:         * as provided by Sun in the GPL Version 2 section of the License file that
018:         * accompanied this code.  If applicable, add the following below the License
019:         * Header, with the fields enclosed by brackets [] replaced by your own
020:         * identifying information: "Portions Copyrighted [year]
021:         * [name of copyright owner]"
022:         * 
023:         * Contributor(s):
024:         * 
025:         * If you wish your version of this file to be governed by only the CDDL or
026:         * only the GPL Version 2, indicate your decision by adding "[Contributor]
027:         * elects to include this software in this distribution under the [CDDL or GPL
028:         * Version 2] license."  If you don't indicate a single choice of license, a
029:         * recipient has the option to distribute your version of this file under
030:         * either the CDDL, the GPL Version 2 or to extend the choice of license to
031:         * its licensees as provided above.  However, if you add GPL Version 2 code
032:         * and therefore, elected the GPL Version 2 license, then the option applies
033:         * only if the new code is made subject to such option by the copyright
034:         * holder.
035:         */
036:
037:        package com.sun.xml.ws.transport.tcp.server.glassfish;
038:
039:        import com.sun.enterprise.webservice.JAXWSAdapterRegistry;
040:        import com.sun.enterprise.webservice.EjbRuntimeEndpointInfo;
041:        import com.sun.enterprise.webservice.WebServiceEjbEndpointRegistry;
042:        import com.sun.istack.NotNull;
043:        import com.sun.xml.ws.api.server.Adapter;
044:        import com.sun.xml.ws.transport.tcp.resources.MessagesMessages;
045:        import com.sun.xml.ws.transport.tcp.util.WSTCPURI;
046:        import com.sun.xml.ws.transport.tcp.server.TCPAdapter;
047:        import com.sun.xml.ws.transport.tcp.server.WSTCPAdapterRegistry;
048:        import java.util.Map;
049:        import java.util.concurrent.ConcurrentHashMap;
050:        import java.util.logging.Level;
051:        import java.util.logging.Logger;
052:
053:        /**
054:         * @author Alexey Stashok
055:         */
056:        public final class WSTCPAdapterRegistryImpl implements 
057:                WSTCPAdapterRegistry {
058:            private static final Logger logger = Logger
059:                    .getLogger(com.sun.xml.ws.transport.tcp.util.TCPConstants.LoggingDomain
060:                            + ".server");
061:
062:            /**
063:             * Registry holds correspondents between service name and adapter
064:             */
065:            final Map<String, TCPAdapter> registry = new ConcurrentHashMap<String, TCPAdapter>();
066:            private static final WSTCPAdapterRegistryImpl instance = new WSTCPAdapterRegistryImpl();
067:
068:            private WSTCPAdapterRegistryImpl() {
069:            }
070:
071:            public static @NotNull
072:            WSTCPAdapterRegistryImpl getInstance() {
073:                return instance;
074:            }
075:
076:            public TCPAdapter getTarget(@NotNull
077:            final WSTCPURI requestURI) {
078:                // path should have format like "/context-root/url-pattern", where context-root and url-pattern could be /xxxx/yyyy/zzzz
079:
080:                WSEndpointDescriptor wsEndpointDescriptor = null;
081:                String contextRoot = "/";
082:                String urlPattern = "/";
083:                // check if URI path is not empty
084:                if (requestURI.path.length() > 0
085:                        && !requestURI.path.equals("/")) {
086:
087:                    // Try to check for most common situation "/context-root/url-pattern"
088:                    int nextSlashIndex = requestURI.path.indexOf('/', 1);
089:                    if (nextSlashIndex != -1) {
090:                        contextRoot = requestURI.path.substring(0,
091:                                nextSlashIndex);
092:                        urlPattern = requestURI.path.substring(nextSlashIndex,
093:                                requestURI.path.length());
094:                        wsEndpointDescriptor = AppServWSRegistry.getInstance()
095:                                .get(contextRoot, urlPattern);
096:                    }
097:
098:                    if (wsEndpointDescriptor == null) {
099:                        // Try to combine different context-root and url-pattern from given path
100:                        nextSlashIndex = -1;
101:                        do {
102:                            nextSlashIndex = requestURI.path.indexOf('/',
103:                                    nextSlashIndex + 1);
104:                            int delim = nextSlashIndex != -1 ? nextSlashIndex
105:                                    : requestURI.path.length();
106:                            contextRoot = delim > 0 ? requestURI.path
107:                                    .substring(0, delim) : "/";
108:                            urlPattern = delim < requestURI.path.length() ? requestURI.path
109:                                    .substring(delim, requestURI.path.length())
110:                                    : "/";
111:                            wsEndpointDescriptor = AppServWSRegistry
112:                                    .getInstance().get(contextRoot, urlPattern);
113:                        } while (nextSlashIndex != -1
114:                                && wsEndpointDescriptor == null);
115:                    }
116:                } else {
117:                    wsEndpointDescriptor = AppServWSRegistry.getInstance().get(
118:                            contextRoot, urlPattern);
119:                }
120:
121:                if (wsEndpointDescriptor != null) {
122:                    TCPAdapter adapter = registry.get(requestURI.path);
123:                    if (adapter == null) {
124:                        try {
125:                            adapter = createWSAdapter(wsEndpointDescriptor);
126:                            registry.put(requestURI.path, adapter);
127:                            logger
128:                                    .log(
129:                                            Level.FINE,
130:                                            "WSTCPAdapterRegistryImpl. Register adapter. Path: {0}",
131:                                            requestURI.path);
132:                        } catch (Exception e) {
133:                            // This common exception is thrown from ejbEndPtInfo.prepareInvocation(true)
134:                            logger
135:                                    .log(
136:                                            Level.SEVERE,
137:                                            "WSTCPAdapterRegistryImpl. "
138:                                                    + MessagesMessages
139:                                                            .WSTCP_0008_ERROR_TCP_ADAPTER_CREATE(wsEndpointDescriptor
140:                                                                    .getWSServiceName()),
141:                                            e);
142:                        }
143:                    }
144:                    return adapter;
145:                }
146:
147:                return null;
148:            }
149:
150:            public void deleteTargetFor(@NotNull
151:            final String path) {
152:                logger.log(Level.FINE,
153:                        "WSTCPAdapterRegistryImpl. DeRegister adapter for {0}",
154:                        path);
155:                registry.remove(path);
156:            }
157:
158:            private TCPAdapter createWSAdapter(@NotNull
159:            final WSEndpointDescriptor wsEndpointDescriptor) throws Exception {
160:                Adapter adapter;
161:                if (wsEndpointDescriptor.isEJB()) {
162:                    final EjbRuntimeEndpointInfo ejbEndPtInfo = (EjbRuntimeEndpointInfo) WebServiceEjbEndpointRegistry
163:                            .getRegistry()
164:                            .getEjbWebServiceEndpoint(
165:                                    wsEndpointDescriptor.getURI(), "POST", null);
166:                    adapter = (Adapter) ejbEndPtInfo.prepareInvocation(true);
167:                } else {
168:                    final String uri = wsEndpointDescriptor.getURI();
169:                    adapter = JAXWSAdapterRegistry.getInstance().getAdapter(
170:                            wsEndpointDescriptor.getContextRoot(), uri, uri);
171:                }
172:
173:                //@TODO implement checkAdapterSupportsTCP
174:                //        checkAdapterSupportsTCP(adapter);
175:                final TCPAdapter tcpAdapter = new TCP109Adapter(
176:                        wsEndpointDescriptor.getWSServiceName().toString(),
177:                        wsEndpointDescriptor.getContextRoot(),
178:                        wsEndpointDescriptor.getUrlPattern(), adapter
179:                                .getEndpoint(), new ServletFakeArtifactSet(
180:                                wsEndpointDescriptor.getRequestURL(),
181:                                wsEndpointDescriptor.getUrlPattern()),
182:                        wsEndpointDescriptor.isEJB());
183:
184:                return tcpAdapter;
185:            }
186:        }
w_ww.j__av__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.