XmlRpcLocalStreamTransport.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.client;
00020 
00021 import java.io.ByteArrayInputStream;
00022 import java.io.ByteArrayOutputStream;
00023 import java.io.IOException;
00024 import java.io.InputStream;
00025 
00026 import org.apache.xmlrpc.XmlRpcException;
00027 import org.apache.xmlrpc.XmlRpcRequest;
00028 import org.apache.xmlrpc.common.LocalStreamConnection;
00029 import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
00030 import org.apache.xmlrpc.common.XmlRpcStreamRequestProcessor;
00031 import org.xml.sax.SAXException;
00032 
00033 
00040 public class XmlRpcLocalStreamTransport extends XmlRpcStreamTransport {
00041         private final XmlRpcStreamRequestProcessor localServer;
00042         private LocalStreamConnection conn;
00043     private XmlRpcRequest request;
00044         
00049         public XmlRpcLocalStreamTransport(XmlRpcClient pClient,
00050                         XmlRpcStreamRequestProcessor pServer) {
00051                 super(pClient);
00052                 localServer = pServer;
00053         }
00054 
00055         protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) {
00056                 return pConfig.isGzipRequesting();
00057         }
00058 
00059         protected void close() throws XmlRpcClientException {
00060         }
00061 
00062         protected InputStream getInputStream() throws XmlRpcException {
00063                 localServer.execute(conn.getConfig(), conn.getServerStreamConnection());
00064                 return new ByteArrayInputStream(conn.getResponse().toByteArray());
00065         }
00066 
00067         protected ReqWriter newReqWriter(XmlRpcRequest pRequest)
00068             throws XmlRpcException, IOException, SAXException {
00069             request = pRequest;
00070         return super.newReqWriter(pRequest);
00071     }
00072 
00073     protected void writeRequest(ReqWriter pWriter)
00074             throws XmlRpcException, IOException, SAXException {
00075                 ByteArrayOutputStream baos = new ByteArrayOutputStream();               
00076                 pWriter.write(baos);
00077                 XmlRpcStreamRequestConfig config = (XmlRpcStreamRequestConfig) request.getConfig();
00078                 conn = new LocalStreamConnection(config, new ByteArrayInputStream(baos.toByteArray()));
00079         }
00080 }


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