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 javax.servlet.ServletException;
021import javax.servlet.http.HttpServletRequest;
022import javax.servlet.http.HttpServletResponse;
023
024import org.springframework.web.HttpRequestHandler;
025import org.springframework.web.HttpRequestMethodNotSupportedException;
026import org.springframework.web.util.NestedServletException;
027
028/**
029 * Servlet-API-based HTTP request handler that exports the specified service bean
030 * as Burlap service endpoint, accessible via a Burlap proxy.
031 *
032 * <p><b>Note:</b> Spring also provides an alternative version of this exporter,
033 * for Sun's JRE 1.6 HTTP server: {@link SimpleBurlapServiceExporter}.
034 *
035 * <p>Burlap is a slim, XML-based RPC protocol.
036 * For information on Burlap, see the
037 * <a href="https://www.caucho.com/burlap">Burlap website</a>.
038 * This exporter requires Burlap 3.x.
039 *
040 * <p>Note: Burlap services exported with this class can be accessed by
041 * any Burlap client, as there isn't any special handling involved.
042 *
043 * @author Juergen Hoeller
044 * @since 13.05.2003
045 * @see BurlapClientInterceptor
046 * @see BurlapProxyFactoryBean
047 * @see org.springframework.remoting.caucho.HessianServiceExporter
048 * @see org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter
049 * @see org.springframework.remoting.rmi.RmiServiceExporter
050 * @deprecated as of Spring 4.0, since Burlap hasn't evolved in years
051 * and is effectively retired (in contrast to its sibling Hessian)
052 */
053@Deprecated
054public class BurlapServiceExporter extends BurlapExporter implements HttpRequestHandler {
055
056        /**
057         * Processes the incoming Burlap request and creates a Burlap response.
058         */
059        @Override
060        public void handleRequest(HttpServletRequest request, HttpServletResponse response)
061                        throws ServletException, IOException {
062
063                if (!"POST".equals(request.getMethod())) {
064                        throw new HttpRequestMethodNotSupportedException(request.getMethod(),
065                                        new String[] {"POST"}, "BurlapServiceExporter only supports POST requests");
066                }
067
068                try {
069                  invoke(request.getInputStream(), response.getOutputStream());
070                }
071                catch (Throwable ex) {
072                  throw new NestedServletException("Burlap skeleton invocation failed", ex);
073                }
074        }
075
076}