Example usage for javax.servlet ServletContext addServlet

List of usage examples for javax.servlet ServletContext addServlet

Introduction

In this page you can find the example usage for javax.servlet ServletContext addServlet.

Prototype

public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass);

Source Link

Document

Adds the servlet with the given name and class type to this servlet context.

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  av a 2 s .  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);//  www  .j av a2 s .c o  m
}

From source file:sample.H2ConsoleInitializer.java

public void onStartup(ServletContext servletContext) throws ServletException {
    servletContext.addServlet("h2Console", new WebServlet()).addMapping("/h2-console/*");
}

From source file:com.dm.platform.listener.base.MyServletContextListener.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    System.out.println("MyServletContextListener");
    ServletContext sc = sce.getServletContext();

    ServletRegistration sr = sc.addServlet("spring", DispatcherServlet.class);
    sr.setInitParameter("contextConfigLocation", "/WEB-INF/dispatcher-servlet.xml");
    sr.addMapping("/spring/*");

    FilterRegistration fr = sc.addFilter(DynamicRegistFilter.class.getSimpleName(), DynamicRegistFilter.class);
    fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/platform/*");
    //          fr = sc.addFilter(DelegatingFilterProxy.class.getSimpleName(), DelegatingFilterProxy.class);
    //        fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/platform/*");

    sc.addListener(new ContextLoaderListener());
}

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: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.mycompany.testfile.config.WebConfig.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    ServletRegistration.Dynamic h2ConsoleServlet = servletContext.addServlet("H2Console",
            new org.h2.server.web.WebServlet());
    h2ConsoleServlet.addMapping("/console/*");
    h2ConsoleServlet.setInitParameter("-properties", "src/main/resources");
    h2ConsoleServlet.setLoadOnStartup(1);
}

From source file:com.volho.example.todo.web.config.WebAppInitializer.java

public void initH2Console(ServletContext servletContext) {
    ServletRegistration.Dynamic h2ConsoleServlet = servletContext.addServlet("H2Console",
            new org.h2.server.web.WebServlet());
    h2ConsoleServlet.addMapping("/console/*");
}

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:be.wolkmaan.klimtoren.web.config.WebAppInitializer.java

public void zkUpdateServlet(ServletContext servletContext) {
    ServletRegistration.Dynamic servlet = servletContext.addServlet("auEngine", new DHtmlUpdateServlet());
    servlet.addMapping("/zkau/*");
}