Package javax.servlet

Examples of javax.servlet.ServletRegistration$Dynamic


        }

        try {
            String pushHandlerMapping;

            ServletRegistration servletRegistration = getServletRegistration(PushServlet.class, servletContext);
            if (servletRegistration == null) {
                registerPushServlet(servletContext);
                pushHandlerMapping = PUSH_CONTEXT_DEFAULT_MAPPING;
            } else {
                pushHandlerMapping = Iterables.get(servletRegistration.getMappings(), 0);
            }

            servletContext.setAttribute(PushContextFactoryImpl.PUSH_HANDLER_MAPPING_ATTRIBUTE, pushHandlerMapping);
        } catch (Exception e) {
            servletContext.log(MessageFormat.format("Caught exception when registering RichFaces Push Servlet: {0]", e.getMessage()), e);
View Full Code Here


        if (Boolean.valueOf(servletContext.getInitParameter(SKIP_SERVLET_REGISTRATION_PARAM))) {
            return;
        }

        try {
            ServletRegistration servletRegistration = getServletRegistration(ResourceServlet.class, servletContext);
            if (servletRegistration == null) {
                registerServlet(servletContext);
            }
        } catch (Exception e) {
            servletContext
View Full Code Here

public class CviewerServletListener implements ServletContextListener {

    public void contextInitialized(ServletContextEvent sce) {
        ServletContext sc = sce.getServletContext();
        // Regist servlet
        ServletRegistration sr = sc.addServlet("ClassViewer",
                "org.apache.geronimo.testsuite.servlet3.app.CViewerServlet");
        sr.addMapping("/ClassViewer");

        // Register Filter
        FilterRegistration fr = sc.addFilter("CViewerFilter",
                "org.apache.geronimo.testsuite.servlet3.app.CviewerFilter");
        fr.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), true,
View Full Code Here

            throws ServletException {
        for (Class tc : classes) {
            System.out.println(tc.getName());
        }
       
        ServletRegistration reg = ctx.addServlet("testAdd", AddedServletOnStartup.class);
        reg.addMapping("/add");
    }
View Full Code Here

       List<String> prefixMappings = null;
       if (registrations != null)
       {
           for (Map.Entry<String, ? extends ServletRegistration> entry : registrations.entrySet())
           {
               ServletRegistration registration = entry.getValue();
              
               if (FacesServlet.class.getName().equals(registration.getClassName()))
               {
                   for (String urlPattern :entry.getValue().getMappings())
                   {
                       //look for prefix mapping
                       String prefix;
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

    }

    private void onStartupImpl(Set<Class<?>> classes, final ServletContext servletContext) throws ServletException {
        // first see if there are any application classes in the web app
        for (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

    /**
     * Enhance default servlet (named {@link Application}) configuration.
     */
    private static void addServletWithDefaultConfiguration(final ServletContext sc, final 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 ResourceConfig resourceConfig = ResourceConfig.forApplicationClass(ResourceConfig.class, appClasses)
                    .addProperties(getInitParams(appReg))
                    .addProperties(WebComponent.getContextParams(sc));
            final ServletContainer s = new ServletContainer(resourceConfig);
            appReg = sc.addServlet(appReg.getName(), s);
            ((ServletRegistration.Dynamic) appReg).setLoadOnStartup(1);

            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

   * @param servletContext The context to get the ServletRegistration from.
   * @return ServletRegistration for FacesServlet, or <code>null</code> if the FacesServlet is not installed.
   * @since 1.8
   */
  public static ServletRegistration getFacesServletRegistration(ServletContext servletContext) {
    ServletRegistration facesServletRegistration = null;

    for (ServletRegistration registration : servletContext.getServletRegistrations().values()) {
      if (registration.getClassName().equals(FacesServlet.class.getName())) {
        facesServletRegistration = registration;
        break;
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.