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 ClientlibConfiguration
configuration
protected static Pattern
FILENAME_PATTERN
protected static Pattern
HASHSUFFIX_PATTERN
protected ClientlibService
service
-
Constructor Summary
Constructors Constructor Description ClientlibServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
appendHashSuffix(String url, String hash)
Appends a suffix containing the hash code, if given.protected void
doGet(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)
protected void
doHead(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull org.apache.sling.api.SlingHttpServletResponse response)
protected @NotNull ClientlibService
getClientlibService()
protected ClientlibConfiguration.Config
getConfig()
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.protected String
makeUri(boolean minified, ClientlibLink link)
static String
parseHashFromSuffix(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:
getClientlibService
in classAbstractClientlibServlet
-
getConfig
@NotNull protected ClientlibConfiguration.Config getConfig()
- Specified by:
getConfig
in 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:
doGet
in classorg.apache.sling.api.servlets.SlingSafeMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
-
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:
doHead
in classorg.apache.sling.api.servlets.SlingSafeMethodsServlet
- Throws:
javax.servlet.ServletException
IOException
-
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:
makeUri
in 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.
-
-