public class BeanApplicationContext extends Object implements ApplicationContext
Constructor and Description |
---|
BeanApplicationContext()
Create a new BeanApplicationContext with a
DefaultBeanFactory |
BeanApplicationContext(BeanFactory factory)
Create a new BeanApplicationContext with the given
BeanFactory |
Modifier and Type | Method and Description |
---|---|
void |
add(Object object)
Adds an object instance with the fully qualified classname as name to the application context
|
void |
add(String name,
Object instance)
Adds an object instance with the specified name to the ApplicationContext.
|
protected void |
addAndReplace(String name,
Object instance)
Will add or replace a bean with the given name.
|
<T> T |
find(Class<T> klass)
Looks for an object of the specified class.
|
<T> Collection<T> |
findAll(Class<T> klass)
Utility method to find all classes that implements or extends from the given class.
|
<T> T |
get(String name)
Returns the object of the specified type with the specified name.
|
BeanFactory |
getBeanFactory() |
boolean |
hasBean(String name)
Check if a object with the specified name is available in this ApplicationContext.
|
<T> T |
load(Class<T> klass)
Load the specified class with the context ClassLoader into this ApplicationContext.
|
<T> T |
load(Class<T> klass,
ClassLoader classLoader)
Load the specified class with the given ClassLoader into this ApplicationContext.
|
protected void |
performShutdown(ConcurrentHashMap<String,Object> beans) |
protected void |
preDestroy(Object value) |
void |
shutdown()
Called to shutdown the application context, letting it perform shutdown like running
PreDestroy on beans. |
public BeanApplicationContext()
DefaultBeanFactory
public BeanApplicationContext(BeanFactory factory)
BeanFactory
factory
- the BeanFactory
NullPointerException
- if the factory is nullpublic void add(String name, Object instance)
ApplicationContextAware
the application context is set to
the object.add
in interface ApplicationContext
name
- the unique name of the objectinstance
- the object to add.DuplicateEntryException
- if the bean with the given name already existspublic void add(Object object)
ApplicationContext
add
in interface ApplicationContext
protected void addAndReplace(String name, Object instance)
name
- the nameinstance
- the beanpublic <T> T get(String name)
ApplicationContext
get
in interface ApplicationContext
name
- the name of the object to returnpublic <T> T find(Class<T> klass)
ApplicationContext
find
in interface ApplicationContext
klass
- the class of the object to look for.public <T> Collection<T> findAll(Class<T> klass)
ApplicationContext
findAll
in interface ApplicationContext
klass
- the type to look forpublic BeanFactory getBeanFactory()
getBeanFactory
in interface ApplicationContext
public boolean hasBean(String name)
ApplicationContext
hasBean
in interface ApplicationContext
name
- the name to look for.public <T> T load(Class<T> klass, ClassLoader classLoader)
ApplicationContext
load
in interface ApplicationContext
klass
- the class to load.classLoader
- the ClassLoader to use.public <T> T load(Class<T> klass)
ApplicationContext
load
in interface ApplicationContext
klass
- the class to load.public void shutdown()
ApplicationContext
PreDestroy
on beans.shutdown
in interface ApplicationContext
protected void performShutdown(ConcurrentHashMap<String,Object> beans)
beans
- SecurityException
protected void preDestroy(Object value)
Copyright © 2012 redlab.be. All Rights Reserved.