org.eclipse.sw360.projects.Sw360ThriftServlet.java Source code

Java tutorial

Introduction

Here is the source code for org.eclipse.sw360.projects.Sw360ThriftServlet.java

Source

/*
 * Copyright Siemens AG, 2015. Part of the SW360 Portal Project.
 *
 * SPDX-License-Identifier: EPL-1.0
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.eclipse.sw360.projects;

import org.apache.log4j.Logger;
import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.server.TServlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import static org.apache.log4j.Logger.getLogger;

/**
 * @author Andreas.Reichel@tngtech.com
 */
public class Sw360ThriftServlet extends TServlet {
    private static final Logger log = getLogger(Sw360ThriftServlet.class);

    public Sw360ThriftServlet(TProcessor processor, TProtocolFactory protocolFactory) {
        super(processor, protocolFactory);
    }

    public Sw360ThriftServlet(TProcessor processor, TProtocolFactory inProtocolFactory,
            TProtocolFactory outProtocolFactory) {
        super(processor, inProtocolFactory, outProtocolFactory);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            super.doPost(request, response);
        } catch (Exception e) {
            log.error("uncaught", e);
            throw e;
        }
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            super.doGet(request, response);
        } catch (Exception e) {
            log.error("uncaught", e);
            throw e;
        }
    }
}