Package javax.servlet

Examples of javax.servlet.ServletRegistration$Dynamic


     * Enhance default servlet (named {@link Application}) configuration.
     */
    private static void addServletWithDefaultConfiguration(final ServletContext context,
                                                           final Set<Class<?>> classes) throws ServletException {

        ServletRegistration registration = context.getServletRegistration(Application.class.getName());

        if (registration != null) {
            final Set<Class<?>> appClasses = getRootResourceAndProviderClasses(classes);
            final ResourceConfig resourceConfig = ResourceConfig.forApplicationClass(ResourceConfig.class, appClasses)
                    .addProperties(getInitParams(registration))
                    .addProperties(Utils.getContextParams(context));

            if (registration.getClassName() != null) {
                // class name present - complete servlet registration from container point of view
                Utils.store(resourceConfig, context);
            } else {
                // no class name - no complete servlet registration from container point of view
                final ServletContainer servlet = new ServletContainer(resourceConfig);
                registration = context.addServlet(registration.getName(), servlet);
                ((ServletRegistration.Dynamic) registration).setLoadOnStartup(1);

                if (registration.getMappings().isEmpty()) {
                    // Error
                    LOGGER.log(Level.WARNING, LocalizationMessages.JERSEY_APP_NO_MAPPING(registration.getName()));
                } else {
                    LOGGER.log(Level.CONFIG,
                            LocalizationMessages.JERSEY_APP_REGISTERED_CLASSES(registration.getName(), appClasses));
                }
            }
        }
    }
View Full Code Here


        if (classes == null) {
            classes = Collections.<Class<?>>emptySet();
        }
        final int nOfRegisterations = sc.getServletRegistrations().size();
        for (Class<? extends Application> a : getApplicationClasses(classes)) {
            final ServletRegistration appReg = sc.getServletRegistration(a.getName());
            if (appReg != null) {
                // Servlet is registered with app name
               
                addServletWithExistingRegistration(sc, appReg, a, classes);
            } else {
View Full Code Here

        return srs;
    }

    private void addServletWithDefaultConfiguration(ServletContext sc, Set<Class<?>> classes) {
        ServletRegistration appReg = sc.getServletRegistration(Application.class.getName());
        if (appReg != null && appReg.getClassName() == null) {
            final Set<Class<?>> x = getRootResourceAndProviderClasses(classes);
            final ServletContainer s = new ServletContainer(
                    new DefaultResourceConfig(x));
            appReg = sc.addServlet(appReg.getName(), s);

            if (appReg.getMappings().isEmpty()) {
                // Error
                LOGGER.severe("The Jersey servlet application, named " +
                        appReg.getName() +
                        ", has no servlet mapping");
            } else {
                LOGGER.info("Registering the Jersey servlet application, named " +
                        appReg.getName() +
                        ", with the following root resource and provider classes: " + x);
            }
        }
    }
View Full Code Here

      }
   }

   protected void handleNoApplicationClass(Set<Class<?>> providers, Set<Class<?>> resources, ServletContext servletContext)
   {
      ServletRegistration defaultApp = null;
      for (ServletRegistration reg : servletContext.getServletRegistrations().values())
      {
         if (reg.getName().equals(Application.class.getName()))
         {
            defaultApp = reg;
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
            // of the FacesServlet in the web.xml.  If it's not present, then
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
            // of the FacesServlet in the web.xml.  If it's not present, then
View Full Code Here

        if (classes == null) {
            classes = Collections.emptySet();
        }
        // first see if there are any application classes in the web app
        for (Class<? extends Application> a : getApplicationClasses(classes)) {
            final ServletRegistration appReg = sc.getServletRegistration(a.getName());

            if (appReg != null) {
                addServletWithExistingRegistration(sc, appReg, a, classes);
            } else {
                // Servlet is not registered with app name or the app name is used to register a different servlet
View Full Code Here

            }
        }
    }

    private void addServletWithDefaultConfiguration(ServletContext sc, Set<Class<?>> classes) throws ServletException {
        ServletRegistration appReg = sc.getServletRegistration(Application.class.getName());
        if (appReg != null && appReg.getClassName() == null) {
            final Set<Class<?>> appClasses = getRootResourceAndProviderClasses(classes);
            final ServletContainer s = new ServletContainer(
                    ResourceConfig.forApplicationClass(ResourceConfig.class, appClasses).addProperties(getInitParams(appReg))
                    .addProperties(WebComponent.getContextParams(sc))
            );
            appReg = sc.addServlet(appReg.getName(), s);

            if (appReg.getMappings().isEmpty()) {
                // Error
                LOGGER.log(Level.SEVERE, LocalizationMessages.JERSEY_APP_NO_MAPPING(appReg.getName()));
            } else {
                LOGGER.log(Level.INFO, LocalizationMessages.JERSEY_APP_REGISTERED_CLASSES(appReg.getName(), appClasses));
            }
        }
    }
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
            // of the FacesServlet in the web.xml.  If it's not present, then
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

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.