Package org.springframework.data.rest.example

Source Code of org.springframework.data.rest.example.RestExporterWebInitializer

package org.springframework.data.rest.example;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

import org.springframework.data.rest.webmvc.RepositoryRestExporterServlet;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;

/**
* @author Jon Brisbin
*/
public class RestExporterWebInitializer implements WebApplicationInitializer {

  @Override public void onStartup(ServletContext ctx) throws ServletException {

    AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext();
    rootCtx.register(ApplicationConfig.class);

    ctx.addListener(new ContextLoaderListener(rootCtx));

    RepositoryRestExporterServlet exporter = new RepositoryRestExporterServlet();

    ServletRegistration.Dynamic reg = ctx.addServlet("rest-exporter", exporter);
    reg.setLoadOnStartup(1);
    reg.addMapping("/*");

  }

}
TOP

Related Classes of org.springframework.data.rest.example.RestExporterWebInitializer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.