Package javax.servlet.ServletRegistration

Examples of javax.servlet.ServletRegistration.Dynamic


    /**
     * Uses dynamic servlet registartaion for registering PushServlet automatically
     */
    private static void registerPushServlet(ServletContext context) {
        Dynamic dynamicRegistration = context.addServlet("AutoRegisteredPushServlet", PushServlet.class);
        dynamicRegistration.addMapping(PUSH_CONTEXT_DEFAULT_MAPPING);
        dynamicRegistration.setAsyncSupported(true);

        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Auto-registered servlet " + PushServlet.class.getSimpleName() + " with mapping '" + PUSH_CONTEXT_DEFAULT_MAPPING + "'");
        }
    }
View Full Code Here


                    .log(MessageFormat.format("Exception registering RichFaces Resource Servlet: {0]", e.getMessage()), e);
        }
    }

    private static void registerServlet(ServletContext context) {
        Dynamic dynamicRegistration = context.addServlet("AutoRegisteredResourceServlet", ResourceServlet.class);
        dynamicRegistration.addMapping(RICHFACES_RESOURCES_DEFAULT_MAPPING);

        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Auto-registered servlet " + ResourceServlet.class.getSimpleName() + " with mapping '" + RICHFACES_RESOURCES_DEFAULT_MAPPING + "'");
        }
    }
View Full Code Here

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

    TomcatBitcoinServlet servlet = new TomcatBitcoinServlet();

    Dynamic registration = servletContext.addServlet("ws", servlet);
    registration.addMapping("/tomcat");
    registration.setLoadOnStartup(1);

    Broadcaster broadcaster = servlet;

    AbstractMtgoxClient mtgoxClient = new StubMtgoxClient(broadcaster);
//    AbstractMtgoxClient mtgoxClient = new JettyMtgoxClient(broadcaster);
View Full Code Here

    public void contextInitialized(ServletContextEvent servletContextEvent) {

        ServletContext servletContext = servletContextEvent.getServletContext();

        //dynamic register /SampleServlet3Dynamic and security constraint
        Dynamic servlet3Dynamic = servletContext.addServlet("SampleServlet3Dynamic", SampleServlet3.class);
        servlet3Dynamic.addMapping("/SampleServlet3Dynamic", "/TestDynamic");
        HttpConstraintElement httpConstraintElement = new HttpConstraintElement();
        List<HttpMethodConstraintElement> httpMethodConstraintElements = new ArrayList<HttpMethodConstraintElement>();
        httpMethodConstraintElements.add(new HttpMethodConstraintElement("GET", new HttpConstraintElement(ServletSecurity.TransportGuarantee.NONE, "RoleC")));
        ServletSecurityElement servletSecurityElement = new ServletSecurityElement(httpConstraintElement, httpMethodConstraintElements);
        Set<String> uneffectedUrlPatterns = servlet3Dynamic.setServletSecurity(servletSecurityElement);
        if (uneffectedUrlPatterns.size() == 0) {
            throw new RuntimeException("/SampleServlet3Dynamic should be returned as it is defined in the web.xml file");
        }
        servlet3Dynamic.addMapping("/TestDynamicAfter");
    }
View Full Code Here

    public static void registerWebActor(ServletContext sc, Class<?> webActorClass) {
        final WebActor waAnn = webActorClass.getAnnotation(WebActor.class);
        final String name = (waAnn.name() != null && !waAnn.name().isEmpty()) ? waAnn.name() : webActorClass.getName();
        // servlet
        Dynamic d = sc.addServlet(name, WebActorServlet.class);
        d.setInitParameter(WebActorServlet.ACTOR_CLASS_PARAM, webActorClass.getName());
        d.setAsyncSupported(true);
        d.addMapping(waAnn.httpUrlPatterns());
        d.addMapping(waAnn.value());

        // web socket
        ServerContainer scon = (ServerContainer) sc.getAttribute("javax.websocket.server.ServerContainer");
        assert scon!=null : "Container does not support websockets !!!";
        for (String wsPath : waAnn.webSocketUrlPatterns()) {
View Full Code Here

    final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
    root.setServletContext(ctx);
    root.scan("app");
    root.refresh();

    final Dynamic servlet = ctx.addServlet("spring", new DispatcherServlet(root));
    servlet.setLoadOnStartup(1);
    servlet.addMapping("/");
  }
View Full Code Here

    ctx.register(WebAppConfig.class);
    servletContext.addListener(new ContextLoaderListener(ctx));

    ctx.setServletContext(servletContext);

    Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
    servlet.addMapping("/");
    servlet.setLoadOnStartup(1);
  }
View Full Code Here

    if (!isEnabled()) {
      logger.info("Filter " + name + " was not registered (disabled)");
      return;
    }
    logger.info("Mapping servlet: '" + name + "' to " + this.urlMappings);
    Dynamic added = servletContext.addServlet(name, this.servlet);
    if (added == null) {
      logger.info("Servlet " + name + " was not registered "
          + "(possibly already registered?)");
      return;
    }
View Full Code Here

public class H2ConsoleWebInitializer implements WebApplicationInitializer {

  @Override
  public void onStartup(ServletContext container) throws ServletException {
    WebServlet h2Servlet = new WebServlet();
    Dynamic dynamic = container.addServlet("H2Console", h2Servlet);
    dynamic.addMapping("/admin/h2/*");
  }
 
View Full Code Here

    private void registerWebActor(ServletContext sc, Class<?> webActorClass) {
        final WebActor waAnn = webActorClass.getAnnotation(WebActor.class);
        final String name = (waAnn.name() != null && !waAnn.name().isEmpty()) ? waAnn.name() : webActorClass.getName();
        // servlet
        Dynamic d = sc.addServlet(name, WebActorServlet.class);
        d.setInitParameter(WebActorServlet.ACTOR_CLASS_PARAM, webActorClass.getName());
        d.setAsyncSupported(true);
        d.addMapping(waAnn.httpUrlPatterns());
        d.addMapping(waAnn.value());

        // web socket
        final ServerContainer scon = (ServerContainer) sc.getAttribute("javax.websocket.server.ServerContainer");
        for (String wsPath : waAnn.webSocketUrlPatterns()) {
            try {
View Full Code Here

TOP

Related Classes of javax.servlet.ServletRegistration.Dynamic

Copyright © 2018 www.massapicom. 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.