1
2
3
4
5
6 package com.hack23.cia.web.common;
7
8 import org.springframework.context.ApplicationContext;
9 import org.springframework.context.MessageSource;
10 import org.springframework.context.support.ResourceBundleMessageSource;
11
12 import com.hack23.cia.service.api.application.ApplicationManager;
13
14 /***
15 * The Class BeanLocator.
16 */
17 public class BeanLocator {
18
19 /*** The Constant APPLICATION_ACTION_LISTENER. */
20 private static final String APPLICATION_ACTION_LISTENER = "applicationActionListener";
21
22 /*** The Constant MESSAGE_SOURCE. */
23 private static final String MESSAGE_SOURCE = "messageSource";
24
25 /***
26 * Gets the application action listener.
27 *
28 * @return the application action listener
29 */
30 public static ControllerActionListener getApplicationActionListener() {
31 return (ControllerActionListener) getApplicationContext().getBean(
32 APPLICATION_ACTION_LISTENER);
33 }
34
35 /***
36 * Gets the application context.
37 *
38 * @return the application context
39 */
40 private static ApplicationContext getApplicationContext() {
41 return StaticContextLoaderListener.getWebApplicationContext();
42 }
43
44 /***
45 * Gets the application manager.
46 *
47 * @return the application manager
48 */
49 public static ApplicationManager getApplicationManager() {
50 return (ApplicationManager) getApplicationContext().getBean("applicationManager");
51 }
52
53 /***
54 * Gets the resource bundle message source.
55 *
56 * @return the resource bundle message source
57 */
58 public static MessageSource getResourceBundleMessageSource() {
59 return (ResourceBundleMessageSource) getApplicationContext().getBean(
60 MESSAGE_SOURCE);
61 }
62
63 /***
64 * Instantiates a new bean locator.
65 */
66 protected BeanLocator() {
67 super();
68 }
69
70 }