java.lang.Object
ch.ralscha.extdirectspring.util.ExtDirectSpringUtil
Utility class
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCacheHeaders(jakarta.servlet.http.HttpServletResponse response, String etag, Integer month) Adds Expires, ETag and Cache-Control response headers.static booleanChecks if two objects are equal.static StringgenerateApiString(org.springframework.context.ApplicationContext ctx) Returns the api configuration as a String.static StringgenerateApiString(org.springframework.context.ApplicationContext ctx, String remotingVarName, String pollingApiVarName) Returns the api configuration as a Stringstatic StringConverts a stacktrace into a Stringstatic voidhandleCacheableResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, byte[] data, String contentType) Checks etag and sends back HTTP status 304 if not modified.static Objectinvoke(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Locale locale, org.springframework.context.ApplicationContext context, ExtDirectRequest directRequest, ParametersResolver parametersResolver, MethodInfoCache cache) static Objectinvoke(org.springframework.context.ApplicationContext context, String beanName, MethodInfo methodInfo, Object[] params) Invokes a method on a Spring managed bean.static booleanisMultipart(jakarta.servlet.http.HttpServletRequest request) Checks if the request is a multipart request
-
Field Details
-
UTF8_CHARSET
-
-
Method Details
-
equal
Checks if two objects are equal. Returns true if both objects are null- Parameters:
a- object oneb- object two- Returns:
- true if objects are equal
-
isMultipart
public static boolean isMultipart(jakarta.servlet.http.HttpServletRequest request) Checks if the request is a multipart request- Parameters:
request- the HTTP servlet request- Returns:
- true if request is a Multipart request (file upload)
-
invoke
public static Object invoke(org.springframework.context.ApplicationContext context, String beanName, MethodInfo methodInfo, Object[] params) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException Invokes a method on a Spring managed bean.- Parameters:
context- a Spring application contextbeanName- the name of the beanmethodInfo- the methodInfo objectparams- the parameters- Returns:
- the result of the method invocation
- Throws:
IllegalArgumentException- if there is no bean in the contextIllegalAccessExceptionInvocationTargetException
-
invoke
public static Object invoke(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Locale locale, org.springframework.context.ApplicationContext context, ExtDirectRequest directRequest, ParametersResolver parametersResolver, MethodInfoCache cache) throws Exception - Throws:
Exception
-
getStackTrace
Converts a stacktrace into a String- Parameters:
t- a Throwable- Returns:
- the whole stacktrace in a String
-
addCacheHeaders
public static void addCacheHeaders(jakarta.servlet.http.HttpServletResponse response, String etag, Integer month) Adds Expires, ETag and Cache-Control response headers.- Parameters:
response- the HTTP servlet responseetag- the calculated etag (md5) of the responsemonth- number of months the response can be cached. Added to the Expires and Cache-Control header. If null defaults to 6 months.
-
handleCacheableResponse
public static void handleCacheableResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, byte[] data, String contentType) throws IOException Checks etag and sends back HTTP status 304 if not modified. If modified sets content type and content length, adds cache headers (addCacheHeaders(HttpServletResponse, String, Integer)), writes the data into theServletResponse.getOutputStream()and flushes it.- Parameters:
request- the HTTP servlet requestresponse- the HTTP servlet responsedata- the response datacontentType- the content type of the data (i.e. "application/javascript;charset=utf-8")- Throws:
IOException
-
generateApiString
public static String generateApiString(org.springframework.context.ApplicationContext ctx) throws com.fasterxml.jackson.core.JsonProcessingException Returns the api configuration as a String. Uses "REMOTING_API" and "POLLING_URLS" for the variable names- Parameters:
ctx- The spring applicationcontext- Returns:
- the api configuration
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
generateApiString
public static String generateApiString(org.springframework.context.ApplicationContext ctx, String remotingVarName, String pollingApiVarName) throws com.fasterxml.jackson.core.JsonProcessingException Returns the api configuration as a String- Parameters:
ctx- The spring applicationcontextremotingVarName- name of the variable for the remoting configuration (e.g. REMOTING_API)pollingApiVarName- name of the variable for the polling configuration (e.g. POLLING_URLS)- Returns:
- the api configuration
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-