1 package org.argosfields.spring;
2
3 import org.apache.commons.logging.Log;
4 import org.apache.commons.logging.LogFactory;
5 import org.argosfields.service.IAccountManager;
6 import org.springframework.context.ConfigurableApplicationContext;
7 import org.springframework.context.support.ClassPathXmlApplicationContext;
8
9 /***
10 * ServerContextHelper.java
11 *
12 * @author Xavier Cho
13 * @version $Revision 1.1 $ $Date: 2004/04/15 05:43:55 $
14 */
15 public final class ServerContextHelper extends AbstractContextHelper {
16
17 private static Log log = LogFactory.getLog(ServerContextHelper.class);
18
19 private static ServerContextHelper instance;
20
21 private IAccountManager accountManager;
22
23 /***
24 * Default constructor for ServerContextHelper.
25 */
26 private ServerContextHelper() {
27 if (log.isInfoEnabled()) {
28 log.info("AccountManager has been initialized successfully.");
29 }
30 }
31
32 public static ServerContextHelper getInstance() {
33 if (instance == null) {
34 synchronized (ServerContextHelper.class) {
35 instance = new ServerContextHelper();
36 }
37 }
38
39 return instance;
40 }
41
42 /***
43 * @see org.argosfields.spring.AbstractContextHelper#createApplicationContext()
44 */
45 protected ConfigurableApplicationContext createApplicationContext() {
46 if (log.isInfoEnabled()) {
47 log.info("Loading server application context.");
48 }
49
50 return new ClassPathXmlApplicationContext("applicationContext.xml");
51 }
52
53 public IAccountManager getAccountManager() {
54 if (accountManager == null) {
55 accountManager = createAccountManager();
56 }
57
58 return accountManager;
59 }
60
61 protected IAccountManager createAccountManager() {
62 return (IAccountManager) getApplicationContext().getBean(
63 IAccountManager.NAME);
64 }
65 }
This page was automatically generated by Maven