Source Code Cross Referenced for HttpServiceProcessor.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » transport » http » server » 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 AXIS2 » kernal » org.apache.axis2.transport.http.server 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */
019:
020:        package org.apache.axis2.transport.http.server;
021:
022:        import org.apache.commons.logging.Log;
023:        import org.apache.commons.logging.LogFactory;
024:        import org.apache.http.ConnectionClosedException;
025:        import org.apache.http.HttpException;
026:        import org.apache.http.protocol.HttpContext;
027:        import org.apache.http.protocol.HttpExecutionContext;
028:
029:        import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
030:        import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong;
031:
032:        import java.io.IOException;
033:        import java.net.SocketException;
034:        import java.net.SocketTimeoutException;
035:
036:        /**
037:         * I/O processor intended to process requests and fill in responses.
038:         * 
039:         * @author Chuck Williams
040:         */
041:        public class HttpServiceProcessor implements  IOProcessor {
042:
043:            private static final Log LOG = LogFactory
044:                    .getLog(HttpServiceProcessor.class);
045:
046:            /** Counter used to create unique IDs. */
047:            private static AtomicLong counter = new AtomicLong(0L);
048:
049:            private AtomicBoolean terminated;
050:
051:            private final AxisHttpService httpservice;
052:
053:            private final AxisHttpConnection conn;
054:
055:            private final IOProcessorCallback callback;
056:
057:            /**
058:             * Unique identifier used by {@linkplain #equals(Object)} and
059:             * {@linkplain #hashCode()}.
060:             * <p>
061:             * This field is needed to allow the equals method to work properly when this
062:             * HttpServiceProcessor has to be removed from the list of processors.
063:             * 
064:             * @see DefaultHttpConnectionManager
065:             */
066:            private final long id;
067:
068:            public HttpServiceProcessor(final AxisHttpService httpservice,
069:                    final AxisHttpConnection conn,
070:                    final IOProcessorCallback callback) {
071:                super ();
072:                this .httpservice = httpservice;
073:                this .conn = conn;
074:                this .callback = callback;
075:                this .terminated = new AtomicBoolean(false);
076:
077:                id = counter.incrementAndGet();
078:            }
079:
080:            public void run() {
081:                LOG.debug("New connection thread");
082:                HttpContext context = new HttpExecutionContext(null);
083:                try {
084:                    while (!Thread.interrupted() && !isDestroyed()
085:                            && this .conn.isOpen()) {
086:                        this .httpservice.handleRequest(this .conn, context);
087:                    }
088:                } catch (ConnectionClosedException ex) {
089:                    LOG.debug("Client closed connection");
090:                } catch (IOException ex) {
091:                    if (ex instanceof  SocketTimeoutException) {
092:                        LOG.debug(ex.getMessage());
093:                    } else if (ex instanceof  SocketException) {
094:                        LOG.debug(ex.getMessage());
095:                    } else {
096:                        LOG.warn(ex.getMessage(), ex);
097:                    }
098:                } catch (HttpException ex) {
099:                    if (LOG.isWarnEnabled()) {
100:                        LOG.warn("HTTP protocol error: " + ex.getMessage());
101:                    }
102:                } finally {
103:                    destroy();
104:                    if (this .callback == null) {
105:                        throw new NullPointerException(
106:                                "The callback object can't be null");
107:                    }
108:                    this .callback.completed(this );
109:                }
110:            }
111:
112:            public void close() throws IOException {
113:                this .conn.close();
114:            }
115:
116:            public void destroy() {
117:                if (this .terminated.compareAndSet(false, true)) {
118:                    try {
119:                        //                this.conn.shutdown();
120:                        close();
121:                    } catch (IOException ex) {
122:                        LOG.debug("I/O error shutting down connection");
123:                    }
124:                }
125:            }
126:
127:            public boolean isDestroyed() {
128:                return this .terminated.get();
129:            }
130:
131:            // -------------------------------------------------- Methods from Object
132:
133:            /**
134:             * Returns the unique ID of this HttpServiceProcessor.
135:             * 
136:             * @return The unique ID of this HttpServiceProcessor.
137:             */
138:            public int hashCode() {
139:                final int PRIME = 31;
140:                int result = 1;
141:                result = PRIME * result + (int) (id ^ (id >>> 32));
142:                return result;
143:            }
144:
145:            /**
146:             * Indicates whether some other object is "equal to" this one.
147:             * 
148:             * @return <code>true</code> if this HttpServiceProcessor refere to the same 
149:             * object as obj or they have the same {@linkplain #id}, <code>false</code> otherwise.
150:             */
151:            public boolean equals(Object obj) {
152:                if (this  == obj)
153:                    return true;
154:                if (obj == null)
155:                    return false;
156:                if (getClass() != obj.getClass())
157:                    return false;
158:                final HttpServiceProcessor other = (HttpServiceProcessor) obj;
159:                if (id != other.id)
160:                    return false;
161:                return true;
162:            }
163:
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.