Package javax.servlet

Examples of javax.servlet.ServletRegistration$Dynamic


    cacheProvider.setParameters(getCacheSetting(context));

    // Installs a filter that on demands buffers the response from the Faces Servlet, in order to grab child content
    // from the buffer.
    if (Boolean.TRUE.equals(Boolean.valueOf(context.getInitParameter(CACHE_INSTALL_BUFFER_FILTER)))) {
      ServletRegistration facesServletRegistration = getFacesServletRegistration(context);
      FilterRegistration bufferFilterRegistration = context.addFilter(OnDemandResponseBufferFilter.class.getName(), OnDemandResponseBufferFilter.class);
      bufferFilterRegistration.addMappingForServletNames(null, true, facesServletRegistration.getName());
    }
  }
View Full Code Here


   * @param servletContext The involved servlet context.
   * @param extensions collections of extensions (typically those as encountered during scanning)
   */
  public static void mapFacesServlet(ServletContext servletContext, Set<String> extensions) {

      ServletRegistration facesServletRegistration = getFacesServletRegistration(servletContext);
      if (facesServletRegistration != null) {
          Collection<String> mappings = facesServletRegistration.getMappings();
          for (String extension : extensions) {
              if (!mappings.contains(extension)) {
                  facesServletRegistration.addMapping(extension);
              }
          }
      }
  }
View Full Code Here

    @SuppressWarnings("unchecked")
    Set<String> extensions = (Set<String>) servletContext.getAttribute(FACES_SERVLET_EXTENSIONS);

    if (extensions == null) {
      extensions = new HashSet<>();
      ServletRegistration facesServletRegistration = getFacesServletRegistration(servletContext);
        if (facesServletRegistration != null) {
            Collection<String> mappings = facesServletRegistration.getMappings();
            for (String mapping : mappings) {
              if (mapping.startsWith("*")) {
                extensions.add(mapping.substring(1));
              }
            }
View Full Code Here

    }

    void paths(ServletContext sc) {
        Map<String, ? extends ServletRegistration> m = config.getServletContext().getServletRegistrations();

        ServletRegistration sr =  m.get(config.getServletConfig().getServletName());

        if (sr != null) {
            for(String mapping : sr.getMappings()) {
                if (mapping.contains("*")) {
                    mapping = mapping.replace("*", AtmosphereFramework.MAPPING_REGEX);
                }

                if (mapping.endsWith("/")) {
View Full Code Here

    @Test
    public void testInitParams() throws Exception
    {
        ServletHolder holder = new ServletHolder(Source.JAVAX_API);
        ServletRegistration reg = holder.getRegistration();
        try
        {
            reg.setInitParameter(null, "foo");
            fail("null name accepted");
        }
        catch (IllegalArgumentException e)
        {
        }
        try
        {
            reg.setInitParameter("foo", null);
            fail("null value accepted");
        }
        catch (IllegalArgumentException e)
        {
        }
        reg.setInitParameter("foo", "bar");
        assertFalse(reg.setInitParameter("foo", "foo"));

        Set<String> clash = reg.setInitParameters(Collections.singletonMap("foo", "bax"));
        assertTrue("should be one clash", clash != null && clash.size() == 1);

        try
        {
            reg.setInitParameters(Collections.singletonMap((String) null, "bax"));
            fail("null name in map accepted");
        }
        catch (IllegalArgumentException e)
        {
        }
        try
        {
            reg.setInitParameters(Collections.singletonMap("foo", (String) null));
            fail("null value in map accepted");
        }
        catch (IllegalArgumentException e)
        {
        }

        Set<String> clash2 = reg.setInitParameters(Collections.singletonMap("FOO", "bax"));
        assertTrue("should be no clash", clash2.isEmpty());
        assertEquals("setInitParameters should not replace existing non-clashing init parameters", 2, reg.getInitParameters().size());

    }
View Full Code Here

                    // FacesServlet has already been defined, so we're
                    // not going to add additional mappings;
                    return;
                }
            }
            ServletRegistration reg =
                  servletContext.addServlet("FacesServlet",
                                            "javax.faces.webapp.FacesServlet");
            reg.addMapping("/faces/*", "*.jsf", "*.faces");
            servletContext.setAttribute(RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED, Boolean.TRUE);


            // The following line is temporary until we can solve an ordering
            // issue in V3.  Right now the JSP container looks for a mapping
View Full Code Here

            }
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE,
                           "Registering FacesServlet with mappings '/faces/*', '*.jsf', and '*.faces'.");
            }
            ServletRegistration reg =
                  servletContext.addServlet("FacesServlet",
                                            "javax.faces.webapp.FacesServlet");
            reg.addMapping("/faces/*", "*.jsf", "*.faces");
            servletContext.setAttribute(RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED, Boolean.TRUE);

            // The following line is temporary until we can solve an ordering
            // issue in V3.  Right now the JSP container looks for a mapping
            // of the FacesServlet in the web.xml.  If it's not present, then
View Full Code Here

        env.addTask(task);

        handler.setServer(new Server());
        handler.start();

        final ServletRegistration registration = handler.getServletHandler()
                                                        .getServletContext()
                                                        .getServletRegistration("tasks");
        assertThat(registration.getMappings())
                .containsOnly("/tasks/*");
    }
View Full Code Here

            // servlet class and servlet instance can be both null or one of them is specified exclusively.
            final HttpServlet servletInstance = deploymentContext.getServletInstance();
            final Class<? extends HttpServlet> servletClass = deploymentContext.getServletClass();
            if (servletInstance != null || servletClass != null) {
                final ServletRegistration registration;
                if (servletInstance != null) {
                    registration = context.addServlet(servletInstance.getClass().getName(), servletInstance);
                } else {
                    registration = context.addServlet(servletClass.getName(), servletClass);
                }
                registration.setInitParameters(deploymentContext.getInitParams());
                registration.addMapping(servletPathLocal);
            }

            for (final Class<? extends EventListener> eventListener : deploymentContext.getListeners()) {
                context.addListener(eventListener);
            }
View Full Code Here

    }

    private void onStartupImpl(final Set<Class<?>> classes, final ServletContext servletContext) throws ServletException {
        // first see if there are any application classes in the web app
        for (final Class<? extends Application> applicationClass : getApplicationClasses(classes)) {
            final ServletRegistration servletRegistration = servletContext.getServletRegistration(applicationClass.getName());

            if (servletRegistration != null) {
                addServletWithExistingRegistration(servletContext, servletRegistration, applicationClass, classes);
            } else {
                // Servlet is not registered with app name or the app name is used to register a different servlet
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.