ConnectionServer.java
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one
00003  * or more contributor license agreements.  See the NOTICE file
00004  * distributed with this work for additional information
00005  * regarding copyright ownership.  The ASF licenses this file
00006  * to you under the Apache License, Version 2.0 (the
00007  * "License"); you may not use this file except in compliance
00008  * with the License.  You may obtain a copy of the License at
00009  *
00010  *   http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing,
00013  * software distributed under the License is distributed on an
00014  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00015  * KIND, either express or implied.  See the License for the
00016  * specific language governing permissions and limitations
00017  * under the License.    
00018  */
00019 package org.apache.xmlrpc.webserver;
00020 
00021 import java.io.ByteArrayOutputStream;
00022 import java.io.IOException;
00023 import java.io.OutputStream;
00024 
00025 import org.apache.xmlrpc.XmlRpcException;
00026 import org.apache.xmlrpc.common.ServerStreamConnection;
00027 import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
00028 import org.apache.xmlrpc.server.XmlRpcHttpServer;
00029 
00030 
00031 class ConnectionServer extends XmlRpcHttpServer {
00032         protected void writeError(XmlRpcStreamRequestConfig pConfig, OutputStream pStream,
00033                                                           Throwable pError) throws XmlRpcException {
00034                 RequestData data = (RequestData) pConfig;
00035                 try {
00036                         if (data.isByteArrayRequired()) {
00037                                 super.writeError(pConfig, pStream, pError);
00038                                 data.getConnection().writeError(data, pError, (ByteArrayOutputStream) pStream);
00039                         } else {
00040                                 data.getConnection().writeErrorHeader(data, pError, -1);
00041                                 super.writeError(pConfig, pStream, pError);
00042                                 pStream.flush();
00043                         }
00044                 } catch (IOException e) {
00045                         throw new XmlRpcException(e.getMessage(), e);
00046                 }
00047         }
00048 
00049         protected void writeResponse(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, Object pResult) throws XmlRpcException {
00050                 RequestData data = (RequestData) pConfig;
00051                 try {
00052                         if (data.isByteArrayRequired()) {
00053                                 super.writeResponse(pConfig, pStream, pResult);
00054                                 data.getConnection().writeResponse(data, pStream);
00055                         } else {
00056                                 data.getConnection().writeResponseHeader(data, -1);
00057                                 super.writeResponse(pConfig, pStream, pResult);
00058                                 pStream.flush();
00059                         }
00060                 } catch (IOException e) {
00061                         throw new XmlRpcException(e.getMessage(), e);
00062                 }
00063         }
00064 
00065         protected void setResponseHeader(ServerStreamConnection pConnection, String pHeader, String pValue) {
00066                 ((Connection) pConnection).setResponseHeader(pHeader, pValue);
00067         }
00068 }


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49