ro.isdc.wro.http.support
Class ServletContextAttributeHelper

java.lang.Object
  extended by ro.isdc.wro.http.support.ServletContextAttributeHelper

public class ServletContextAttributeHelper
extends Object

Encapsulates the details of storing/retrieving attributes from ServletContext.
This class know how to handle multiple WroFilter & WroServletContextListener configurations, by setting the attributes with a unique key computed based on provided name (using getName(). Use this class to retrieve wro4j related attributes, instead of hard-coding the name of the attribute to retrieve.

Usage scenario:

Since:
1.4.6
Author:
Alex Objelean

Field Summary
static String DEFAULT_NAME
          Default value of the name init param.
 
Constructor Summary
ServletContextAttributeHelper(javax.servlet.ServletContext servletContext)
          Uses default name for storing/retrieving attributes in ServletContext.
ServletContextAttributeHelper(javax.servlet.ServletContext servletContext, String name)
          Uses default name to work with ServletContext attribute.
 
Method Summary
 void clear()
          Remove all attributes from ServletContext.
static ServletContextAttributeHelper create(javax.servlet.FilterConfig filterConfig)
          Factory method which uses default name for storing/retrieving attributes in ServletContext.
 WroManagerFactory getManagerFactory()
           
 WroConfiguration getWroConfiguration()
           
 void setManagerFactory(WroManagerFactory managerFactory)
          Set the configuration object as a servletContext attribute.
 void setWroConfiguration(WroConfiguration config)
          Set the configuration object as a servletContext attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAME

public static final String DEFAULT_NAME
Default value of the name init param. This one is used when no value is defined.

See Also:
Constant Field Values
Constructor Detail

ServletContextAttributeHelper

public ServletContextAttributeHelper(javax.servlet.ServletContext servletContext)
Uses default name for storing/retrieving attributes in ServletContext.


ServletContextAttributeHelper

public ServletContextAttributeHelper(javax.servlet.ServletContext servletContext,
                                     String name)
Uses default name to work with ServletContext attribute.

Parameters:
servletContext - a not null ServletContext object.
name - of the listener for which the helper will be used.
Method Detail

create

public static ServletContextAttributeHelper create(javax.servlet.FilterConfig filterConfig)
Factory method which uses default name for storing/retrieving attributes in ServletContext.


getManagerFactory

public WroManagerFactory getManagerFactory()
Returns:
the WroManagerFactory stored in servletContext.

getWroConfiguration

public WroConfiguration getWroConfiguration()
Returns:
the WroConfiguration stored in servletContext.

setWroConfiguration

public void setWroConfiguration(WroConfiguration config)
Set the configuration object as a servletContext attribute.


setManagerFactory

public void setManagerFactory(WroManagerFactory managerFactory)
Set the configuration object as a servletContext attribute.


clear

public void clear()
Remove all attributes from ServletContext.



Copyright © 2008-2013. All Rights Reserved.