Example usage for javax.servlet ServletRegistration.Dynamic addMapping

List of usage examples for javax.servlet ServletRegistration.Dynamic addMapping

Introduction

In this page you can find the example usage for javax.servlet ServletRegistration.Dynamic addMapping.

Prototype

public Set<String> addMapping(String... urlPatterns);

Source Link

Document

Adds a servlet mapping with the given URL patterns for the Servlet represented by this ServletRegistration.

Usage

From source file:io.adeptj.runtime.common.Servlets.java

public static void registerBridgeServlet(ServletContext context) {
    // Register the BridgeServlet after the OSGi Framework started successfully.
    // This will ensure that the Felix DispatcherServlet is available as an OSGi service and can be tracked.
    // BridgeServlet delegates all the service calls to the Felix DispatcherServlet.
    ServletRegistration.Dynamic bridgeServlet = context.addServlet(BRIDGE_SERVLET, new BridgeServlet());
    bridgeServlet.addMapping(ROOT_MAPPING);
    // Required if [osgi.http.whiteboard.servlet.asyncSupported] is declared true for OSGi HttpService managed Servlets.
    // Otherwise the request processing fails throwing exception [java.lang.IllegalStateException: UT010026:
    // Async is not supported for this request, as not all filters or Servlets were marked as supporting async]
    bridgeServlet.setAsyncSupported(true);
    // Load early to detect any issue with OSGi Felix DispatcherServlet initialization.
    bridgeServlet.setLoadOnStartup(0);//from  www . j  a v  a 2s .co  m
}

From source file:com.adeptj.runtime.common.Servlets.java

public static void registerBridgeServlet(ServletContext context) {
    // Register the BridgeServlet after the OSGi Framework started successfully.
    // This will ensure that the Felix DispatcherServlet is available as an OSGi service and can be tracked.
    // BridgeServlet delegates all the service calls to the Felix DispatcherServlet.
    ServletRegistration.Dynamic bridgeServlet = context.addServlet(BRIDGE_SERVLET, new BridgeServlet());
    bridgeServlet.addMapping(ROOT_MAPPING);
    // Required if [osgi.http.whiteboard.servlet.asyncSupported] is declared true for OSGi HttpService managed Servlets.
    // Otherwise the request processing fails throwing exception.
    // [java.lang.IllegalStateException: UT010026: Async is not supported for this request, as not all filters or Servlets
    // were marked as supporting async]
    bridgeServlet.setAsyncSupported(true);
    // Load early to detect any issue with OSGi Felix DispatcherServlet initialization.
    bridgeServlet.setLoadOnStartup(0);/*from   ww w  . j  av  a 2  s .  c  om*/
}

From source file:ip.ip.rest.config.WebAppInitializer.java

public void onStartup(javax.servlet.ServletContext sc) throws javax.servlet.ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(ApplicationConfig.class);
    ctx.setServletContext(sc);//from  ww  w.  j  a v  a  2  s  . c  o m
    ServletRegistration.Dynamic dynamic = sc.addServlet("dispatcher", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);
}

From source file:es.adama.archetype.configuration.H2Initializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    ServletRegistration.Dynamic dynamic = servletContext.addServlet("h2", new WebServlet());
    dynamic.addMapping("/h2/*");
}

From source file:com.mycompany.comerciobici.controlador.InicializadorRest.java

public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(CargadorApplicacion.class);
    ctx.setServletContext(servletContext);
    ServletRegistration.Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);//from  www  .j a v a2  s  .  c o m
}

From source file:org.teavm.flavour.example.server.ApplicationInitializer.java

private void initJersey(ServletContext servletContext) {
    JerseyInitializer.servletContext = servletContext;
    ServletRegistration.Dynamic reg = servletContext.addServlet("jersey", ServletContainer.class);
    reg.addMapping("/api/*");
    reg.setInitParameter("javax.ws.rs.Application", JerseyInitializer.class.getName());
}

From source file:com.mycompany.config.WebInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(Config.class);
    ctx.setServletContext(servletContext);
    ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);/*from   w  w  w  .  j ava2 s.c  om*/
}

From source file:br.sp.mandala.config.AnnotationConfig.java

private void registerJAXWSServlet(ServletContext servletContext) {
    ServletRegistration.Dynamic jaxWsServlet = servletContext.addServlet("cxf", new CXFServlet());
    jaxWsServlet.addMapping("/ws/*");
}

From source file:com.olegchir.fadeok.init.AppInitializer.java

public void onStartup(ServletContext servletContext) throws ServletException {
    System.out.println("Initializing Application for " + servletContext.getServerInfo());

    //Create webapp context
    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.setConfigLocation(CONFIG_LOCATION);

    servletContext.addListener(new ContextLoaderListener(applicationContext));
    //        servletContext.addListener(new CompleteAutoloadTilesListener());

    // Add the servlet mapping manually and make it initialize automatically
    DispatcherServlet dispatcherServlet = new DispatcherServlet(applicationContext);
    ServletRegistration.Dynamic servlet = servletContext.addServlet("mvc-dispatcher", dispatcherServlet);

    servlet.addMapping("/");
    servlet.setAsyncSupported(true);/*from   w  w  w.  jav  a2s.co m*/
    servlet.setLoadOnStartup(1);
}

From source file:com.controller.config.MainWebApplicationInitizer.java

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

    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
    rootContext.scan("com.controller.config");

    servletContext.addListener(new ContextLoaderListener(rootContext));

    ServletRegistration.Dynamic dispather = servletContext.addServlet("CXFServlet", CXFServlet.class);

    dispather.addMapping("/rest/*");
}