Class SimpleHybrisWidgetResourceLoader
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- com.hybris.cockpitng.core.persistence.packaging.SimpleHybrisWidgetResourceLoader
-
- All Implemented Interfaces:
Resettable,java.io.Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
- Direct Known Subclasses:
ExtendedWidgetResourceLoader
public class SimpleHybrisWidgetResourceLoader extends javax.servlet.http.HttpServlet implements Resettable
Serves resources located in a widget library.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAPPLICATION_THEME_CSSprotected static java.util.Map<java.lang.String,java.lang.String>CACHED_MERGED_CSSstatic java.lang.StringCNGPRELOADstatic java.lang.StringCNGPRELOAD_CSSstatic java.lang.StringCOCKPITNG_RESOURCELOADER_CACHE_EXPIRATIONstatic java.lang.StringCOCKPITNG_WIDGET_RESOURCE_LOADER_CACHE_CONTROLstatic java.lang.StringCSS_CACHE_ENABLEDstatic java.lang.StringCSS_LEGACY_IE_IMPORTprotected static java.util.Map<java.lang.String,java.lang.String>IE_CSS_SPLIT_CACHEprotected static java.lang.StringJS_DEPENDENCY_VARIABLEstatic intMAX_LEGACY_IE_IMPORT_FILESstatic intMAX_LEGACY_IE_IMPORT_FILES_LEVEL_1static intMAX_LEGACY_IE_IMPORT_FILES_NESTING_LEVEL
-
Constructor Summary
Constructors Constructor Description SimpleHybrisWidgetResourceLoader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappendResponse(java.io.InputStream is, javax.servlet.http.HttpServletResponse resp)static voidclearCssCache()static java.text.DateFormatcreateHtmlDateFormat()protected voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)protected voiddoGetInternal(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)protected org.springframework.web.context.WebApplicationContextgetApplicationContext()CockpitPropertiesgetCockpitProperties()protected java.util.List<java.lang.String>getCssFilesAsStrings(java.lang.String mainSlotId, javax.servlet.http.HttpServletRequest request)Returns all css resources that should be preloaded as strings.ResourceLoadergetFallbackResourceLoader()protected java.io.InputStreamgetResourceAsStream(java.lang.String uri)protected java.io.InputStreamgetResourceAsStreamFromJar(WidgetJarLibInfo widgetJarLibInfo, java.lang.String resourceName)protected java.io.InputStreamgetResourceAsStreamFromJar(java.io.File jarFile, java.lang.String resourceName)protected java.io.InputStreamgetResourceAsStreamFromJar(java.lang.String uri)protected WidgetLibUtilsgetWidgetLibUtils()CockpitResourceLoadergetWidgetResourceReader()protected booleanhasResourceInJar(java.lang.String uri)voidinit()protected booleanisCssCached()protected booleanisSplitForLegacyIeEnabled()As described here on MSDN legacy IE versions may struggle interpreting more than 31 import declarations in css stylesheets.protected java.lang.StringprocessRequestURI(java.lang.String requestURI, javax.servlet.http.HttpServletRequest req)protected voidprocessResponseHeader(java.lang.String requestURI, javax.servlet.http.HttpServletResponse resp)voidreset()Resets the something the implementation provides.protected voidsplitImportsForLegacyIe(java.lang.String idPrefix, java.util.List<java.lang.String> urls, java.lang.StringBuilder builder, int level)Method used to distribute the files according to the limit of imports allowed by legacy IE versions.protected voidwriteCachedCssChunkForLegacyIe(java.lang.String cacheKey, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)The method should write the content of the requested resource into the output stream.protected voidwriteMergedWidgetCss(java.lang.String mainSlotId, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
-
-
-
-
Field Detail
-
COCKPITNG_RESOURCELOADER_CACHE_EXPIRATION
public static final java.lang.String COCKPITNG_RESOURCELOADER_CACHE_EXPIRATION
- See Also:
- Constant Field Values
-
COCKPITNG_WIDGET_RESOURCE_LOADER_CACHE_CONTROL
public static final java.lang.String COCKPITNG_WIDGET_RESOURCE_LOADER_CACHE_CONTROL
- See Also:
- Constant Field Values
-
CSS_CACHE_ENABLED
public static final java.lang.String CSS_CACHE_ENABLED
- See Also:
- Constant Field Values
-
CSS_LEGACY_IE_IMPORT
public static final java.lang.String CSS_LEGACY_IE_IMPORT
- See Also:
- Constant Field Values
-
APPLICATION_THEME_CSS
public static final java.lang.String APPLICATION_THEME_CSS
- See Also:
- Constant Field Values
-
MAX_LEGACY_IE_IMPORT_FILES
public static final int MAX_LEGACY_IE_IMPORT_FILES
- See Also:
- Constant Field Values
-
MAX_LEGACY_IE_IMPORT_FILES_LEVEL_1
public static final int MAX_LEGACY_IE_IMPORT_FILES_LEVEL_1
- See Also:
- Constant Field Values
-
MAX_LEGACY_IE_IMPORT_FILES_NESTING_LEVEL
public static final int MAX_LEGACY_IE_IMPORT_FILES_NESTING_LEVEL
- See Also:
- Constant Field Values
-
CNGPRELOAD_CSS
public static final java.lang.String CNGPRELOAD_CSS
- See Also:
- Constant Field Values
-
CNGPRELOAD
public static final java.lang.String CNGPRELOAD
- See Also:
- Constant Field Values
-
CACHED_MERGED_CSS
protected static final java.util.Map<java.lang.String,java.lang.String> CACHED_MERGED_CSS
-
IE_CSS_SPLIT_CACHE
protected static final java.util.Map<java.lang.String,java.lang.String> IE_CSS_SPLIT_CACHE
-
JS_DEPENDENCY_VARIABLE
protected static final java.lang.String JS_DEPENDENCY_VARIABLE
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init() throws javax.servlet.ServletException- Overrides:
initin classjavax.servlet.GenericServlet- Throws:
javax.servlet.ServletException
-
clearCssCache
public static void clearCssCache()
-
createHtmlDateFormat
public static java.text.DateFormat createHtmlDateFormat()
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, java.io.IOException- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
doGetInternal
protected void doGetInternal(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, java.io.IOException- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
processResponseHeader
protected void processResponseHeader(java.lang.String requestURI, javax.servlet.http.HttpServletResponse resp)
-
getWidgetLibUtils
protected WidgetLibUtils getWidgetLibUtils()
-
getCockpitProperties
public CockpitProperties getCockpitProperties()
-
getWidgetResourceReader
public CockpitResourceLoader getWidgetResourceReader()
-
getFallbackResourceLoader
public ResourceLoader getFallbackResourceLoader()
-
getApplicationContext
protected org.springframework.web.context.WebApplicationContext getApplicationContext()
-
getResourceAsStreamFromJar
protected java.io.InputStream getResourceAsStreamFromJar(WidgetJarLibInfo widgetJarLibInfo, java.lang.String resourceName)
-
getResourceAsStreamFromJar
protected java.io.InputStream getResourceAsStreamFromJar(java.io.File jarFile, java.lang.String resourceName)
-
getResourceAsStreamFromJar
protected java.io.InputStream getResourceAsStreamFromJar(java.lang.String uri)
-
hasResourceInJar
protected boolean hasResourceInJar(java.lang.String uri)
-
getResourceAsStream
protected java.io.InputStream getResourceAsStream(java.lang.String uri)
-
processRequestURI
protected java.lang.String processRequestURI(java.lang.String requestURI, javax.servlet.http.HttpServletRequest req)
-
writeMergedWidgetCss
protected void writeMergedWidgetCss(java.lang.String mainSlotId, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException- Throws:
java.io.IOException
-
splitImportsForLegacyIe
protected void splitImportsForLegacyIe(java.lang.String idPrefix, java.util.List<java.lang.String> urls, java.lang.StringBuilder builder, int level)Method used to distribute the files according to the limit of imports allowed by legacy IE versions.- Parameters:
idPrefix- prefix for caching partial css filesurls- collection of files to importbuilder- content of a file should be written to the builder
-
isSplitForLegacyIeEnabled
protected boolean isSplitForLegacyIeEnabled()
As described here on MSDN legacy IE versions may struggle interpreting more than 31 import declarations in css stylesheets. This method allows to enable legacy IE support workaround.- Returns:
- true if legacy IE should be supported
-
writeCachedCssChunkForLegacyIe
protected void writeCachedCssChunkForLegacyIe(java.lang.String cacheKey, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws java.io.IOExceptionThe method should write the content of the requested resource into the output stream.- Parameters:
cacheKey- key under which the css is storedreq- http requestresp- http response- Throws:
java.io.IOException
-
getCssFilesAsStrings
protected java.util.List<java.lang.String> getCssFilesAsStrings(java.lang.String mainSlotId, javax.servlet.http.HttpServletRequest request)Returns all css resources that should be preloaded as strings.- Parameters:
mainSlotId- the widgets mainSlot idrequest- the request passed todoGet(HttpServletRequest, HttpServletResponse)
-
isCssCached
protected boolean isCssCached()
-
appendResponse
protected void appendResponse(java.io.InputStream is, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException- Throws:
java.io.IOException
-
reset
public void reset()
Description copied from interface:ResettableResets the something the implementation provides.- Specified by:
resetin interfaceResettable
-
-