Source Code Cross Referenced for AbstractHttpSenderConnection.java in  » Web-Services » spring-ws-1.0.0 » org » springframework » ws » transport » 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 » Web Services » spring ws 1.0.0 » org.springframework.ws.transport.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.ws.transport.http;
018:
019:        import java.io.ByteArrayInputStream;
020:        import java.io.IOException;
021:        import java.io.InputStream;
022:        import java.util.Iterator;
023:        import java.util.zip.GZIPInputStream;
024:
025:        import org.springframework.util.FileCopyUtils;
026:        import org.springframework.ws.transport.AbstractSenderConnection;
027:        import org.springframework.ws.transport.FaultAwareWebServiceConnection;
028:        import org.springframework.ws.transport.WebServiceConnection;
029:
030:        /**
031:         * Abstract base class for {@link WebServiceConnection} implementations that send request over HTTP.
032:         *
033:         * @author Arjen Poutsma
034:         * @since 1.0.0
035:         */
036:        public abstract class AbstractHttpSenderConnection extends
037:                AbstractSenderConnection implements 
038:                FaultAwareWebServiceConnection {
039:
040:            /** Buffer used for reading the response, when the content length is invalid. */
041:            private byte[] responseBuffer;
042:
043:            public final boolean hasError() throws IOException {
044:                return getResponseCode() / 100 != 2;
045:            }
046:
047:            public final String getErrorMessage() throws IOException {
048:                StringBuffer buffer = new StringBuffer(getResponseMessage());
049:                buffer.append(" [");
050:                buffer.append(getResponseCode());
051:                buffer.append(']');
052:                return buffer.toString();
053:            }
054:
055:            /*
056:             * Receiving response
057:             */
058:            protected final boolean hasResponse() throws IOException {
059:                if (getResponseCode() == HttpTransportConstants.STATUS_ACCEPTED) {
060:                    return false;
061:                }
062:                long contentLength = getResponseContentLength();
063:                if (contentLength < 0) {
064:                    if (responseBuffer == null) {
065:                        responseBuffer = FileCopyUtils
066:                                .copyToByteArray(getResponseInputStream());
067:                    }
068:                    contentLength = responseBuffer.length;
069:                }
070:                return contentLength > 0;
071:            }
072:
073:            protected final InputStream getResponseInputStream()
074:                    throws IOException {
075:                InputStream inputStream;
076:                if (responseBuffer != null) {
077:                    inputStream = new ByteArrayInputStream(responseBuffer);
078:                } else {
079:                    inputStream = getRawResponseInputStream();
080:                }
081:                return isGzipResponse() ? new GZIPInputStream(inputStream)
082:                        : inputStream;
083:            }
084:
085:            /** Determine whether the given response is a GZIP response. */
086:            private boolean isGzipResponse() throws IOException {
087:                for (Iterator iterator = getResponseHeaders(HttpTransportConstants.HEADER_CONTENT_ENCODING); iterator
088:                        .hasNext();) {
089:                    String encodingHeader = (String) iterator.next();
090:                    return encodingHeader.toLowerCase().indexOf(
091:                            HttpTransportConstants.CONTENT_ENCODING_GZIP) != -1;
092:                }
093:                return false;
094:            }
095:
096:            /** Returns the HTTP status code of the response. */
097:            protected abstract int getResponseCode() throws IOException;
098:
099:            /** Returns the HTTP status message of the response. */
100:            protected abstract String getResponseMessage() throws IOException;
101:
102:            /** Returns the length of the response. */
103:            protected abstract long getResponseContentLength()
104:                    throws IOException;
105:
106:            protected abstract InputStream getRawResponseInputStream()
107:                    throws IOException;
108:
109:            /*
110:             * Faults
111:             */
112:
113:            public final boolean hasFault() throws IOException {
114:                return getResponseCode() == HttpTransportConstants.STATUS_INTERNAL_SERVER_ERROR;
115:            }
116:
117:            public final void setFault(boolean fault) {
118:            }
119:
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.