View | Details | Raw Unified | Return to bug 38795
Collapse All | Expand All

(-)jakarta-tomcat-4.1.31-src/catalina/src/share/org/apache/catalina/core/StandardContext.java (-127 / +137 lines)
Lines 2392-2440 Link Here
2392
        // Binding thread
2392
        // Binding thread
2393
        ClassLoader oldCCL = bindThread();
2393
        ClassLoader oldCCL = bindThread();
2394
2394
2395
        // Shut down our session manager
2395
        try {
2396
        if ((manager != null) && (manager instanceof Lifecycle)) {
2396
            // Shut down our session manager
2397
            try {
2397
            if ((manager != null) && (manager instanceof Lifecycle)) {
2398
                ((Lifecycle) manager).stop();
2399
            } catch (LifecycleException e) {
2400
                log(sm.getString("standardContext.stoppingManager"), e);
2401
            }
2402
        }
2403
2404
        // Shut down the current version of all active servlets
2405
        Container children[] = findChildren();
2406
        for (int i = 0; i < children.length; i++) {
2407
            Wrapper wrapper = (Wrapper) children[i];
2408
            if (wrapper instanceof Lifecycle) {
2409
                try {
2398
                try {
2410
                    ((Lifecycle) wrapper).stop();
2399
                    ((Lifecycle) manager).stop();
2411
                } catch (LifecycleException e) {
2400
                } catch (LifecycleException e) {
2412
                    log(sm.getString("standardContext.stoppingWrapper",
2401
                    log(sm.getString("standardContext.stoppingManager"), e);
2413
                                     wrapper.getName()),
2414
                        e);
2415
                }
2402
                }
2416
            }
2403
            }
2417
        }
2418
2404
2419
        // Shut down application event listeners
2405
            // Shut down the current version of all active servlets
2420
        listenerStop();
2406
            Container children[] = findChildren();
2421
2407
            for (int i = 0; i < children.length; i++) {
2422
        // Clear all application-originated servlet context attributes
2408
                Wrapper wrapper = (Wrapper) children[i];
2423
        if (context != null)
2409
                if (wrapper instanceof Lifecycle) {
2424
            context.clearAttributes();
2410
                    try {
2411
                        ((Lifecycle) wrapper).stop();
2412
                    } catch (LifecycleException e) {
2413
                        log(sm.getString("standardContext.stoppingWrapper",
2414
                                         wrapper.getName()),
2415
                            e);
2416
                    }
2417
                }
2418
            }
2425
2419
2426
        // Shut down filters
2420
            // Shut down application event listeners
2427
        filterStop();
2421
            listenerStop();
2428
2422
2429
        if (isUseNaming()) {
2423
            // Clear all application-originated servlet context attributes
2430
            // Start
2424
            if (context != null)
2431
            namingContextListener.lifecycleEvent
2425
                context.clearAttributes();
2432
                (new LifecycleEvent(this, Lifecycle.STOP_EVENT));
2426
2427
            // Shut down filters
2428
            filterStop();
2429
2430
            if (isUseNaming()) {
2431
                // Start
2432
                namingContextListener.lifecycleEvent
2433
                    (new LifecycleEvent(this, Lifecycle.STOP_EVENT));
2434
            }
2435
        } finally {
2436
            // Binding thread
2437
            unbindThread(oldCCL);
2433
        }
2438
        }
2434
2439
2435
        // Binding thread
2436
        unbindThread(oldCCL);
2437
2438
        // Shut down our application class loader
2440
        // Shut down our application class loader
2439
        if ((loader != null) && (loader instanceof Lifecycle)) {
2441
        if ((loader != null) && (loader instanceof Lifecycle)) {
2440
            try {
2442
            try {
Lines 2447-2464 Link Here
2447
        // Binding thread
2449
        // Binding thread
2448
        oldCCL = bindThread();
2450
        oldCCL = bindThread();
2449
2451
2450
        // Restart our application class loader
2452
        try {
2451
        if ((loader != null) && (loader instanceof Lifecycle)) {
2453
            // Restart our application class loader
2452
            try {
2454
            if ((loader != null) && (loader instanceof Lifecycle)) {
2453
                ((Lifecycle) loader).start();
2455
                try {
2454
            } catch (LifecycleException e) {
2456
                    ((Lifecycle) loader).start();
2455
                log(sm.getString("standardContext.startingLoader"), e);
2457
                } catch (LifecycleException e) {
2458
                    log(sm.getString("standardContext.startingLoader"), e);
2459
                }
2456
            }
2460
            }
2461
        } finally {
2462
            // Binding thread
2463
            unbindThread(oldCCL);
2457
        }
2464
        }
2458
2465
2459
        // Binding thread
2460
        unbindThread(oldCCL);
2461
2462
        // Create and register the associated naming context, if internal
2466
        // Create and register the associated naming context, if internal
2463
        // naming is used
2467
        // naming is used
2464
        boolean ok = true;
2468
        boolean ok = true;
Lines 2471-2526 Link Here
2471
        // Binding thread
2475
        // Binding thread
2472
        oldCCL = bindThread();
2476
        oldCCL = bindThread();
2473
2477
2474
        // Restart our application event listeners and filters
2478
        try {
2475
        if (ok) {
2479
            // Restart our application event listeners and filters
2476
            if (!listenerStart()) {
2480
            if (ok) {
2477
                log(sm.getString("standardContext.listenerStartFailed"));
2481
                if (!listenerStart()) {
2478
                ok = false;
2482
                    log(sm.getString("standardContext.listenerStartFailed"));
2483
                    ok = false;
2484
                }
2479
            }
2485
            }
2480
        }
2486
            if (ok) {
2481
        if (ok) {
2487
                if (!filterStart()) {
2482
            if (!filterStart()) {
2488
                    log(sm.getString("standardContext.filterStartFailed"));
2483
                log(sm.getString("standardContext.filterStartFailed"));
2489
                    ok = false;
2484
                ok = false;
2490
                }
2485
            }
2491
            }
2486
        }
2487
2492
2488
        // Restore the "Welcome Files" and "Resources" context attributes
2493
            // Restore the "Welcome Files" and "Resources" context attributes
2489
        postResources();
2494
            postResources();
2490
        postWelcomeFiles();
2495
            postWelcomeFiles();
2491
2496
2492
        // Restart our currently defined servlets
2497
            // Restart our currently defined servlets
2493
        for (int i = 0; i < children.length; i++) {
2498
            for (int i = 0; i < children.length; i++) {
2494
            if (!ok)
2499
                if (!ok)
2495
                break;
2500
                    break;
2496
            Wrapper wrapper = (Wrapper) children[i];
2501
                Wrapper wrapper = (Wrapper) children[i];
2497
            if (wrapper instanceof Lifecycle) {
2502
                if (wrapper instanceof Lifecycle) {
2498
                try {
2503
                    try {
2499
                    ((Lifecycle) wrapper).start();
2504
                        ((Lifecycle) wrapper).start();
2500
                } catch (LifecycleException e) {
2505
                    } catch (LifecycleException e) {
2501
                    log(sm.getString("standardContext.startingWrapper",
2506
                        log(sm.getString("standardContext.startingWrapper",
2502
                                     wrapper.getName()),
2507
                                         wrapper.getName()),
2503
                        e);
2508
                            e);
2504
                    ok = false;
2509
                        ok = false;
2510
                    }
2505
                }
2511
                }
2506
            }
2512
            }
2507
        }
2508
2513
2509
        // Reinitialize all load on startup servlets
2514
            // Reinitialize all load on startup servlets
2510
        loadOnStartup(children);
2515
            loadOnStartup(children);
2511
2516
2512
        // Restart our session manager (AFTER naming context recreated/bound)
2517
            // Restart our session manager (AFTER naming context recreated/bound)
2513
        if ((manager != null) && (manager instanceof Lifecycle)) {
2518
            if ((manager != null) && (manager instanceof Lifecycle)) {
2514
            try {
2519
                try {
2515
                ((Lifecycle) manager).start();
2520
                    ((Lifecycle) manager).start();
2516
            } catch (LifecycleException e) {
2521
                } catch (LifecycleException e) {
2517
                log(sm.getString("standardContext.startingManager"), e);
2522
                    log(sm.getString("standardContext.startingManager"), e);
2523
                }
2518
            }
2524
            }
2525
        } finally {
2526
            // Unbinding thread
2527
            unbindThread(oldCCL);
2519
        }
2528
        }
2520
2529
2521
        // Unbinding thread
2522
        unbindThread(oldCCL);
2523
2524
        // Start accepting requests again
2530
        // Start accepting requests again
2525
        if (ok) {
2531
        if (ok) {
2526
            log(sm.getString("standardContext.reloadingCompleted"));
2532
            log(sm.getString("standardContext.reloadingCompleted"));
Lines 3470-3482 Link Here
3470
        // Binding thread
3476
        // Binding thread
3471
        ClassLoader oldCCL = bindThread();
3477
        ClassLoader oldCCL = bindThread();
3472
3478
3473
        // Standard container startup
3479
        try {
3474
        if (debug >= 1)
3480
            // Standard container startup
3475
            log("Processing standard container startup");
3481
            if (debug >= 1)
3476
3482
                log("Processing standard container startup");
3477
        if (ok) {
3478
3483
3479
            try {
3484
            if (ok) {
3480
3485
3481
                addDefaultMapper(this.mapperClass);
3486
                addDefaultMapper(this.mapperClass);
3482
                started = true;
3487
                started = true;
Lines 3525-3536 Link Here
3525
                if ((manager != null) && (manager instanceof Lifecycle))
3530
                if ((manager != null) && (manager instanceof Lifecycle))
3526
                    ((Lifecycle) manager).start();
3531
                    ((Lifecycle) manager).start();
3527
3532
3528
            } finally {
3529
                // Unbinding thread
3530
                unbindThread(oldCCL);
3531
            }
3533
            }
3532
3534
        } finally {
3535
            // Unbinding thread
3536
            unbindThread(oldCCL);
3533
        }
3537
        }
3538
3534
        if (!getConfigured())
3539
        if (!getConfigured())
3535
            ok = false;
3540
            ok = false;
3536
3541
Lines 3542-3567 Link Here
3542
        // Binding thread
3547
        // Binding thread
3543
        oldCCL = bindThread();
3548
        oldCCL = bindThread();
3544
3549
3545
        // Create context attributes that will be required
3550
        try {
3546
        if (ok) {
3551
            // Create context attributes that will be required
3547
            if (debug >= 1)
3552
            if (ok) {
3548
                log("Posting standard context attributes");
3553
                if (debug >= 1)
3549
            postWelcomeFiles();
3554
                    log("Posting standard context attributes");
3550
        }
3555
                postWelcomeFiles();
3556
            }
3551
3557
3552
        // Configure and call application event listeners and filters
3558
            // Configure and call application event listeners and filters
3553
        if (ok) {
3559
            if (ok) {
3554
            if (!listenerStart())
3560
                if (!listenerStart())
3555
                ok = false;
3561
                    ok = false;
3556
        }
3562
            }
3557
        if (ok) {
3563
            if (ok) {
3558
            if (!filterStart())
3564
                if (!filterStart())
3559
                ok = false;
3565
                    ok = false;
3566
            }
3567
        } finally {
3568
            // Unbinding thread
3569
            unbindThread(oldCCL);
3560
        }
3570
        }
3561
3571
3562
        // Unbinding thread
3563
        unbindThread(oldCCL);
3564
3565
        // Set available status depending upon startup success
3572
        // Set available status depending upon startup success
3566
        if (ok) {
3573
        if (ok) {
3567
            if (debug >= 1)
3574
            if (debug >= 1)
Lines 3583-3590 Link Here
3583
3590
3584
        // Load and initialize all "load on startup" servlets
3591
        // Load and initialize all "load on startup" servlets
3585
        oldCCL = bindThread();
3592
        oldCCL = bindThread();
3586
        loadOnStartup(findChildren());
3593
        try {
3587
        unbindThread(oldCCL);
3594
            loadOnStartup(findChildren());
3595
        } finally {
3596
            unbindThread(oldCCL);
3597
        }
3588
    }
3598
    }
3589
3599
3590
3600
Lines 3612-3638 Link Here
3612
        // Binding thread
3622
        // Binding thread
3613
        ClassLoader oldCCL = bindThread();
3623
        ClassLoader oldCCL = bindThread();
3614
3624
3615
        // Stop our filters
3625
        try {
3616
        filterStop();
3617
3626
3618
        // Stop our application listeners
3627
            // Stop our filters
3619
        listenerStop();
3628
            filterStop();
3620
3629
3621
        // Finalize our character set mapper
3630
            // Stop our application listeners
3622
        setCharsetMapper(null);
3631
            listenerStop();
3623
3632
3624
        if ((manager != null) && (manager instanceof Lifecycle)) {
3633
            // Finalize our character set mapper
3625
            ((Lifecycle) manager).stop();
3634
            setCharsetMapper(null);
3626
        }
3627
3635
3628
        // Normal container shutdown processing
3636
            if ((manager != null) && (manager instanceof Lifecycle)) {
3629
        if (debug >= 1)
3637
                ((Lifecycle) manager).stop();
3630
            log("Processing standard container shutdown");
3638
            }
3631
        // Notify our interested LifecycleListeners
3632
        lifecycle.fireLifecycleEvent(STOP_EVENT, null);
3633
        started = false;
3634
3639
3635
        try {
3640
            // Normal container shutdown processing
3641
            if (debug >= 1)
3642
                log("Processing standard container shutdown");
3643
            // Notify our interested LifecycleListeners
3644
            lifecycle.fireLifecycleEvent(STOP_EVENT, null);
3645
            started = false;
3636
3646
3637
            // Stop the Valves in our pipeline (including the basic), if any
3647
            // Stop the Valves in our pipeline (including the basic), if any
3638
            if (pipeline instanceof Lifecycle) {
3648
            if (pipeline instanceof Lifecycle) {

Return to bug 38795