01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.core.dependencylifecycles;
18:
19: import org.kuali.rice.lifecycle.BaseLifecycle;
20:
21: import edu.iu.uis.eden.SpringLoader;
22:
23: /**
24: * A Lifecycle which simply initializes the SpringLoader with the correct spring context file. It's important that
25: * we don't actually start the SpringLoader here because that will be handled by the GlobalResourceLoader.
26: *
27: * @author Eric Westfall
28: */
29: public class SpringLifeCycle extends BaseLifecycle {
30:
31: protected final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
32: .getLogger(SpringLifeCycle.class);
33: private String springFileName;
34:
35: public SpringLifeCycle() {
36: springFileName = SpringLoader.DEFAULT_SPRING_FILE;
37: }
38:
39: public SpringLifeCycle(String springFileName) {
40: this .springFileName = springFileName;
41: }
42:
43: public void start() throws Exception {
44: LOG.warn("Initializing Spring from " + springFileName);
45: // Config config = Core.getCurrentContextConfig();
46: // String originalME = config.getMessageEntity();
47: try {
48: // if (config.getRunningEmbeddedServerMode()) {
49: // Core.getCurrentContextConfig().overrideProperty(Config.MESSAGE_ENTITY, "KEW");
50: // }
51: SpringLoader.getInstance().setContextFile(springFileName);
52: // SpringLoader.getInstance().start();
53: super .start();
54: } catch (Exception e) {
55: LOG.error("Spring Initialization Failed.", e);
56: throw new RuntimeException("Spring Initialization Failed.");
57: }
58: // finally {
59: // Core.getCurrentContextConfig().overrideProperty(Config.MESSAGE_ENTITY, originalME);
60: // }
61: }
62:
63: // public void stop() throws Exception {
64: // LOG.warn("Shutting down Spring");
65: // // destroying the GRL will kill Spring as well
66: // //GlobalResourceLoader.stop();
67: // SpringLoader.getInstance().stop();
68: // super.stop();
69: // }
70:
71: }
|