Class ClientlibServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- org.apache.sling.api.servlets.SlingSafeMethodsServlet
-
- com.composum.sling.clientlibs.servlet.AbstractClientlibServlet
-
- com.composum.sling.clientlibs.servlet.ClientlibServlet
-
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
public class ClientlibServlet extends AbstractClientlibServlet
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ClientlibConfigurationconfigurationprotected static PatternFILENAME_PATTERNprotected static PatternHASHSUFFIX_PATTERNprotected ClientlibServiceservice
-
Constructor Summary
Constructors Constructor Description ClientlibServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringappendHashSuffix(String url, String hash)Appends a suffix containing the hash code, if given.protected voiddoGet(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)protected voiddoHead(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)protected @NotNull ClientlibServicegetClientlibService()protected ClientlibConfiguration.ConfiggetConfig()static StringmakePath(String path, Clientlib.Type type, boolean minified, String hash)Creates an path that is rendered by this servlet containing the given parameters.protected StringmakeUri(boolean minified, ClientlibLink link)static StringparseHashFromSuffix(String suffix)Does the inverse toappendHashSuffix(String, String): extracts the hash from the generated suffix.-
Methods inherited from class com.composum.sling.clientlibs.servlet.AbstractClientlibServlet
deliverClientlib, isMinified, makeUrl, usefulRequest
-
Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServlet
doGeneric, doOptions, doTrace, getAllowedRequestMethods, getServletInfo, handleMethodNotImplemented, mayService, service, service
-
-
-
-
Field Detail
-
FILENAME_PATTERN
protected static final Pattern FILENAME_PATTERN
-
HASHSUFFIX_PATTERN
protected static final Pattern HASHSUFFIX_PATTERN
-
service
protected ClientlibService service
-
configuration
protected ClientlibConfiguration configuration
-
-
Method Detail
-
getClientlibService
@NotNull protected @NotNull ClientlibService getClientlibService()
- Specified by:
getClientlibServicein classAbstractClientlibServlet
-
getConfig
@NotNull protected ClientlibConfiguration.Config getConfig()
- Specified by:
getConfigin classAbstractClientlibServlet
-
doGet
protected void doGet(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException- Overrides:
doGetin classorg.apache.sling.api.servlets.SlingSafeMethodsServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doHead
protected void doHead(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull org.apache.sling.api.SlingHttpServletResponse response) throws javax.servlet.ServletException, IOException- Overrides:
doHeadin classorg.apache.sling.api.servlets.SlingSafeMethodsServlet- Throws:
javax.servlet.ServletExceptionIOException
-
makePath
public static String makePath(String path, Clientlib.Type type, boolean minified, String hash)
Creates an path that is rendered by this servlet containing the given parameters.
-
makeUri
protected String makeUri(boolean minified, ClientlibLink link)
- Specified by:
makeUriin classAbstractClientlibServlet
-
appendHashSuffix
public static String appendHashSuffix(String url, String hash)
Appends a suffix containing the hash code, if given. The file name is repeated to satisfy browsers with the correct type and file name, though it is not used by the servlet.- Parameters:
url- an url to which we append the suffixhash- optional, the hash code- Returns:
- the url with suffix /{hash}/{filename} appended, where {filename} is the last part of a / separated url.
-
parseHashFromSuffix
public static String parseHashFromSuffix(String suffix)
Does the inverse toappendHashSuffix(String, String): extracts the hash from the generated suffix.- Parameters:
suffix- the suffix generated byappendHashSuffix(String, String), nullable- Returns:
- the hash if it could be extracted, otherwise null.
-
-