1 package org.argosfields.spring;
2
3 import org.apache.commons.logging.Log;
4 import org.apache.commons.logging.LogFactory;
5 import org.springframework.context.ConfigurableApplicationContext;
6
7 /***
8 * AbstractContextHelper.java
9 *
10 * @author Xavier Cho
11 * @version $Revision: 1.1 $ $Date: 2004/04/15 05:43:55 $
12 */
13 public abstract class AbstractContextHelper implements ISpringContextHelper {
14 private static Log log = LogFactory.getLog(AbstractContextHelper.class);
15
16 private ConfigurableApplicationContext applicationContext;
17
18 protected ConfigurableApplicationContext getApplicationContext() {
19 if (applicationContext == null) {
20 applicationContext = createApplicationContext();
21 }
22
23 return applicationContext;
24 }
25
26 /***
27 * @see org.argosfields.spring.ISpringContextHelper#reload()
28 */
29 public void reload() {
30 if (applicationContext == null) {
31 getApplicationContext();
32 } else {
33 if (log.isInfoEnabled()) {
34 log.info("Refreshing application context.");
35 }
36
37 applicationContext.refresh();
38 }
39 }
40
41 /***
42 * @see org.argosfields.spring.ISpringContextHelper#close()
43 */
44 public void close() {
45 if (applicationContext != null) {
46 if (log.isInfoEnabled()) {
47 log.info("Closing application context.");
48 }
49
50 applicationContext.close();
51 }
52 }
53
54 protected abstract ConfigurableApplicationContext createApplicationContext();
55 }
This page was automatically generated by Maven