public class ApplicationContextMock extends Object implements org.springframework.context.ApplicationContext, Serializable
getBean(String)
, getBean(String, Class)
, and
getBeansOfType(Class)
are implemented so far. Any other method throws
UnsupportedOperationException
.Constructor and Description |
---|
ApplicationContextMock() |
Modifier and Type | Method and Description |
---|---|
boolean |
containsBean(String name) |
boolean |
containsBeanDefinition(String beanName) |
boolean |
containsLocalBean(String arg0) |
<A extends Annotation> |
findAnnotationOnBean(String beanName,
Class<A> annotationType) |
String[] |
getAliases(String name) |
String |
getApplicationName() |
org.springframework.beans.factory.config.AutowireCapableBeanFactory |
getAutowireCapableBeanFactory() |
<T> T |
getBean(Class<T> requiredType) |
<T> T |
getBean(Class<T> requiredType,
Object... objects) |
Object |
getBean(String name) |
<T> T |
getBean(String name,
Class<T> requiredType) |
Object |
getBean(String name,
Object... args) |
int |
getBeanDefinitionCount() |
String[] |
getBeanDefinitionNames() |
String[] |
getBeanNamesForAnnotation(Class<? extends Annotation> aClass) |
String[] |
getBeanNamesForType(Class type) |
String[] |
getBeanNamesForType(Class type,
boolean includeNonSingletons,
boolean allowEagerInit) |
String[] |
getBeanNamesForType(org.springframework.core.ResolvableType resolvableType) |
<T> Map<String,T> |
getBeansOfType(Class<T> type) |
<T> Map<String,T> |
getBeansOfType(Class<T> type,
boolean includeNonSingletons,
boolean allowEagerInit) |
Map<String,Object> |
getBeansWithAnnotation(Class<? extends Annotation> annotationType) |
ClassLoader |
getClassLoader() |
String |
getDisplayName() |
org.springframework.core.env.Environment |
getEnvironment() |
String |
getId() |
String |
getMessage(org.springframework.context.MessageSourceResolvable resolvable,
Locale locale) |
String |
getMessage(String code,
Object[] args,
Locale locale) |
String |
getMessage(String code,
Object[] args,
String defaultMessage,
Locale locale) |
org.springframework.context.ApplicationContext |
getParent() |
org.springframework.beans.factory.BeanFactory |
getParentBeanFactory() |
org.springframework.core.io.Resource |
getResource(String location) |
org.springframework.core.io.Resource[] |
getResources(String locationPattern) |
long |
getStartupDate() |
Class<?> |
getType(String name) |
boolean |
isPrototype(String name) |
boolean |
isSingleton(String name) |
boolean |
isTypeMatch(String name,
Class targetType) |
boolean |
isTypeMatch(String s,
org.springframework.core.ResolvableType resolvableType) |
void |
publishEvent(org.springframework.context.ApplicationEvent event) |
void |
publishEvent(Object o) |
void |
putBean(Object bean)
puts bean with into the context.
|
void |
putBean(String name,
Object bean)
puts bean with the given name into the context
|
public void putBean(String name, Object bean)
name
- bean
- public void putBean(Object bean)
bean
- public Object getBean(String name) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public Object getBean(String name, Object... args) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public <T> T getBean(String name, Class<T> requiredType) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
BeanFactory.getBean(java.lang.String, java.lang.Class)
public <T> Map<String,T> getBeansOfType(Class<T> type) throws org.springframework.beans.BeansException
getBeansOfType
in interface org.springframework.beans.factory.ListableBeanFactory
org.springframework.beans.BeansException
ListableBeanFactory.getBeansOfType(java.lang.Class)
public <T> T getBean(Class<T> requiredType) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public <T> T getBean(Class<T> requiredType, Object... objects) throws org.springframework.beans.BeansException
getBean
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.BeansException
public Map<String,Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) throws org.springframework.beans.BeansException
getBeansWithAnnotation
in interface org.springframework.beans.factory.ListableBeanFactory
org.springframework.beans.BeansException
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
findAnnotationOnBean
in interface org.springframework.beans.factory.ListableBeanFactory
public org.springframework.context.ApplicationContext getParent()
getParent
in interface org.springframework.context.ApplicationContext
public String getDisplayName()
getDisplayName
in interface org.springframework.context.ApplicationContext
public long getStartupDate()
getStartupDate
in interface org.springframework.context.ApplicationContext
public void publishEvent(org.springframework.context.ApplicationEvent event)
publishEvent
in interface org.springframework.context.ApplicationEventPublisher
public void publishEvent(Object o)
publishEvent
in interface org.springframework.context.ApplicationEventPublisher
public boolean containsBeanDefinition(String beanName)
containsBeanDefinition
in interface org.springframework.beans.factory.ListableBeanFactory
public int getBeanDefinitionCount()
getBeanDefinitionCount
in interface org.springframework.beans.factory.ListableBeanFactory
public String[] getBeanDefinitionNames()
getBeanDefinitionNames
in interface org.springframework.beans.factory.ListableBeanFactory
public String[] getBeanNamesForType(org.springframework.core.ResolvableType resolvableType)
getBeanNamesForType
in interface org.springframework.beans.factory.ListableBeanFactory
public String[] getBeanNamesForType(Class type)
getBeanNamesForType
in interface org.springframework.beans.factory.ListableBeanFactory
public String[] getBeanNamesForType(Class type, boolean includeNonSingletons, boolean allowEagerInit)
getBeanNamesForType
in interface org.springframework.beans.factory.ListableBeanFactory
public <T> Map<String,T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws org.springframework.beans.BeansException
getBeansOfType
in interface org.springframework.beans.factory.ListableBeanFactory
org.springframework.beans.BeansException
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> aClass)
getBeanNamesForAnnotation
in interface org.springframework.beans.factory.ListableBeanFactory
public boolean containsBean(String name)
containsBean
in interface org.springframework.beans.factory.BeanFactory
public boolean isSingleton(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isSingleton
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public Class<?> getType(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
getType
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public String[] getAliases(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
getAliases
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public org.springframework.beans.factory.BeanFactory getParentBeanFactory()
getParentBeanFactory
in interface org.springframework.beans.factory.HierarchicalBeanFactory
getParentBeanFactory()
public String getMessage(String code, Object[] args, String defaultMessage, Locale locale)
getMessage
in interface org.springframework.context.MessageSource
public String getMessage(String code, Object[] args, Locale locale) throws org.springframework.context.NoSuchMessageException
getMessage
in interface org.springframework.context.MessageSource
org.springframework.context.NoSuchMessageException
public String getMessage(org.springframework.context.MessageSourceResolvable resolvable, Locale locale) throws org.springframework.context.NoSuchMessageException
getMessage
in interface org.springframework.context.MessageSource
org.springframework.context.NoSuchMessageException
public org.springframework.core.io.Resource[] getResources(String locationPattern) throws IOException
getResources
in interface org.springframework.core.io.support.ResourcePatternResolver
IOException
public org.springframework.core.io.Resource getResource(String location)
getResource
in interface org.springframework.core.io.ResourceLoader
public org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException
getAutowireCapableBeanFactory
in interface org.springframework.context.ApplicationContext
IllegalStateException
public boolean containsLocalBean(String arg0)
containsLocalBean
in interface org.springframework.beans.factory.HierarchicalBeanFactory
public ClassLoader getClassLoader()
getClassLoader
in interface org.springframework.core.io.ResourceLoader
public String getId()
getId
in interface org.springframework.context.ApplicationContext
public String getApplicationName()
getApplicationName
in interface org.springframework.context.ApplicationContext
public boolean isPrototype(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isPrototype
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public boolean isTypeMatch(String s, org.springframework.core.ResolvableType resolvableType) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isTypeMatch
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public boolean isTypeMatch(String name, Class targetType) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
isTypeMatch
in interface org.springframework.beans.factory.BeanFactory
org.springframework.beans.factory.NoSuchBeanDefinitionException
public org.springframework.core.env.Environment getEnvironment()
getEnvironment
in interface org.springframework.core.env.EnvironmentCapable
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.