org.powertac.common.spring
Class SpringApplicationContext

java.lang.Object
  extended by org.powertac.common.spring.SpringApplicationContext
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

@Service
public class SpringApplicationContext
extends Object
implements org.springframework.context.ApplicationContextAware

Static methods to access the Spring application context. It is set up as a service so Spring will create and initialize it.

Author:
John Collins

Constructor Summary
SpringApplicationContext()
           
 
Method Summary
static Object getBean(String beanName)
          Returns the Spring bean, if any, with the given name.
static
<T> T
getBeanByType(Class<T> type)
          Returns the first Spring bean found that is an instance of the given class.
static org.springframework.context.ApplicationContext getContext()
           
static
<T> List<T>
listBeansOfType(Class<T> type)
          Returns all the Spring beans that are instances of the given type.
static
<T> Map<String,T>
mapBeansOfType(Class<T> type)
          Returns a map of all the Spring beans that are instances of the given type.
 void setApplicationContext(org.springframework.context.ApplicationContext appContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringApplicationContext

public SpringApplicationContext()
Method Detail

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext appContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

getBean

public static Object getBean(String beanName)
Returns the Spring bean, if any, with the given name.


getBeanByType

public static <T> T getBeanByType(Class<T> type)
Returns the first Spring bean found that is an instance of the given class.


listBeansOfType

public static <T> List<T> listBeansOfType(Class<T> type)
Returns all the Spring beans that are instances of the given type.


mapBeansOfType

public static <T> Map<String,T> mapBeansOfType(Class<T> type)
Returns a map of all the Spring beans that are instances of the given type.


getContext

public static org.springframework.context.ApplicationContext getContext()


Copyright © 2012. All Rights Reserved.