|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ro.isdc.wro.http.support.ServletContextAttributeHelper
public class ServletContextAttributeHelper
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.
WroFilter
and a
WroServletContextListener
configured in web.xml. In order to retrieve/store attributes in servlet context
use:
ServletContextAttributeHelper
helper = newServletContextAttributeHelper
(servletContext);WroConfiguration
config = helper.getWroConfiguration();WroManagerFactory
managerFactory = helper.getManagerFactory();
WroFilter
configurations in web.xml (each should have a dedicated listener
extended form WroServletContextListener
). In order to retrieve/store attributes in servlet context use:
String name = ..//the name of the filter (defined in init-param called name).ServletContextAttributeHelper
helper = newServletContextAttributeHelper
(servletContext, name);WroConfiguration
config = helper.getWroConfiguration();WroManagerFactory
managerFactory = helper.getManagerFactory();
WroFilter
configurations in web.xml, you can retrieve/store attributes from
within a filter using:
This example is similar to previous, except that the name of the filter will be extracted in the factory method.ServletContextAttributeHelper
helper =ServletContextAttributeHelper
.create(filterConfig);WroConfiguration
config = helper.getWroConfiguration();WroManagerFactory
managerFactory = helper.getManagerFactory();
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 |
---|
public static final String DEFAULT_NAME
Constructor Detail |
---|
public ServletContextAttributeHelper(javax.servlet.ServletContext servletContext)
ServletContext
.
public ServletContextAttributeHelper(javax.servlet.ServletContext servletContext, String name)
ServletContext
attribute.
servletContext
- a not null ServletContext
object.name
- of the listener for which the helper will be used.Method Detail |
---|
public static ServletContextAttributeHelper create(javax.servlet.FilterConfig filterConfig)
ServletContext
.
public WroManagerFactory getManagerFactory()
WroManagerFactory
stored in servletContext.public WroConfiguration getWroConfiguration()
WroConfiguration
stored in servletContext.public void setWroConfiguration(WroConfiguration config)
public void setManagerFactory(WroManagerFactory managerFactory)
public void clear()
ServletContext
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |