org.jasig.springframework.web.portlet.context
Class PortletApplicationContextUtils2

java.lang.Object
  extended by org.jasig.springframework.web.portlet.context.PortletApplicationContextUtils2

public class PortletApplicationContextUtils2
extends Object

Convenience methods for retrieving the root PortletApplicationContext for a given PortletContext. This is e.g. useful for accessing a Spring context from within custom web views or Struts actions.

Note that there are more convenient ways of accessing the root context for many portlet frameworks, either part of Spring or available as external library. This helper class is just the most generic way to access the root context.

Author:
Juergen Hoeller, Eric Dalquist
See Also:
ContextLoaderFilter, FrameworkPortlet, DispatcherPortlet

Field Summary
static String ROOT_PORTLET_APPLICATION_CONTEXT_LOADER_ATTRIBUTE
          Context attribute to bind root PortletContextLoader
 
Constructor Summary
PortletApplicationContextUtils2()
           
 
Method Summary
static PortletApplicationContext getPortletApplicationContext(javax.portlet.PortletContext pc)
          Find the root PortletApplicationContext for this portlet application, which is typically loaded via PortletContextLoaderListener.
static PortletApplicationContext getPortletApplicationContext(javax.portlet.PortletContext pc, String attrName)
          Find a custom PortletApplicationContext for this web application.
static PortletApplicationContext getRequiredPortletApplicationContext(javax.portlet.PortletContext pc)
          Find the root PortletApplicationContext for this portlet application, which is typically loaded via ContextLoaderFilter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_PORTLET_APPLICATION_CONTEXT_LOADER_ATTRIBUTE

public static final String ROOT_PORTLET_APPLICATION_CONTEXT_LOADER_ATTRIBUTE
Context attribute to bind root PortletContextLoader

Constructor Detail

PortletApplicationContextUtils2

public PortletApplicationContextUtils2()
Method Detail

getRequiredPortletApplicationContext

public static PortletApplicationContext getRequiredPortletApplicationContext(javax.portlet.PortletContext pc)
                                                                      throws IllegalStateException
Find the root PortletApplicationContext for this portlet application, which is typically loaded via ContextLoaderFilter.

Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.

Parameters:
pc - PortletContext to find the portlet application context for
Returns:
the root PortletApplicationContext for this portlet app
Throws:
IllegalStateException - if the root PortletApplicationContext could not be found
See Also:
PortletApplicationContextUtils2#ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE

getPortletApplicationContext

public static PortletApplicationContext getPortletApplicationContext(javax.portlet.PortletContext pc)
Find the root PortletApplicationContext for this portlet application, which is typically loaded via PortletContextLoaderListener.

Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.

Parameters:
pc - PortletContext to find the web application context for
Returns:
the root PortletApplicationContext for this portlet app, or null if none
See Also:
PortletApplicationContextUtils2#ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE

getPortletApplicationContext

public static PortletApplicationContext getPortletApplicationContext(javax.portlet.PortletContext pc,
                                                                     String attrName)
Find a custom PortletApplicationContext for this web application.

Parameters:
pc - PortletContext to find the web application context for
attrName - the name of the PortletContext attribute to look for
Returns:
the desired PortletApplicationContext for this web app, or null if none


Copyright © 2013 Jasig. All Rights Reserved.