001/* 002 * Copyright 2002-2013 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 * https://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 017package org.springframework.remoting.caucho; 018 019import java.io.IOException; 020import java.io.InputStream; 021import java.io.OutputStream; 022 023import com.caucho.burlap.io.BurlapInput; 024import com.caucho.burlap.io.BurlapOutput; 025import com.caucho.burlap.server.BurlapSkeleton; 026 027import org.springframework.beans.factory.InitializingBean; 028import org.springframework.remoting.support.RemoteExporter; 029import org.springframework.util.Assert; 030 031/** 032 * General stream-based protocol exporter for a Burlap endpoint. 033 * 034 * <p>Burlap is a slim, XML-based RPC protocol. 035 * For information on Burlap, see the 036 * <a href="https://www.caucho.com/burlap">Burlap website</a>. 037 * This exporter requires Burlap 3.x. 038 * 039 * @author Juergen Hoeller 040 * @since 2.5.1 041 * @see #invoke(java.io.InputStream, java.io.OutputStream) 042 * @see BurlapServiceExporter 043 * @see SimpleBurlapServiceExporter 044 * @deprecated as of Spring 4.0, since Burlap hasn't evolved in years 045 * and is effectively retired (in contrast to its sibling Hessian) 046 */ 047@Deprecated 048public class BurlapExporter extends RemoteExporter implements InitializingBean { 049 050 private BurlapSkeleton skeleton; 051 052 053 @Override 054 public void afterPropertiesSet() { 055 prepare(); 056 } 057 058 /** 059 * Initialize this service exporter. 060 */ 061 public void prepare() { 062 checkService(); 063 checkServiceInterface(); 064 this.skeleton = new BurlapSkeleton(getProxyForService(), getServiceInterface()); 065 } 066 067 068 /** 069 * Perform an invocation on the exported object. 070 * @param inputStream the request stream 071 * @param outputStream the response stream 072 * @throws Throwable if invocation failed 073 */ 074 public void invoke(InputStream inputStream, OutputStream outputStream) throws Throwable { 075 Assert.notNull(this.skeleton, "Burlap exporter has not been initialized"); 076 ClassLoader originalClassLoader = overrideThreadContextClassLoader(); 077 try { 078 this.skeleton.invoke(new BurlapInput(inputStream), new BurlapOutput(outputStream)); 079 } 080 finally { 081 try { 082 inputStream.close(); 083 } 084 catch (IOException ex) { 085 // ignore 086 } 087 try { 088 outputStream.close(); 089 } 090 catch (IOException ex) { 091 // ignore 092 } 093 resetThreadContextClassLoader(originalClassLoader); 094 } 095 } 096 097}