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

(-)apache-tomcat-5.5.16-src/container/catalina/src/share/org/apache/catalina/core/StandardContext.java (-58 / +64 lines)
Lines 4059-4084 Link Here
4059
            }
4068
            }
4060
        }
4069
        }
4061
4070
4062
        // Binding thread
4063
        ClassLoader oldCCL = bindThread();
4064
4065
        // Standard container startup
4066
        if (log.isDebugEnabled())
4067
            log.debug("Processing standard container startup");
4068
4069
        if (ok) {
4071
        if (ok) {
4070
4071
            boolean mainOk = false;
4072
            boolean mainOk = false;
4073
4074
            // Binding thread
4075
            ClassLoader oldCCL = bindThread();
4072
            try {
4076
            try {
4073
4077
4078
                // Standard container startup
4079
                if (log.isDebugEnabled())
4080
                    log.debug("Processing standard container startup");
4081
4082
4074
                started = true;
4083
                started = true;
4075
4084
4076
                // Start our subordinate components, if any
4085
                // Start our subordinate components, if any
4077
                if ((loader != null) && (loader instanceof Lifecycle))
4086
                if ((loader != null) && (loader instanceof Lifecycle))
4078
                    ((Lifecycle) loader).start();
4087
                    ((Lifecycle) loader).start();
4079
4088
4080
                // Unbinding thread
4089
                try {
4081
                unbindThread(oldCCL);
4090
                    // Unbinding thread
4091
                    unbindThread(oldCCL);
4092
                } catch(Throwable t) {
4093
                    oldCCL = null;
4094
                }
4082
4095
4083
                // Binding thread
4096
                // Binding thread
4084
                oldCCL = bindThread();
4097
                oldCCL = bindThread();
Lines 4142-4156 Link Here
4142
                mainOk = true;
4155
                mainOk = true;
4143
4156
4144
            } finally {
4157
            } finally {
4145
                // Unbinding thread
4158
                if(oldCCL != null) {
4146
                unbindThread(oldCCL);
4159
                    // Unbinding thread
4160
                    unbindThread(oldCCL);
4161
                }
4147
                if (!mainOk) {
4162
                if (!mainOk) {
4148
                    // An exception occurred
4163
                    // An exception occurred
4149
                    // Register with JMX anyway, to allow management
4164
                    // Register with JMX anyway, to allow management
4150
                    registerJMX();
4165
                    registerJMX();
4151
                }
4166
                }
4152
            }
4167
            }
4153
4154
        }
4168
        }
4155
        if (!getConfigured()) {
4169
        if (!getConfigured()) {
4156
            log.error( "Error getConfigured");
4170
            log.error( "Error getConfigured");
Lines 4166-4205 Link Here
4166
        mapper.setContext(getPath(), welcomeFiles, resources);
4184
        mapper.setContext(getPath(), welcomeFiles, resources);
4167
4185
4168
        // Binding thread
4186
        // Binding thread
4169
        oldCCL = bindThread();
4187
        ClassLoader oldCCL = bindThread();
4170
4188
4171
        // Create context attributes that will be required
4189
        try {
4172
        if (ok) {
4190
            // Create context attributes that will be required
4173
            postWelcomeFiles();
4191
            if (ok) {
4174
        }
4192
                postWelcomeFiles();
4193
            }
4175
4194
4176
        if (ok) {
4195
            if (ok) {
4177
            // Notify our interested LifecycleListeners
4196
                // Notify our interested LifecycleListeners
4178
            lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
4197
                lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
4179
        }
4198
            }
4180
4199
4181
        // Configure and call application event listeners and filters
4200
            // Configure and call application event listeners and filters
4182
        if (ok) {
4201
            if (ok) {
4183
            if (!listenerStart()) {
4202
                if (!listenerStart()) {
4184
                log.error( "Error listenerStart");
4203
                    log.error( "Error listenerStart");
4185
                ok = false;
4204
                    ok = false;
4205
                }
4186
            }
4206
            }
4187
        }
4207
            if (ok) {
4188
        if (ok) {
4208
                if (!filterStart()) {
4189
            if (!filterStart()) {
4209
                    log.error( "Error filterStart");
4190
                log.error( "Error filterStart");
4210
                    ok = false;
4191
                ok = false;
4211
                }
4192
            }
4212
            }
4193
        }
4194
4213
4195
        // Load and initialize all "load on startup" servlets
4214
            // Load and initialize all "load on startup" servlets
4196
        if (ok) {
4215
            if (ok) {
4197
            loadOnStartup(findChildren());
4216
                loadOnStartup(findChildren());
4217
            }
4218
        } finally {
4219
            // Unbinding thread
4220
            unbindThread(oldCCL);
4198
        }
4221
        }
4199
4222
4200
        // Unbinding thread
4201
        unbindThread(oldCCL);
4202
4203
        // Set available status depending upon startup success
4223
        // Set available status depending upon startup success
4204
        if (ok) {
4224
        if (ok) {
4205
            if (log.isDebugEnabled())
4225
            if (log.isDebugEnabled())
Lines 4324-4353 Link Here
4324
        // Binding thread
4344
        // Binding thread
4325
        ClassLoader oldCCL = bindThread();
4345
        ClassLoader oldCCL = bindThread();
4326
4346
4327
        // Stop our filters
4347
        try {
4328
        filterStop();
4348
            // Stop our filters
4329
4349
            filterStop();
4330
        // Stop our application listeners
4331
        listenerStop();
4332
4350
4333
        // Stop ContainerBackgroundProcessor thread
4351
            // Stop our application listeners
4334
        super.threadStop();
4352
            listenerStop();
4335
4353
4336
        if ((manager != null) && (manager instanceof Lifecycle)) {
4354
            // Stop ContainerBackgroundProcessor thread
4337
            ((Lifecycle) manager).stop();
4355
            super.threadStop();
4338
        }
4339
4356
4340
        // Finalize our character set mapper
4357
            if ((manager != null) && (manager instanceof Lifecycle)) {
4341
        setCharsetMapper(null);
4358
                ((Lifecycle) manager).stop();
4359
            }
4342
4360
4343
        // Normal container shutdown processing
4361
            // Finalize our character set mapper
4344
        if (log.isDebugEnabled())
4362
            setCharsetMapper(null);
4345
            log.debug("Processing standard container shutdown");
4346
        // Notify our interested LifecycleListeners
4347
        lifecycle.fireLifecycleEvent(STOP_EVENT, null);
4348
        started = false;
4349
4363
4350
        try {
4364
            // Normal container shutdown processing
4365
            if (log.isDebugEnabled())
4366
                log.debug("Processing standard container shutdown");
4367
            // Notify our interested LifecycleListeners
4368
            lifecycle.fireLifecycleEvent(STOP_EVENT, null);
4369
            started = false;
4351
4370
4352
            // Stop the Valves in our pipeline (including the basic), if any
4371
            // Stop the Valves in our pipeline (including the basic), if any
4353
            if (pipeline instanceof Lifecycle) {
4372
            if (pipeline instanceof Lifecycle) {

Return to bug 38795