Java Doc for GenericApplicationContext.java in  » J2EE » spring-framework-2.0.6 » org » springframework » context » support » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.context.support 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.context.support.AbstractApplicationContext
   org.springframework.context.support.GenericApplicationContext

All known Subclasses:   org.springframework.context.support.StaticApplicationContext,  org.springframework.web.context.support.GenericWebApplicationContext,
GenericApplicationContext
public class GenericApplicationContext extends AbstractApplicationContext implements BeanDefinitionRegistry(Code)
Generic ApplicationContext implementation that holds a single internal org.springframework.beans.factory.support.DefaultListableBeanFactory instance and does not assume a specific bean definition format. Implements the org.springframework.beans.factory.support.BeanDefinitionRegistry interface in order to allow for applying any bean definition readers to it.

Typical usage is to register a variety of bean definitions via the org.springframework.beans.factory.support.BeanDefinitionRegistry interface and then call GenericApplicationContext.refresh() to initialize those beans with application context semantics (handling org.springframework.context.ApplicationContextAware , auto-detecting org.springframework.beans.factory.config.BeanFactoryPostProcessor BeanFactoryPostProcessors , etc).

In contrast to other ApplicationContext implementations that create a new internal BeanFactory instance for each refresh, the internal BeanFactory of this context is available right from the start, to be able to register bean definitions on it. GenericApplicationContext.refresh() may only be called once.

Usage example:

 GenericApplicationContext ctx = new GenericApplicationContext();
 XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
 xmlReader.loadBeanDefinitions(new ClassPathResource("applicationContext.xml"));
 PropertiesBeanDefinitionReader propReader = new PropertiesBeanDefinitionReader(ctx);
 propReader.loadBeanDefinitions(new ClassPathResource("otherBeans.properties"));
 ctx.refresh();
 MyBean myBean = (MyBean) ctx.getBean("myBean");
 ...
For the typical case of XML bean definitions, simply use ClassPathXmlApplicationContext or FileSystemXmlApplicationContext , which are easier to set up - but less flexible, since you can just use standard resource locations for XML bean definitions, rather than mixing arbitrary bean definition formats. The equivalent in a web environment is org.springframework.web.context.support.XmlWebApplicationContext .

For custom application context implementations that are supposed to read special bean definition formats in a refreshable manner, consider deriving from the AbstractRefreshableApplicationContext base class.
author:
   Juergen Hoeller
since:
   1.1.2
See Also:   GenericApplicationContext.registerBeanDefinition
See Also:   GenericApplicationContext.refresh()
See Also:   org.springframework.beans.factory.xml.XmlBeanDefinitionReader
See Also:   org.springframework.beans.factory.support.PropertiesBeanDefinitionReader




Constructor Summary
public  GenericApplicationContext()
     Create a new GenericApplicationContext.
public  GenericApplicationContext(DefaultListableBeanFactory beanFactory)
     Create a new GenericApplicationContext with the given DefaultListableBeanFactory.
public  GenericApplicationContext(ApplicationContext parent)
     Create a new GenericApplicationContext with the given parent.
public  GenericApplicationContext(DefaultListableBeanFactory beanFactory, ApplicationContext parent)
     Create a new GenericApplicationContext with the given DefaultListableBeanFactory.

Method Summary
final protected  voidcloseBeanFactory()
     Do nothing: We hold a single internal BeanFactory that will never get released.
public  BeanDefinitiongetBeanDefinition(String beanName)
    
final public  ConfigurableListableBeanFactorygetBeanFactory()
     Return the single internal BeanFactory held by this context (as ConfigurableListableBeanFactory).
final public  DefaultListableBeanFactorygetDefaultListableBeanFactory()
     Return the underlying bean factory of this context, available for registering bean definitions.
public  ResourcegetResource(String location)
     This implementation delegates to this context's ResourceLoader if set, falling back to the default superclass behavior else.
public  Resource[]getResources(String locationPattern)
     This implementation delegates to this context's ResourceLoader if it implements the ResourcePatternResolver interface, falling back to the default superclass behavior else.
final protected  voidrefreshBeanFactory()
     Do nothing: We hold a single internal BeanFactory and rely on callers to register beans through our public methods (or the BeanFactory's).
public  voidregisterAlias(String beanName, String alias)
    
public  voidregisterBeanDefinition(String beanName, BeanDefinition beanDefinition)
    
public  voidsetParent(ApplicationContext parent)
     Set the parent of this application context, also setting the parent of the internal BeanFactory accordingly.
public  voidsetResourceLoader(ResourceLoader resourceLoader)
     Set a ResourceLoader to use for this context.


Constructor Detail
GenericApplicationContext
public GenericApplicationContext()(Code)
Create a new GenericApplicationContext.
See Also:   GenericApplicationContext.registerBeanDefinition
See Also:   GenericApplicationContext.refresh



GenericApplicationContext
public GenericApplicationContext(DefaultListableBeanFactory beanFactory)(Code)
Create a new GenericApplicationContext with the given DefaultListableBeanFactory.
Parameters:
  beanFactory - the DefaultListableBeanFactory instance to use for this context
See Also:   GenericApplicationContext.registerBeanDefinition
See Also:   GenericApplicationContext.refresh



GenericApplicationContext
public GenericApplicationContext(ApplicationContext parent)(Code)
Create a new GenericApplicationContext with the given parent.
Parameters:
  parent - the parent application context
See Also:   GenericApplicationContext.registerBeanDefinition
See Also:   GenericApplicationContext.refresh



GenericApplicationContext
public GenericApplicationContext(DefaultListableBeanFactory beanFactory, ApplicationContext parent)(Code)
Create a new GenericApplicationContext with the given DefaultListableBeanFactory.
Parameters:
  beanFactory - the DefaultListableBeanFactory instance to use for this context
Parameters:
  parent - the parent application context
See Also:   GenericApplicationContext.registerBeanDefinition
See Also:   GenericApplicationContext.refresh




Method Detail
closeBeanFactory
final protected void closeBeanFactory()(Code)
Do nothing: We hold a single internal BeanFactory that will never get released.



getBeanDefinition
public BeanDefinition getBeanDefinition(String beanName) throws BeansException(Code)



getBeanFactory
final public ConfigurableListableBeanFactory getBeanFactory()(Code)
Return the single internal BeanFactory held by this context (as ConfigurableListableBeanFactory).



getDefaultListableBeanFactory
final public DefaultListableBeanFactory getDefaultListableBeanFactory()(Code)
Return the underlying bean factory of this context, available for registering bean definitions.

NOTE: You need to call GenericApplicationContext.refresh() to initialize the bean factory and its contained beans with application context semantics (autodetecting BeanFactoryPostProcessors, etc). the internal bean factory (as DefaultListableBeanFactory)




getResource
public Resource getResource(String location)(Code)
This implementation delegates to this context's ResourceLoader if set, falling back to the default superclass behavior else.
See Also:   GenericApplicationContext.setResourceLoader



getResources
public Resource[] getResources(String locationPattern) throws IOException(Code)
This implementation delegates to this context's ResourceLoader if it implements the ResourcePatternResolver interface, falling back to the default superclass behavior else.
See Also:   GenericApplicationContext.setResourceLoader



refreshBeanFactory
final protected void refreshBeanFactory() throws IllegalStateException(Code)
Do nothing: We hold a single internal BeanFactory and rely on callers to register beans through our public methods (or the BeanFactory's).
See Also:   GenericApplicationContext.registerBeanDefinition



registerAlias
public void registerAlias(String beanName, String alias) throws BeansException(Code)



registerBeanDefinition
public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeansException(Code)



setParent
public void setParent(ApplicationContext parent)(Code)
Set the parent of this application context, also setting the parent of the internal BeanFactory accordingly.
See Also:   org.springframework.beans.factory.config.ConfigurableBeanFactory.setParentBeanFactory



setResourceLoader
public void setResourceLoader(ResourceLoader resourceLoader)(Code)
Set a ResourceLoader to use for this context. If set, the context will delegate all getResource calls to the given ResourceLoader. If not set, default resource loading will apply.

The main reason to specify a custom ResourceLoader is to resolve resource paths (withour URL prefix) in a specific fashion. The default behavior is to resolve such paths as class path locations. To resolve resource paths as file system locations, specify a FileSystemResourceLoader here.

You can also pass in a full ResourcePatternResolver, which will be autodetected by the context and used for getResources calls as well. Else, default resource pattern matching will apply.
See Also:   GenericApplicationContext.getResource
See Also:   org.springframework.core.io.DefaultResourceLoader
See Also:   org.springframework.core.io.FileSystemResourceLoader
See Also:   org.springframework.core.io.support.ResourcePatternResolver
See Also:   GenericApplicationContext.getResources




Fields inherited from org.springframework.context.support.AbstractApplicationContext
final public static String APPLICATION_EVENT_MULTICASTER_BEAN_NAME(Code)(Java Doc)
final public static String MESSAGE_SOURCE_BEAN_NAME(Code)(Java Doc)
final protected Log logger(Code)(Java Doc)

Methods inherited from org.springframework.context.support.AbstractApplicationContext
public void addApplicationListener(ApplicationListener listener)(Code)(Java Doc)
public void addBeanFactoryPostProcessor(BeanFactoryPostProcessor beanFactoryPostProcessor)(Code)(Java Doc)
protected void addListener(ApplicationListener listener)(Code)(Java Doc)
public void close()(Code)(Java Doc)
abstract protected void closeBeanFactory()(Code)(Java Doc)
public boolean containsBean(String name)(Code)(Java Doc)
public boolean containsBeanDefinition(String name)(Code)(Java Doc)
public boolean containsLocalBean(String name)(Code)(Java Doc)
public void destroy()(Code)(Java Doc)
protected void destroyBeans()(Code)(Java Doc)
protected void doClose()(Code)(Java Doc)
public String[] getAliases(String name)(Code)(Java Doc)
public List getApplicationListeners()(Code)(Java Doc)
public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException(Code)(Java Doc)
public Object getBean(String name) throws BeansException(Code)(Java Doc)
public Object getBean(String name, Class requiredType) throws BeansException(Code)(Java Doc)
public int getBeanDefinitionCount()(Code)(Java Doc)
public String[] getBeanDefinitionNames()(Code)(Java Doc)
abstract public ConfigurableListableBeanFactory getBeanFactory() throws IllegalStateException(Code)(Java Doc)
public List getBeanFactoryPostProcessors()(Code)(Java Doc)
public String[] getBeanNamesForType(Class type)(Code)(Java Doc)
public String[] getBeanNamesForType(Class type, boolean includePrototypes, boolean allowEagerInit)(Code)(Java Doc)
public Map getBeansOfType(Class type) throws BeansException(Code)(Java Doc)
public Map getBeansOfType(Class type, boolean includePrototypes, boolean allowEagerInit) throws BeansException(Code)(Java Doc)
public String getDisplayName()(Code)(Java Doc)
protected BeanFactory getInternalParentBeanFactory()(Code)(Java Doc)
protected MessageSource getInternalParentMessageSource()(Code)(Java Doc)
protected Collection getLifecycleBeans()(Code)(Java Doc)
public String getMessage(String code, Object args, String defaultMessage, Locale locale)(Code)(Java Doc)
public String getMessage(String code, Object args, Locale locale) throws NoSuchMessageException(Code)(Java Doc)
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException(Code)(Java Doc)
public ApplicationContext getParent()(Code)(Java Doc)
public BeanFactory getParentBeanFactory()(Code)(Java Doc)
protected ResourcePatternResolver getResourcePatternResolver()(Code)(Java Doc)
public Resource[] getResources(String locationPattern) throws IOException(Code)(Java Doc)
public long getStartupDate()(Code)(Java Doc)
public Class getType(String name) throws NoSuchBeanDefinitionException(Code)(Java Doc)
protected void initApplicationEventMulticaster()(Code)(Java Doc)
protected void initMessageSource()(Code)(Java Doc)
protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory)(Code)(Java Doc)
public boolean isActive()(Code)(Java Doc)
public boolean isPrototype(String name) throws NoSuchBeanDefinitionException(Code)(Java Doc)
public boolean isRunning()(Code)(Java Doc)
public boolean isSingleton(String name) throws NoSuchBeanDefinitionException(Code)(Java Doc)
public boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException(Code)(Java Doc)
protected ConfigurableListableBeanFactory obtainFreshBeanFactory()(Code)(Java Doc)
protected void onClose()(Code)(Java Doc)
protected void onRefresh() throws BeansException(Code)(Java Doc)
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)(Code)(Java Doc)
protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory)(Code)(Java Doc)
protected void prepareRefresh()(Code)(Java Doc)
public void publishEvent(ApplicationEvent event)(Code)(Java Doc)
public void refresh() throws BeansException, IllegalStateException(Code)(Java Doc)
abstract protected void refreshBeanFactory() throws BeansException, IllegalStateException(Code)(Java Doc)
protected void registerBeanPostProcessors(ConfigurableListableBeanFactory beanFactory)(Code)(Java Doc)
protected void registerListeners()(Code)(Java Doc)
public void registerShutdownHook()(Code)(Java Doc)
public void setDisplayName(String displayName)(Code)(Java Doc)
public void setParent(ApplicationContext parent)(Code)(Java Doc)
public void start()(Code)(Java Doc)
public void stop()(Code)(Java Doc)
public String toString()(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.