Package javax.servlet

Examples of javax.servlet.ServletContainerInitializer


                // Should never happen with UTF-8
                // If it does - ignore & return null
            }
        }
       
        ServletContainerInitializer sci = null;
        try {
            Class<?> clazz = Class.forName(className,true,
                    context.getLoader().getClassLoader());
             sci = (ServletContainerInitializer) clazz.newInstance();
        } catch (ClassNotFoundException e) {
View Full Code Here


        // Must have a real docBase - just use temp
        Context ctx =
            tomcat.addContext("", System.getProperty("java.io.tmpdir"));
       
        Servlet s = new DenyAllServlet();
        ServletContainerInitializer sci = new SCI(s, useCreateServlet);
        ctx.addServletContainerInitializer(sci, null);
       
        tomcat.start();
       
        ByteChunk bc = new ByteChunk();
View Full Code Here

       
        for (WebXml fragment : fragments) {
            URL url = fragment.getURL();
            JarFile jarFile = null;
            InputStream is = null;
            ServletContainerInitializer sci = null;
            try {
                if ("jar".equals(url.getProtocol())) {
                    JarURLConnection conn =
                        (JarURLConnection) url.openConnection();
                    jarFile = conn.getJarFile();
                    ZipEntry entry = jarFile.getEntry(SCI_LOCATION);
                    if (entry != null) {
                        is = jarFile.getInputStream(entry);
                    }
                } else if ("file".equals(url.getProtocol())) {
                    String path = url.getPath();
                    File file = new File(path, SCI_LOCATION);
                    if (file.exists()) {
                        is = new FileInputStream(file);
                    }
                }
                if (is != null) {
                    sci = getServletContainerInitializer(is);
                }
            } catch (IOException ioe) {
                log.error(sm.getString(
                        "contextConfig.servletContainerInitializerFail", url,
                        context.getName()));
                ok = false;
                return;
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                        // Ignore
                    }
                }
                if (jarFile != null) {
                    try {
                        jarFile.close();
                    } catch (IOException e) {
                        // Ignore
                    }
                }
            }
           
            if (sci == null) {
                continue;
            }

            initializerClassMap.put(sci, new HashSet<Class<?>>());
           
            HandlesTypes ht =
                sci.getClass().getAnnotation(HandlesTypes.class);
            if (ht != null) {
                Class<?>[] types = ht.value();
                if (types != null) {
                    for (Class<?> type : types) {
                        Set<ServletContainerInitializer> scis =
View Full Code Here

                // Should never happen with UTF-8
                // If it does - ignore & return null
            }
        }
       
        ServletContainerInitializer sci = null;
        try {
            Class<?> clazz = Class.forName(className,true,
                    context.getLoader().getClassLoader());
             sci = (ServletContainerInitializer) clazz.newInstance();
        } catch (ClassNotFoundException e) {
View Full Code Here

        lc.setAuthMethod("BASIC");
        ctx.setLoginConfig(lc);
        ctx.getPipeline().addValve(new BasicAuthenticator());

        // Add ServletContainerInitializer
        ServletContainerInitializer sci = new Bug50015SCI();
        ctx.addServletContainerInitializer(sci, null);

        // Start the context
        tomcat.start();
View Full Code Here

        lc.setAuthMethod("BASIC");
        ctx.setLoginConfig(lc);
        ctx.getPipeline().addValve(new BasicAuthenticator());

        // Add ServletContainerInitializer
        ServletContainerInitializer sci = new DenyUncoveredHttpMethodsSCI();
        ctx.addServletContainerInitializer(sci, null);

        // Start the context
        tomcat.start();
View Full Code Here

            if (servletContainerInitializerClassNamesMap != null) {
                for (Map.Entry<String, Set<String>> entry : servletContainerInitializerClassNamesMap.entrySet()) {
                    String servletContainerInitializerClassName = entry.getKey();
                    Set<String> classNames = entry.getValue();
                    try {
                        ServletContainerInitializer servletContainerInitializer = (ServletContainerInitializer) bundle.loadClass(servletContainerInitializerClassName).newInstance();
                        if (classNames == null || classNames.size() == 0) {
                            addServletContainerInitializer(servletContainerInitializer, null);
                        } else {
                            Set<Class<?>> classSet = new HashSet<Class<?>>();
                            for (String cls : classNames) {
View Full Code Here

       
        for (WebXml fragment : fragments) {
            URL url = fragment.getURL();
            JarFile jarFile = null;
            InputStream is = null;
            ServletContainerInitializer sci = null;
            try {
                if ("jar".equals(url.getProtocol())) {
                    JarURLConnection conn =
                        (JarURLConnection) url.openConnection();
                    jarFile = conn.getJarFile();
                    ZipEntry entry = jarFile.getEntry(SCI_LOCATION);
                    if (entry != null) {
                        is = jarFile.getInputStream(entry);
                    }
                } else if ("file".equals(url.getProtocol())) {
                    String path = url.getPath();
                    File file = new File(path, SCI_LOCATION);
                    if (file.exists()) {
                        is = new FileInputStream(file);
                    }
                }
                if (is != null) {
                    sci = getServletContainerInitializer(is);
                }
            } catch (IOException ioe) {
                log.error(sm.getString(
                        "contextConfig.servletContainerInitializerFail", url,
                        context.getPath()));
                return false;
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                        // Ignore
                    }
                }
                if (jarFile != null) {
                    try {
                        jarFile.close();
                    } catch (IOException e) {
                        // Ignore
                    }
                }
            }
           
            if (sci == null) {
                continue;
            }

            initializerClassMap.put(sci, new HashSet<Class<?>>());
           
            HandlesTypes ht =
                sci.getClass().getAnnotation(HandlesTypes.class);
            if (ht != null) {
                Class<?>[] types = ht.value();
                if (types != null) {
                    for (Class<?> type : types) {
                        Set<ServletContainerInitializer> scis =
View Full Code Here

                // Should never happen with UTF-8
                // If it does - ignore & return null
            }
        }
       
        ServletContainerInitializer sci = null;
        try {
            Class<?> clazz = Class.forName(className,true,
                    context.getLoader().getClassLoader());
             sci = (ServletContainerInitializer) clazz.newInstance();
        } catch (ClassNotFoundException e) {
View Full Code Here

        } catch (final Throwable ignored) {
            // no-op
        }
        try {
            final Class<?> myfacesInitializer = Class.forName(MYFACES_TOMEEM_CONTAINER_INITIALIZER, true, classLoader);
            final ServletContainerInitializer instance = (ServletContainerInitializer) myfacesInitializer.newInstance();
            context.addServletContainerInitializer(instance, getJsfClasses(context));
            context.addApplicationListener(TOMEE_MYFACES_CONTEXT_LISTENER); // cleanup listener
        } catch (final Exception | NoClassDefFoundError ignored) {
            // no-op
        }
View Full Code Here

TOP

Related Classes of javax.servlet.ServletContainerInitializer

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.