ro.isdc.wro.config
Class Context

java.lang.Object
  extended by ro.isdc.wro.config.Context
All Implemented Interfaces:
ReadOnlyContext

public class Context
extends Object
implements ReadOnlyContext

Holds the properties related to a request cycle.

Author:
Alex Objelean

Method Summary
static void destroy()
          Perform context clean-up.
static Context get()
           
 String getAggregatedFolderPath()
          This field is useful only for the aggregated resources of type ResourceType.CSS.
 WroConfiguration getConfig()
           
static String getCorrelationId()
           
 javax.servlet.FilterConfig getFilterConfig()
           
 javax.servlet.http.HttpServletRequest getRequest()
           
 javax.servlet.http.HttpServletResponse getResponse()
           
 javax.servlet.ServletContext getServletContext()
           
static boolean isContextSet()
           
static void set(Context context)
          Set a context with default configuration to current thread.
static void set(Context context, WroConfiguration config)
          Associate a context with the CURRENT request cycle.
 void setAggregatedFolderPath(String aggregatedFolderPath)
           
 void setConfig(WroConfiguration config)
          DO NOT CALL THIS METHOD UNLESS YOU ARE SURE WHAT YOU ARE DOING.
static void setCorrelationId(String correlationId)
          Set the correlationId to the current thread.
static Context standaloneContext()
          A context useful for running in non web context (standalone applications).
 String toString()
          
static void unset()
          Remove context from the local thread.
static void unsetCorrelationId()
          Remove the correlationId from the current thread.
static Context webContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterConfig filterConfig)
          A context useful for running in web context (inside a servlet container).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getConfig

public WroConfiguration getConfig()
Specified by:
getConfig in interface ReadOnlyContext
Returns:
WroConfiguration singleton instance.

setConfig

public void setConfig(WroConfiguration config)
DO NOT CALL THIS METHOD UNLESS YOU ARE SURE WHAT YOU ARE DOING.

sets the WroConfiguration singleton instance.


webContext

public static Context webContext(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 javax.servlet.FilterConfig filterConfig)
A context useful for running in web context (inside a servlet container).


standaloneContext

public static Context standaloneContext()
A context useful for running in non web context (standalone applications).


get

public static Context get()
Returns:
Context associated with CURRENT request cycle.

isContextSet

public static boolean isContextSet()
Returns:
true if the call is done during wro4j request cycle. In other words, if the context is set.

set

public static void set(Context context)
Set a context with default configuration to current thread.


set

public static void set(Context context,
                       WroConfiguration config)
Associate a context with the CURRENT request cycle.

Parameters:
context - Context to set.

unset

public static void unset()
Remove context from the local thread.


getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Specified by:
getRequest in interface ReadOnlyContext
Returns:
the request

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Specified by:
getResponse in interface ReadOnlyContext
Returns:
the response

getServletContext

public javax.servlet.ServletContext getServletContext()
Specified by:
getServletContext in interface ReadOnlyContext
Returns:
the servletContext

getFilterConfig

public javax.servlet.FilterConfig getFilterConfig()
Specified by:
getFilterConfig in interface ReadOnlyContext
Returns:
the filterConfig

getAggregatedFolderPath

public String getAggregatedFolderPath()
This field is useful only for the aggregated resources of type ResourceType.CSS.
The aggregatedFolderPath is used to compute the depth. For example, if aggregatedFolder is "wro" then the depth is 1 and the path used to prefix the image url is "..". If the aggregatedFolder is "css/aggregated", the depth is 2 and the prefix is "../..". The name of the aggregated folder is not important, it is used only to compute the depth.

Specified by:
getAggregatedFolderPath in interface ReadOnlyContext
Returns:
the aggregatedFolderPath

setAggregatedFolderPath

public void setAggregatedFolderPath(String aggregatedFolderPath)
Parameters:
aggregatedFolderPath - the aggregatedFolderPath to set

destroy

public static void destroy()
Perform context clean-up.


setCorrelationId

public static void setCorrelationId(String correlationId)
Set the correlationId to the current thread.


unsetCorrelationId

public static void unsetCorrelationId()
Remove the correlationId from the current thread. This operation will not remove the Context associated with the correlationId. In order to remove context, call unset().

Unsetting correlationId is useful when you create child threads which needs to access the correlationId from the parent thread. This simulates the InheritableThreadLocal functionality.


getCorrelationId

public static String getCorrelationId()
Returns:
the correlationId associated with this thread.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2008-2013. All Rights Reserved.