Coverage Report - org.apache.xmlrpc.webserver.ConnectionServer
 
Classes in this File Line Coverage Branch Coverage Complexity
ConnectionServer
50% 
50% 
2,2
 
 1  
 /*
 2  
  * Copyright 1999,2005 The Apache Software Foundation.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.xmlrpc.webserver;
 17  
 
 18  
 import java.io.IOException;
 19  
 import java.io.InputStream;
 20  
 import java.io.OutputStream;
 21  
 
 22  
 import org.apache.xmlrpc.XmlRpcException;
 23  
 import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
 24  
 import org.apache.xmlrpc.server.XmlRpcStreamServer;
 25  
 
 26  
 
 27  154
 class ConnectionServer extends XmlRpcStreamServer {
 28  
         protected void writeError(XmlRpcStreamRequestConfig pConfig, OutputStream pStream,
 29  
                                                           Throwable pError) throws XmlRpcException {
 30  0
                 RequestData data = (RequestData) pConfig;
 31  
                 try {
 32  0
                         if (data.isByteArrayRequired()) {
 33  0
                                 super.writeError(pConfig, pStream, pError);
 34  0
                                 data.getConnection().writeError(data, pError, pStream);
 35  
                         } else {
 36  0
                                 data.getConnection().writeErrorHeader(data, pError, -1);
 37  0
                                 super.writeError(pConfig, pStream, pError);
 38  0
                                 pStream.flush();
 39  
                         }
 40  0
                 } catch (IOException e) {
 41  0
                         throw new XmlRpcException(e.getMessage(), e);
 42  
                 }
 43  0
         }
 44  
 
 45  
         protected void writeResponse(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, Object pResult) throws XmlRpcException {
 46  175
                 RequestData data = (RequestData) pConfig;
 47  
                 try {
 48  175
                         if (data.isByteArrayRequired()) {
 49  105
                                 super.writeResponse(pConfig, pStream, pResult);
 50  105
                                 data.getConnection().writeResponse(data, pStream);
 51  
                         } else {
 52  70
                                 data.getConnection().writeResponseHeader(data, -1);
 53  70
                                 super.writeResponse(pConfig, pStream, pResult);
 54  70
                                 pStream.flush();
 55  
                         }
 56  0
                 } catch (IOException e) {
 57  0
                         throw new XmlRpcException(e.getMessage(), e);
 58  
                 }
 59  175
         }
 60  
 
 61  
         protected InputStream newInputStream(XmlRpcStreamRequestConfig pConfig, Object pConnection) throws IOException {
 62  175
                 return ((Connection) pConnection).getInputStream((RequestData) pConfig);
 63  
         }
 64  
 
 65  
         protected OutputStream newOutputStream(XmlRpcStreamRequestConfig pConfig, Object pConnection) throws IOException {
 66  175
                 return ((Connection) pConnection).getOutputStream(pConfig);
 67  
         }
 68  
 
 69  
         protected void closeConnection(Object pConnection) throws IOException {
 70  175
         }
 71  
 }