Package org.apache.tomcat.util.threads

Examples of org.apache.tomcat.util.threads.DedicatedThreadExecutor


                getServletContext().setAttribute(
                        InstanceManager.class.getName(), getInstanceManager());
            }
        }

        DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
        try {
           
            // Create context attributes that will be required
            if (ok) {
                getServletContext().setAttribute(
                        JarScanner.class.getName(), getJarScanner());
            }

            // Set up the context init params
            mergeParameters();

            // Call ServletContainerInitializers
            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry :
                initializers.entrySet()) {
                try {
                    entry.getKey().onStartup(entry.getValue(),
                            getServletContext());
                } catch (ServletException e) {
                    // TODO: Log error
                    ok = false;
                    break;
                }
            }

            // Configure and call application event listeners
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Listeners registers some ThreadLocals that they
                // forget to cleanup
                Boolean listenerStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(listenerStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!listenerStarted.booleanValue()) {
                    log.error( "Error listenerStart");
                    ok = false;
                }
            }
           
            try {
                // Start manager
                if ((manager != null) && (manager instanceof Lifecycle)) {
                    ((Lifecycle) getManager()).start();
                }
   
                // Start ContainerBackgroundProcessor thread
                super.threadStart();
            } catch(Exception e) {
                log.error("Error manager.start()", e);
                ok = false;
            }

            // Configure and call application filters
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Filters register some ThreadLocals that they forget
                // to cleanup
                Boolean filterStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(filterStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!filterStarted.booleanValue()) {
                    log.error("Error filterStart");
                    ok = false;
                }
            }
           
            // Load and initialize all "load on startup" servlets
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Servlets register some ThreadLocals that they forget
                // to cleanup
                temporaryExecutor.execute(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        ClassLoader old = bindThread();
                        try {
                            loadOnStartup(findChildren());
                            return null;
                        } finally {
                            unbindThread(old);
                        }
                    }
                });
            }
           
        } finally {
            // Unbinding thread
            unbindThread(oldCCL);
            temporaryExecutor.shutdown();
        }

        // Set available status depending upon startup success
        if (ok) {
            if (log.isDebugEnabled())
View Full Code Here


                getServletContext().setAttribute(
                        InstanceManager.class.getName(), getInstanceManager());
            }
        }

        DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
        try {
           
            // Create context attributes that will be required
            if (ok) {
                getServletContext().setAttribute(
                        JarScanner.class.getName(), getJarScanner());
            }

            // Set up the context init params
            mergeParameters();

            // Call ServletContainerInitializers
            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry :
                initializers.entrySet()) {
                try {
                    entry.getKey().onStartup(entry.getValue(),
                            getServletContext());
                } catch (ServletException e) {
                    // TODO: Log error
                    ok = false;
                    break;
                }
            }

            // Configure and call application event listeners
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Listeners registers some ThreadLocals that they
                // forget to cleanup
                Boolean listenerStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(listenerStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!listenerStarted.booleanValue()) {
                    log.error( "Error listenerStart");
                    ok = false;
                }
            }
           
            try {
                // Start manager
                if ((manager != null) && (manager instanceof Lifecycle)) {
                    ((Lifecycle) getManager()).start();
                }
   
                // Start ContainerBackgroundProcessor thread
                super.threadStart();
            } catch(Exception e) {
                log.error("Error manager.start()", e);
                ok = false;
            }

            // Configure and call application filters
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Filters register some ThreadLocals that they forget
                // to cleanup
                Boolean filterStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(filterStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!filterStarted.booleanValue()) {
                    log.error("Error filterStart");
                    ok = false;
                }
            }
           
            // Load and initialize all "load on startup" servlets
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Servlets register some ThreadLocals that they forget
                // to cleanup
                temporaryExecutor.execute(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        ClassLoader old = bindThread();
                        try {
                            loadOnStartup(findChildren());
                            return null;
                        } finally {
                            unbindThread(old);
                        }
                    }
                });
            }
           
        } finally {
            // Unbinding thread
            unbindThread(oldCCL);
            temporaryExecutor.shutdown();
        }

        // Set available status depending upon startup success
        if (ok) {
            if (log.isDebugEnabled())
View Full Code Here

                getServletContext().setAttribute(
                        InstanceManager.class.getName(), getInstanceManager());
            }
        }

        DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
        try {
           
            // Create context attributes that will be required
            if (ok) {
                getServletContext().setAttribute(
                        JarScanner.class.getName(), getJarScanner());
            }

            // Set up the context init params
            mergeParameters();

            // Call ServletContainerInitializers
            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry :
                initializers.entrySet()) {
                try {
                    entry.getKey().onStartup(entry.getValue(),
                            getServletContext());
                } catch (ServletException e) {
                    // TODO: Log error
                    ok = false;
                    break;
                }
            }

            // Configure and call application event listeners
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Listeners registers some ThreadLocals that they
                // forget to cleanup
                Boolean listenerStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(listenerStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!listenerStarted.booleanValue()) {
                    log.error( "Error listenerStart");
                    ok = false;
                }
            }
           
            try {
                // Start manager
                if ((manager != null) && (manager instanceof Lifecycle)) {
                    ((Lifecycle) getManager()).start();
                }
   
                // Start ContainerBackgroundProcessor thread
                super.threadStart();
            } catch(Exception e) {
                log.error("Error manager.start()", e);
                ok = false;
            }

            // Configure and call application filters
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Filters register some ThreadLocals that they forget
                // to cleanup
                Boolean filterStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(filterStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!filterStarted.booleanValue()) {
                    log.error("Error filterStart");
                    ok = false;
                }
            }
           
            // Load and initialize all "load on startup" servlets
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Servlets register some ThreadLocals that they forget
                // to cleanup
                temporaryExecutor.execute(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        ClassLoader old = bindThread();
                        try {
                            loadOnStartup(findChildren());
                            return null;
                        } finally {
                            unbindThread(old);
                        }
                    }
                });
            }
           
        } finally {
            // Unbinding thread
            unbindThread(oldCCL);
            temporaryExecutor.shutdown();
        }

        // Set available status depending upon startup success
        if (ok) {
            if (log.isDebugEnabled())
View Full Code Here

                getServletContext().setAttribute(
                        InstanceManager.class.getName(), getInstanceManager());
            }
        }

        DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
        try {
           
            // Create context attributes that will be required
            if (ok) {
                getServletContext().setAttribute(
                        JarScanner.class.getName(), getJarScanner());
            }

            // Set up the context init params
            mergeParameters();

            // Call ServletContainerInitializers
            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry :
                initializers.entrySet()) {
                try {
                    entry.getKey().onStartup(entry.getValue(),
                            getServletContext());
                } catch (ServletException e) {
                    // TODO: Log error
                    ok = false;
                    break;
                }
            }

            // Configure and call application event listeners
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Listeners registers some ThreadLocals that they
                // forget to cleanup
                Boolean listenerStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(listenerStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!listenerStarted.booleanValue()) {
                    log.error( "Error listenerStart");
                    ok = false;
                }
            }
           
            try {
                // Start manager
                if ((manager != null) && (manager instanceof Lifecycle)) {
                    ((Lifecycle) getManager()).start();
                }
   
                // Start ContainerBackgroundProcessor thread
                super.threadStart();
            } catch(Exception e) {
                log.error("Error manager.start()", e);
                ok = false;
            }

            // Configure and call application filters
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Filters register some ThreadLocals that they forget
                // to cleanup
                Boolean filterStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(filterStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!filterStarted.booleanValue()) {
                    log.error("Error filterStart");
                    ok = false;
                }
            }
           
            // Load and initialize all "load on startup" servlets
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Servlets register some ThreadLocals that they forget
                // to cleanup
                temporaryExecutor.execute(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        ClassLoader old = bindThread();
                        try {
                            loadOnStartup(findChildren());
                            return null;
                        } finally {
                            unbindThread(old);
                        }
                    }
                });
            }
           
        } finally {
            // Unbinding thread
            unbindThread(oldCCL);
            temporaryExecutor.shutdown();
        }

        // Set available status depending upon startup success
        if (ok) {
            if (log.isDebugEnabled())
View Full Code Here

                getServletContext().setAttribute(
                        InstanceManager.class.getName(), getInstanceManager());
            }
        }

        DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
        try {
           
            // Create context attributes that will be required
            if (ok) {
                getServletContext().setAttribute(
                        JarScanner.class.getName(), getJarScanner());
            }

            // Set up the context init params
            mergeParameters();

            // Call ServletContainerInitializers
            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry :
                initializers.entrySet()) {
                try {
                    entry.getKey().onStartup(entry.getValue(),
                            getServletContext());
                } catch (ServletException e) {
                    // TODO: Log error
                    ok = false;
                    break;
                }
            }

            // Configure and call application event listeners
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Listeners registers some ThreadLocals that they
                // forget to cleanup
                Boolean listenerStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(listenerStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!listenerStarted.booleanValue()) {
                    log.error( "Error listenerStart");
                    ok = false;
                }
            }
           
            try {
                // Start manager
                if ((manager != null) && (manager instanceof Lifecycle)) {
                    ((Lifecycle) getManager()).start();
                }
   
                // Start ContainerBackgroundProcessor thread
                super.threadStart();
            } catch(Exception e) {
                log.error("Error manager.start()", e);
                ok = false;
            }

            // Configure and call application filters
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Filters register some ThreadLocals that they forget
                // to cleanup
                Boolean filterStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(filterStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!filterStarted.booleanValue()) {
                    log.error("Error filterStart");
                    ok = false;
                }
            }
           
            // Load and initialize all "load on startup" servlets
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Servlets register some ThreadLocals that they forget
                // to cleanup
                temporaryExecutor.execute(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        ClassLoader old = bindThread();
                        try {
                            loadOnStartup(findChildren());
                            return null;
                        } finally {
                            unbindThread(old);
                        }
                    }
                });
            }
           
        } finally {
            // Unbinding thread
            unbindThread(oldCCL);
            temporaryExecutor.shutdown();
        }

        // Set available status depending upon startup success
        if (ok) {
            if (log.isDebugEnabled())
View Full Code Here

                getServletContext().setAttribute(
                        InstanceManager.class.getName(), getInstanceManager());
            }
        }

        DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
        try {
           
            // Create context attributes that will be required
            if (ok) {
                getServletContext().setAttribute(
                        JarScanner.class.getName(), getJarScanner());
            }

            // Set up the context init params
            mergeParameters();

            // Call ServletContainerInitializers
            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry :
                initializers.entrySet()) {
                try {
                    entry.getKey().onStartup(entry.getValue(),
                            getServletContext());
                } catch (ServletException e) {
                    // TODO: Log error
                    ok = false;
                    break;
                }
            }

            // Configure and call application event listeners
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Listeners registers some ThreadLocals that they
                // forget to cleanup
                Boolean listenerStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(listenerStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!listenerStarted.booleanValue()) {
                    log.error( "Error listenerStart");
                    ok = false;
                }
            }
           
            try {
                // Start manager
                if ((manager != null) && (manager instanceof Lifecycle)) {
                    ((Lifecycle) getManager()).start();
                }
   
                // Start ContainerBackgroundProcessor thread
                super.threadStart();
            } catch(Exception e) {
                log.error("Error manager.start()", e);
                ok = false;
            }

            // Configure and call application filters
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Filters register some ThreadLocals that they forget
                // to cleanup
                Boolean filterStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(filterStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!filterStarted.booleanValue()) {
                    log.error("Error filterStart");
                    ok = false;
                }
            }
           
            // Load and initialize all "load on startup" servlets
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Servlets register some ThreadLocals that they forget
                // to cleanup
                temporaryExecutor.execute(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        ClassLoader old = bindThread();
                        try {
                            loadOnStartup(findChildren());
                            return null;
                        } finally {
                            unbindThread(old);
                        }
                    }
                });
            }
           
        } finally {
            // Unbinding thread
            unbindThread(oldCCL);
            temporaryExecutor.shutdown();
        }

        // Set available status depending upon startup success
        if (ok) {
            if (log.isDebugEnabled())
View Full Code Here

                getServletContext().setAttribute(
                        InstanceManager.class.getName(), getInstanceManager());
            }
        }

        DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
        try {
           
            // Create context attributes that will be required
            if (ok) {
                getServletContext().setAttribute(
                        JarScanner.class.getName(), getJarScanner());
            }

            // Set up the context init params
            mergeParameters();

            // Call ServletContainerInitializers
            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry :
                initializers.entrySet()) {
                try {
                    entry.getKey().onStartup(entry.getValue(),
                            getServletContext());
                } catch (ServletException e) {
                    // TODO: Log error
                    ok = false;
                    break;
                }
            }

            // Configure and call application event listeners
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Listeners registers some ThreadLocals that they
                // forget to cleanup
                Boolean listenerStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(listenerStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!listenerStarted.booleanValue()) {
                    log.error( "Error listenerStart");
                    ok = false;
                }
            }
           
            try {
                // Start manager
                if ((manager != null) && (manager instanceof Lifecycle)) {
                    ((Lifecycle) getManager()).start();
                }
   
                // Start ContainerBackgroundProcessor thread
                super.threadStart();
            } catch(Exception e) {
                log.error("Error manager.start()", e);
                ok = false;
            }

            // Configure and call application filters
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Filters register some ThreadLocals that they forget
                // to cleanup
                Boolean filterStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(filterStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!filterStarted.booleanValue()) {
                    log.error("Error filterStart");
                    ok = false;
                }
            }
           
            // Load and initialize all "load on startup" servlets
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Servlets register some ThreadLocals that they forget
                // to cleanup
                temporaryExecutor.execute(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        ClassLoader old = bindThread();
                        try {
                            loadOnStartup(findChildren());
                            return null;
                        } finally {
                            unbindThread(old);
                        }
                    }
                });
            }
           
        } finally {
            // Unbinding thread
            unbindThread(oldCCL);
            temporaryExecutor.shutdown();
        }

        // Set available status depending upon startup success
        if (ok) {
            if (log.isDebugEnabled())
View Full Code Here

                getServletContext().setAttribute(
                        InstanceManager.class.getName(), getInstanceManager());
            }
        }

        DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
        try {
           
            // Create context attributes that will be required
            if (ok) {
                getServletContext().setAttribute(
                        JarScanner.class.getName(), getJarScanner());
            }

            // Set up the context init params
            mergeParameters();

            // Call ServletContainerInitializers
            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry :
                initializers.entrySet()) {
                try {
                    entry.getKey().onStartup(entry.getValue(),
                            getServletContext());
                } catch (ServletException e) {
                    // TODO: Log error
                    ok = false;
                    break;
                }
            }

            // Configure and call application event listeners
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Listeners registers some ThreadLocals that they
                // forget to cleanup
                Boolean listenerStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(listenerStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!listenerStarted.booleanValue()) {
                    log.error( "Error listenerStart");
                    ok = false;
                }
            }
           
            try {
                // Start manager
                if ((manager != null) && (manager instanceof Lifecycle)) {
                    ((Lifecycle) getManager()).start();
                }
   
                // Start ContainerBackgroundProcessor thread
                super.threadStart();
            } catch(Exception e) {
                log.error("Error manager.start()", e);
                ok = false;
            }

            // Configure and call application filters
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Filters register some ThreadLocals that they forget
                // to cleanup
                Boolean filterStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(filterStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!filterStarted.booleanValue()) {
                    log.error("Error filterStart");
                    ok = false;
                }
            }
           
            // Load and initialize all "load on startup" servlets
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Servlets register some ThreadLocals that they forget
                // to cleanup
                temporaryExecutor.execute(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        ClassLoader old = bindThread();
                        try {
                            loadOnStartup(findChildren());
                            return null;
                        } finally {
                            unbindThread(old);
                        }
                    }
                });
            }
           
        } finally {
            // Unbinding thread
            unbindThread(oldCCL);
            temporaryExecutor.shutdown();
        }

        // Set available status depending upon startup success
        if (ok) {
            if (log.isDebugEnabled())
View Full Code Here

                getServletContext().setAttribute(
                        InstanceManager.class.getName(), getInstanceManager());
            }
        }

        DedicatedThreadExecutor temporaryExecutor = new DedicatedThreadExecutor();
        try {
           
            // Create context attributes that will be required
            if (ok) {
                getServletContext().setAttribute(
                        JarScanner.class.getName(), getJarScanner());
            }

            // Set up the context init params
            mergeParameters();

            // Call ServletContainerInitializers
            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry :
                initializers.entrySet()) {
                try {
                    entry.getKey().onStartup(entry.getValue(),
                            getServletContext());
                } catch (ServletException e) {
                    // TODO: Log error
                    ok = false;
                    break;
                }
            }

            // Configure and call application event listeners
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Listeners registers some ThreadLocals that they
                // forget to cleanup
                Boolean listenerStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(listenerStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!listenerStarted.booleanValue()) {
                    log.error( "Error listenerStart");
                    ok = false;
                }
            }
           
            try {
                // Start manager
                if ((manager != null) && (manager instanceof Lifecycle)) {
                    ((Lifecycle) getManager()).start();
                }
   
                // Start ContainerBackgroundProcessor thread
                super.threadStart();
            } catch(Exception e) {
                log.error("Error manager.start()", e);
                ok = false;
            }

            // Configure and call application filters
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Filters register some ThreadLocals that they forget
                // to cleanup
                Boolean filterStarted =
                    temporaryExecutor.execute(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            ClassLoader old = bindThread();
                            try {
                                return Boolean.valueOf(filterStart());
                            } finally {
                                unbindThread(old);
                            }
                        }
                    });
                if (!filterStarted.booleanValue()) {
                    log.error("Error filterStart");
                    ok = false;
                }
            }
           
            // Load and initialize all "load on startup" servlets
            if (ok) {
                // we do it in a dedicated thread for memory leak protection, in
                // case the Servlets register some ThreadLocals that they forget
                // to cleanup
                temporaryExecutor.execute(new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        ClassLoader old = bindThread();
                        try {
                            loadOnStartup(findChildren());
                            return null;
                        } finally {
                            unbindThread(old);
                        }
                    }
                });
            }
           
        } finally {
            // Unbinding thread
            unbindThread(oldCCL);
            temporaryExecutor.shutdown();
        }

        // Set available status depending upon startup success
        if (ok) {
            if (log.isDebugEnabled())
View Full Code Here

TOP

Related Classes of org.apache.tomcat.util.threads.DedicatedThreadExecutor

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.