org.nsesa.editor.gwt.an.common.server.service.gwt.SpringRemoteServiceServlet.java Source code

Java tutorial

Introduction

Here is the source code for org.nsesa.editor.gwt.an.common.server.service.gwt.SpringRemoteServiceServlet.java

Source

/**
 * Copyright 2013 European Parliament
 *
 * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
 * You may not use this work except in compliance with the Licence.
 * You may obtain a copy of the Licence at:
 *
 * http://joinup.ec.europa.eu/software/page/eupl
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Licence for the specific language governing permissions and limitations under the Licence.
 */
package org.nsesa.editor.gwt.an.common.server.service.gwt;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Spring integration for a GWT {@link RemoteServiceServlet}.
 *
 * @author <a href="mailto:p.luppens@gmail.com">Philip Luppens</a>
 * @version $Id:$
 */

public class SpringRemoteServiceServlet extends RemoteServiceServlet
        implements ApplicationContextAware, ServletContextAware, Controller {

    protected ApplicationContext applicationContext;
    protected ServletContext servletContext;

    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // dispatch as POST
        doPost(request, response);
        // do not dispatch to any view
        return null;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @Override
    public void setServletContext(ServletContext context) {
        this.servletContext = context;
    }

    @Override
    public ServletContext getServletContext() {
        return servletContext;
    }

    @Override
    public String getServletName() {
        return "gwt-spring";
    }
}