View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
3   	$Id
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"; //$NON-NLS-1$
21  
22      /*** The Constant MESSAGE_SOURCE. */
23      private static final String MESSAGE_SOURCE = "messageSource"; //$NON-NLS-1$
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  }