Class IOUtils
- java.lang.Object
-
- org.atmosphere.util.IOUtils
-
public class IOUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description IOUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose(java.io.Closeable... closeableArray)Tries to close the given objects and log theIOExceptionat INFO level to make the code more readable when we assume that theIOExceptionwon't be managed.static voiddeliver(java.lang.Object o, DeliverTo deliverConfig, DeliverTo.DELIVER_TO defaultDeliver, AtmosphereResource r)Delivers the given message according to the specifiedconfiguration).static byte[]forceReadEntirelyAsByte(AtmosphereResource r)Reads request body as bytes without respectApplicationConfig.READ_GET_BODYparameterstatic java.lang.StringgetCleanedServletPath(java.lang.String fullServletPath)Used to remove trailing slash and wildcard from a servlet path.
Examples :
- "/foo/" becomes "/foo"
- "foo/bar" becomes "/foo/bar"static java.lang.StringguestRawServletPath(AtmosphereConfig config)static java.lang.StringguestServletPath(AtmosphereConfig config)static booleanisAtmosphere(java.lang.String className)static booleanisBodyBinary(AtmosphereRequest request)static booleanisBodyEmpty(java.lang.Object o)static java.lang.Class<?>loadClass(java.lang.Class<?> thisClass, java.lang.String className)Loading the specified class using some heuristics to support various containers The order of preferece is: 1.static java.lang.ObjectreadEntirely(AtmosphereResource r)static byte[]readEntirelyAsByte(AtmosphereResource r)static java.lang.StringBuilderreadEntirelyAsString(AtmosphereResource r)static java.util.Map<java.lang.String,AtmosphereFramework.MetaServiceAction>readServiceFile(java.lang.String path)This method reads the given file stored under "META-INF/services" and accessed through the framework's class loader to specify a list ofactionsto be done on different service classes (AtmosphereInterceptor,BroadcastFilter, etc).static java.lang.StringrealPath(jakarta.servlet.ServletContext servletContext, java.lang.String targetPath)
-
-
-
Method Detail
-
deliver
public static void deliver(java.lang.Object o, DeliverTo deliverConfig, DeliverTo.DELIVER_TO defaultDeliver, AtmosphereResource r)Delivers the given message according to the specified
configuration).- Parameters:
o- the messagedeliverConfig- the annotation statedefaultDeliver- the strategy applied if deliverConfig isnullr- the resource
-
readEntirely
public static java.lang.Object readEntirely(AtmosphereResource r) throws java.io.IOException
- Throws:
java.io.IOException
-
isBodyBinary
public static boolean isBodyBinary(AtmosphereRequest request)
-
isBodyEmpty
public static boolean isBodyEmpty(java.lang.Object o)
-
readEntirelyAsString
public static java.lang.StringBuilder readEntirelyAsString(AtmosphereResource r) throws java.io.IOException
- Throws:
java.io.IOException
-
readEntirelyAsByte
public static byte[] readEntirelyAsByte(AtmosphereResource r) throws java.io.IOException
- Throws:
java.io.IOException
-
forceReadEntirelyAsByte
public static byte[] forceReadEntirelyAsByte(AtmosphereResource r) throws java.io.IOException
Reads request body as bytes without respectApplicationConfig.READ_GET_BODYparameter- Throws:
java.io.IOException
-
guestServletPath
public static java.lang.String guestServletPath(AtmosphereConfig config)
-
guestRawServletPath
public static java.lang.String guestRawServletPath(AtmosphereConfig config)
-
getCleanedServletPath
public static java.lang.String getCleanedServletPath(java.lang.String fullServletPath)
Used to remove trailing slash and wildcard from a servlet path.
Examples :
- "/foo/" becomes "/foo"
- "foo/bar" becomes "/foo/bar"- Parameters:
fullServletPath- : Servlet mapping- Returns:
- Servlet mapping without trailing slash and wildcard
-
loadClass
public static java.lang.Class<?> loadClass(java.lang.Class<?> thisClass, java.lang.String className) throws java.lang.ExceptionLoading the specified class using some heuristics to support various containers The order of preferece is: 1. Thread.currentThread().getContextClassLoader() 2. Class.forName 3. thisClass.getClassLoader()- Parameters:
thisClass-className-- Returns:
- Throws:
java.lang.Exception
-
isAtmosphere
public static boolean isAtmosphere(java.lang.String className)
-
readServiceFile
public static java.util.Map<java.lang.String,AtmosphereFramework.MetaServiceAction> readServiceFile(java.lang.String path)
This method reads the given file stored under "META-INF/services" and accessed through the framework's class loader to specify a list of
actionsto be done on different service classes (AtmosphereInterceptor,BroadcastFilter, etc).The file content should follows the following format:
INSTALL com.mycompany.MyInterceptor com.mycompany.MyFilter EXCLUDE org.atmosphere.interceptor.HeartbeatInterceptor
If you don't specify any
AtmosphereFramework.MetaServiceActionbefore a class, then default action will beAtmosphereFramework.MetaServiceAction.INSTALL.Important note: you must specify a class declared inside a package. Since creating classes in the source root is a bad practice, the method does not deal with it to improve its performances.
- Parameters:
path- the service file to read- Returns:
- the map associating class to action
-
close
public static void close(java.io.Closeable... closeableArray)
Tries to close the given objects and log the
IOExceptionat INFO level to make the code more readable when we assume that theIOExceptionwon't be managed.Also ignore
nullparameters.- Parameters:
closeableArray- the objects to close
-
realPath
public static java.lang.String realPath(jakarta.servlet.ServletContext servletContext, java.lang.String targetPath) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
-