Java Doc for ContextLoader.java in  » J2EE » spring-framework-2.5 » org » springframework » web » context » 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.5 » org.springframework.web.context 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.web.context.ContextLoader

ContextLoader
public class ContextLoader (Code)
Performs the actual initialization work for the root application context. Called by ContextLoaderListener and ContextLoaderServlet .

Looks for a "contextClass" parameter at the web.xml context-param level to specify the context class type, falling back to the default of org.springframework.web.context.support.XmlWebApplicationContext if not found. With the default ContextLoader implementation, any context class specified needs to implement the ConfigurableWebApplicationContext interface.

Processes a " ContextLoader.CONFIG_LOCATION_PARAM contextConfigLocation " context-param and passes its value to the context instance, parsing it into potentially multiple file paths which can be separated by any number of commas and spaces, e.g. "WEB-INF/applicationContext1.xml, WEB-INF/applicationContext2.xml". Ant-style path patterns are supported as well, e.g. "WEB-INF/*Context.xml,WEB-INF/spring*.xml" or "WEB-INF/**/*Context.xml". If not explicitly specified, the context implementation is supposed to use a default location (with XmlWebApplicationContext: "/WEB-INF/applicationContext.xml").

Note: In case of multiple config locations, later bean definitions will override ones defined in previously loaded files, at least when using one of Spring's default ApplicationContext implementations. This can be leveraged to deliberately override certain bean definitions via an extra XML file.

Above and beyond loading the root application context, this class can optionally load or obtain and hook up a shared parent context to the root application context. See the ContextLoader.loadParentContext(ServletContext) method for more information.
author:
   Juergen Hoeller
author:
   Colin Sampaleanu
author:
   Sam Brannen
since:
   17.02.2003
See Also:   ContextLoaderListener
See Also:   ContextLoaderServlet
See Also:   ConfigurableWebApplicationContext
See Also:   org.springframework.web.context.support.XmlWebApplicationContext



Field Summary
final public static  StringCONFIG_LOCATION_PARAM
     Name of servlet context parameter (i.e., "contextConfigLocation") that can specify the config location for the root context, falling back to the implementation's default otherwise.
final public static  StringCONTEXT_CLASS_PARAM
    
final public static  StringLOCATOR_FACTORY_KEY_PARAM
     Optional servlet context parameter (i.e., "parentContextKey") used only when obtaining a parent context using the default implementation of ContextLoader.loadParentContext(ServletContext servletContext) .
final public static  StringLOCATOR_FACTORY_SELECTOR_PARAM
     Optional servlet context parameter (i.e., "locatorFactorySelector") used only when obtaining a parent context using the default implementation of ContextLoader.loadParentContext(ServletContext servletContext) .


Method Summary
public  voidcloseWebApplicationContext(ServletContext servletContext)
     Close Spring's web application context for the given servlet context.
protected  WebApplicationContextcreateWebApplicationContext(ServletContext servletContext, ApplicationContext parent)
     Instantiate the root WebApplicationContext for this loader, either the default context class or a custom context class if specified.

This implementation expects custom contexts to implement the ConfigurableWebApplicationContext interface.

protected  voidcustomizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext)
     Customize the ConfigurableWebApplicationContext created by this ContextLoader after config locations have been supplied to the context but before the context is refreshed.
protected  ClassdetermineContextClass(ServletContext servletContext)
     Return the WebApplicationContext implementation class to use, either the default XmlWebApplicationContext or a custom context class if specified.
public  WebApplicationContextinitWebApplicationContext(ServletContext servletContext)
     Initialize Spring's web application context for the given servlet context, according to the " ContextLoader.CONTEXT_CLASS_PARAM contextClass " and " ContextLoader.CONFIG_LOCATION_PARAM contextConfigLocation " context-params.
protected  ApplicationContextloadParentContext(ServletContext servletContext)
     Template method with default implementation (which may be overridden by a subclass), to load or obtain an ApplicationContext instance which will be used as the parent context of the root WebApplicationContext.

Field Detail
CONFIG_LOCATION_PARAM
final public static String CONFIG_LOCATION_PARAM(Code)
Name of servlet context parameter (i.e., "contextConfigLocation") that can specify the config location for the root context, falling back to the implementation's default otherwise.
See Also:   org.springframework.web.context.support.XmlWebApplicationContext.DEFAULT_CONFIG_LOCATION



CONTEXT_CLASS_PARAM
final public static String CONTEXT_CLASS_PARAM(Code)
Config param for the root WebApplicationContext implementation class to use: "contextClass"



LOCATOR_FACTORY_KEY_PARAM
final public static String LOCATOR_FACTORY_KEY_PARAM(Code)
Optional servlet context parameter (i.e., "parentContextKey") used only when obtaining a parent context using the default implementation of ContextLoader.loadParentContext(ServletContext servletContext) . Specifies the 'factoryKey' used in the BeanFactoryLocator.useBeanFactory(String factoryKey) method call, obtaining the parent application context from the BeanFactoryLocator instance.

Supplying this "parentContextKey" parameter is sufficient when relying on the default classpath*:beanRefContext.xml selector for candidate factory references.




LOCATOR_FACTORY_SELECTOR_PARAM
final public static String LOCATOR_FACTORY_SELECTOR_PARAM(Code)
Optional servlet context parameter (i.e., "locatorFactorySelector") used only when obtaining a parent context using the default implementation of ContextLoader.loadParentContext(ServletContext servletContext) . Specifies the 'selector' used in the ContextSingletonBeanFactoryLocator.getInstance(String selector) method call, which is used to obtain the BeanFactoryLocator instance from which the parent context is obtained.

The default is classpath*:beanRefContext.xml, matching the default applied for the ContextSingletonBeanFactoryLocator.getInstance method. Supplying the "parentContextKey" parameter is sufficient in this case.






Method Detail
closeWebApplicationContext
public void closeWebApplicationContext(ServletContext servletContext)(Code)
Close Spring's web application context for the given servlet context. If the default ContextLoader.loadParentContext(ServletContext) implementation, which uses ContextSingletonBeanFactoryLocator, has loaded any shared parent context, release one reference to that shared parent context.

If overriding ContextLoader.loadParentContext(ServletContext) , you may have to override this method as well.
Parameters:
  servletContext - the ServletContext that the WebApplicationContext runs in




createWebApplicationContext
protected WebApplicationContext createWebApplicationContext(ServletContext servletContext, ApplicationContext parent) throws BeansException(Code)
Instantiate the root WebApplicationContext for this loader, either the default context class or a custom context class if specified.

This implementation expects custom contexts to implement the ConfigurableWebApplicationContext interface. Can be overridden in subclasses.

In addition, ContextLoader.customizeContext gets called prior to refreshing the context, allowing subclasses to perform custom modifications to the context.
Parameters:
  servletContext - current servlet context
Parameters:
  parent - the parent ApplicationContext to use, or null if none the root WebApplicationContext
throws:
  BeansException - if the context couldn't be initialized
See Also:   ConfigurableWebApplicationContext




customizeContext
protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext)(Code)
Customize the ConfigurableWebApplicationContext created by this ContextLoader after config locations have been supplied to the context but before the context is refreshed.

The default implementation is empty but can be overridden in subclasses to customize the application context.
Parameters:
  servletContext - the current servlet context
Parameters:
  applicationContext - the newly created application context
See Also:   ContextLoader.createWebApplicationContext(ServletContext,ApplicationContext)




determineContextClass
protected Class determineContextClass(ServletContext servletContext) throws ApplicationContextException(Code)
Return the WebApplicationContext implementation class to use, either the default XmlWebApplicationContext or a custom context class if specified.
Parameters:
  servletContext - current servlet context the WebApplicationContext implementation class to use
throws:
  ApplicationContextException - if the context class couldn't be loaded
See Also:   ContextLoader.CONTEXT_CLASS_PARAM
See Also:   org.springframework.web.context.support.XmlWebApplicationContext



initWebApplicationContext
public WebApplicationContext initWebApplicationContext(ServletContext servletContext) throws IllegalStateException, BeansException(Code)
Initialize Spring's web application context for the given servlet context, according to the " ContextLoader.CONTEXT_CLASS_PARAM contextClass " and " ContextLoader.CONFIG_LOCATION_PARAM contextConfigLocation " context-params.
Parameters:
  servletContext - current servlet context the new WebApplicationContext
throws:
  IllegalStateException - if there is already a root application context present
throws:
  BeansException - if the context failed to initialize
See Also:   ContextLoader.CONTEXT_CLASS_PARAM
See Also:   ContextLoader.CONFIG_LOCATION_PARAM



loadParentContext
protected ApplicationContext loadParentContext(ServletContext servletContext) throws BeansException(Code)
Template method with default implementation (which may be overridden by a subclass), to load or obtain an ApplicationContext instance which will be used as the parent context of the root WebApplicationContext. If the return value from the method is null, no parent context is set.

The main reason to load a parent context here is to allow multiple root web application contexts to all be children of a shared EAR context, or alternately to also share the same parent context that is visible to EJBs. For pure web applications, there is usually no need to worry about having a parent context to the root web application context.

The default implementation uses org.springframework.context.access.ContextSingletonBeanFactoryLocator ContextSingletonBeanFactoryLocator , configured via ContextLoader.LOCATOR_FACTORY_SELECTOR_PARAM and ContextLoader.LOCATOR_FACTORY_KEY_PARAM , to load a parent context which will be shared by all other users of ContextsingletonBeanFactoryLocator which also use the same configuration parameters.
Parameters:
  servletContext - current servlet context the parent application context, or null if none
throws:
  BeansException - if the context couldn't be initialized
See Also:   org.springframework.context.access.ContextSingletonBeanFactoryLocator




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(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.