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


java.lang.Object
   org.springframework.web.struts.ContextLoaderPlugIn

ContextLoaderPlugIn
public class ContextLoaderPlugIn implements PlugIn(Code)
Struts 1.1+ PlugIn that loads a Spring application context for the Struts ActionServlet. This context will automatically refer to the root WebApplicationContext (loaded by ContextLoaderListener/Servlet) as parent.

The default namespace of the WebApplicationContext is the name of the Struts ActionServlet, suffixed with "-servlet" (e.g. "action-servlet"). The default location of the XmlWebApplicationContext configuration file is therefore "/WEB-INF/action-servlet.xml".

 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"/>
The location of the context configuration files can be customized through the "contextConfigLocation" setting, analogous to the root WebApplicationContext and FrameworkServlet contexts.
 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
 <set-property property="contextConfigLocation" value="/WEB-INF/action-servlet.xml /WEB-INF/myContext.xml"/>
 </plug-in>
Beans defined in the ContextLoaderPlugIn context can be accessed from conventional Struts Actions, via fetching the WebApplicationContext reference from the ServletContext. ActionSupport and DispatchActionSupport are pre-built convenience classes that provide easy access to the context.

It is normally preferable to access Spring's root WebApplicationContext in such scenarios, though: A shared middle tier should be defined there rather than in a ContextLoaderPlugin context, for access by any web component. ActionSupport and DispatchActionSupport autodetect the root context too.

A special usage of this PlugIn is to define Struts Actions themselves as beans, typically wiring them with middle tier components defined in the root context. Such Actions will then be delegated to by proxy definitions in the Struts configuration, using the DelegatingActionProxy class or the DelegatingRequestProcessor.

Note that you can use a single ContextLoaderPlugIn for all Struts modules. That context can in turn be loaded from multiple XML files, for example split according to Struts modules. Alternatively, define one ContextLoaderPlugIn per Struts module, specifying appropriate "contextConfigLocation" parameters.

Note: The idea of delegating to Spring-managed Struts Actions originated in Don Brown's Spring Struts Plugin. ContextLoaderPlugIn and DelegatingActionProxy constitute a clean-room implementation of the same idea, essentially superseding the original plugin. Many thanks to Don Brown and Matt Raible for the original work and for the agreement to reimplement the idea in Spring proper!
author:
   Juergen Hoeller
since:
   1.0.1
See Also:   ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX
See Also:   ActionSupport
See Also:   DispatchActionSupport
See Also:   DelegatingActionProxy
See Also:   DelegatingRequestProcessor
See Also:   DelegatingTilesRequestProcessor
See Also:   org.springframework.web.context.ContextLoaderListener
See Also:   org.springframework.web.context.ContextLoaderServlet
See Also:   org.springframework.web.servlet.FrameworkServlet



Field Summary
final public static  ClassDEFAULT_CONTEXT_CLASS
     Default context class for ContextLoaderPlugIn.
final public static  StringDEFAULT_NAMESPACE_SUFFIX
     Suffix for WebApplicationContext namespaces.
final public static  StringSERVLET_CONTEXT_PREFIX
     Prefix for the ServletContext attribute for the WebApplicationContext.
final protected  Loglogger
    


Method Summary
protected  WebApplicationContextcreateWebApplicationContext(WebApplicationContext parent)
     Instantiate the WebApplicationContext for the ActionServlet, either a default XmlWebApplicationContext or a custom context class if set.
public  voiddestroy()
     Close the WebApplicationContext of the ActionServlet.
final public  ActionServletgetActionServlet()
     Return the Struts ActionServlet that this PlugIn is associated with.
public  ClassgetContextClass()
     Return the custom context class.
public  StringgetContextConfigLocation()
     Return the explicit context config location, if any.
final public  ModuleConfiggetModuleConfig()
     Return the Struts ModuleConfig that this PlugIn is associated with.
final public  StringgetModulePrefix()
     Return the prefix of the ModuleConfig that this PlugIn is associated with.
public  StringgetNamespace()
     Return the namespace for the ActionServlet, falling back to default scheme if no custom namespace was set: e.g.
final public  ServletContextgetServletContext()
     Return the ServletContext that this PlugIn is associated with.
public  StringgetServletContextAttributeName()
     Return the ServletContext attribute name for this PlugIn's WebApplicationContext.
final public  StringgetServletName()
     Return the name of the ActionServlet that this PlugIn is associated with.
final public  WebApplicationContextgetWebApplicationContext()
     Return this PlugIn's WebApplicationContext.
final public  voidinit(ActionServlet actionServlet, ModuleConfig moduleConfig)
     Create the ActionServlet's WebApplicationContext.
protected  WebApplicationContextinitWebApplicationContext()
     Initialize and publish the WebApplicationContext for the ActionServlet.

Delegates to ContextLoaderPlugIn.createWebApplicationContext for actual creation.

Can be overridden in subclasses.

protected  voidonInit()
     Callback for custom initialization after the context has been set up.
public  voidsetContextClass(Class contextClass)
     Set a custom context class.
public  voidsetContextClassName(String contextClassName)
     Set a custom context class by name.
public  voidsetContextConfigLocation(String contextConfigLocation)
     Set the context config location explicitly, instead of relying on the default location built from the namespace.
public  voidsetNamespace(String namespace)
     Set a custom namespace for the ActionServlet, to be used for building a default context config location.

Field Detail
DEFAULT_CONTEXT_CLASS
final public static Class DEFAULT_CONTEXT_CLASS(Code)
Default context class for ContextLoaderPlugIn.
See Also:   org.springframework.web.context.support.XmlWebApplicationContext



DEFAULT_NAMESPACE_SUFFIX
final public static String DEFAULT_NAMESPACE_SUFFIX(Code)
Suffix for WebApplicationContext namespaces. If a Struts ActionServlet is given the name "action" in a context, the namespace used by this PlugIn will resolve to "action-servlet".



SERVLET_CONTEXT_PREFIX
final public static String SERVLET_CONTEXT_PREFIX(Code)
Prefix for the ServletContext attribute for the WebApplicationContext. The completion is the Struts module name.



logger
final protected Log logger(Code)





Method Detail
createWebApplicationContext
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) throws BeansException(Code)
Instantiate the WebApplicationContext for the ActionServlet, either a default XmlWebApplicationContext or a custom context class if set.

This implementation expects custom contexts to implement ConfigurableWebApplicationContext. Can be overridden in subclasses.
throws:
  org.springframework.beans.BeansException - if the context couldn't be initialized
See Also:   ContextLoaderPlugIn.setContextClass
See Also:   org.springframework.web.context.support.XmlWebApplicationContext




destroy
public void destroy()(Code)
Close the WebApplicationContext of the ActionServlet.
See Also:   org.springframework.context.ConfigurableApplicationContext.close



getActionServlet
final public ActionServlet getActionServlet()(Code)
Return the Struts ActionServlet that this PlugIn is associated with.



getContextClass
public Class getContextClass()(Code)
Return the custom context class.



getContextConfigLocation
public String getContextConfigLocation()(Code)
Return the explicit context config location, if any.



getModuleConfig
final public ModuleConfig getModuleConfig()(Code)
Return the Struts ModuleConfig that this PlugIn is associated with.



getModulePrefix
final public String getModulePrefix()(Code)
Return the prefix of the ModuleConfig that this PlugIn is associated with.
See Also:   org.apache.struts.config.ModuleConfig.getPrefix



getNamespace
public String getNamespace()(Code)
Return the namespace for the ActionServlet, falling back to default scheme if no custom namespace was set: e.g. "test-servlet" for a servlet named "test".



getServletContext
final public ServletContext getServletContext()(Code)
Return the ServletContext that this PlugIn is associated with.



getServletContextAttributeName
public String getServletContextAttributeName()(Code)
Return the ServletContext attribute name for this PlugIn's WebApplicationContext.

The default implementation returns SERVLET_CONTEXT_PREFIX + module prefix.
See Also:   ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX
See Also:   ContextLoaderPlugIn.getModulePrefix()




getServletName
final public String getServletName()(Code)
Return the name of the ActionServlet that this PlugIn is associated with.



getWebApplicationContext
final public WebApplicationContext getWebApplicationContext()(Code)
Return this PlugIn's WebApplicationContext.



init
final public void init(ActionServlet actionServlet, ModuleConfig moduleConfig) throws ServletException(Code)
Create the ActionServlet's WebApplicationContext.



initWebApplicationContext
protected WebApplicationContext initWebApplicationContext() throws BeansException, IllegalStateException(Code)
Initialize and publish the WebApplicationContext for the ActionServlet.

Delegates to ContextLoaderPlugIn.createWebApplicationContext for actual creation.

Can be overridden in subclasses. Call getActionServlet() and/or getModuleConfig() to access the Struts configuration that this PlugIn is associated with.
throws:
  org.springframework.beans.BeansException - if the context couldn't be initialized
throws:
  IllegalStateException - if there is already a context for the Struts ActionServlet
See Also:   ContextLoaderPlugIn.getActionServlet()
See Also:   ContextLoaderPlugIn.getServletName()
See Also:   ContextLoaderPlugIn.getServletContext()
See Also:   ContextLoaderPlugIn.getModuleConfig()
See Also:   ContextLoaderPlugIn.getModulePrefix()




onInit
protected void onInit() throws ServletException(Code)
Callback for custom initialization after the context has been set up.
throws:
  ServletException - if initialization failed



setContextClass
public void setContextClass(Class contextClass)(Code)
Set a custom context class. This class must be of type WebApplicationContext, when using the default ContextLoaderPlugIn implementation, the context class must also implement ConfigurableWebApplicationContext.
See Also:   ContextLoaderPlugIn.createWebApplicationContext



setContextClassName
public void setContextClassName(String contextClassName) throws ClassNotFoundException(Code)
Set a custom context class by name. This class must be of type WebApplicationContext, when using the default ContextLoaderPlugIn implementation, the context class must also implement ConfigurableWebApplicationContext.
See Also:   ContextLoaderPlugIn.createWebApplicationContext



setContextConfigLocation
public void setContextConfigLocation(String contextConfigLocation)(Code)
Set the context config location explicitly, instead of relying on the default location built from the namespace. This location string can consist of multiple locations separated by any number of commas and spaces.



setNamespace
public void setNamespace(String namespace)(Code)
Set a custom namespace for the ActionServlet, to be used for building a default context config location.



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.