|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrooklyn.util.ResourceUtils
public class ResourceUtils
Constructor Summary | |
ResourceUtils(java.lang.ClassLoader loader, java.lang.Object contextObject, java.lang.String contextMessage)
context string used for errors |
|
ResourceUtils(java.lang.Object contextObject, java.lang.String contextMessage)
contextObject used for classloading, contextMessage used for errors |
|
ResourceUtils(java.lang.Object context)
uses the classloader of the given object, and the phrase object's toString (preceded by the word 'for') as the context string used in errors |
Method Summary | |
---|---|
static void
|
addClassLoaderProvider(Function provider)
used to register custom mechanisms for getting classloaders given an object |
static java.lang.Thread
|
addShutdownHook(java.lang.Runnable task)
|
static void
|
copy(java.io.InputStream input, java.io.OutputStream output)
|
java.lang.String
|
getClassLoaderDir()
returns the base directory or JAR from which the context is class-loaded, if possible; throws exception if not found |
java.lang.String
|
getClassLoaderDir(java.lang.String resourceInThatDir)
|
static java.lang.ClassLoader
|
getClassLoaderForObject(java.lang.Object contextObject)
|
java.lang.ClassLoader
|
getLoader()
|
static java.lang.String
|
getProtocol(java.lang.String url)
returns the protocol (e.g. http) if one appears to be specified, or else null; 'protocol' here should consist of 2 or more _letters_ only followed by a colon (2 required to prevent c``:\xxx being treated as a url) |
java.lang.String
|
getResourceAsString(java.lang.String url)
takes getResourceFromUrl(String) and reads fully, into a string |
java.io.InputStream
|
getResourceFromUrl(java.lang.String url)
Takes a string which is treated as a URL (with some extended "schemes" also expected), or as a path to something either on the classpath (absolute only) or the local filesystem (relative or absolute, depending on leading slash) |
static java.lang.String
|
mergePaths(java.lang.String... items)
returns the items with exactly one "/" between items (whether or not the individual items start or end with /), except where character before the / is a : (url syntax) in which case it will permit multiple (will not remove any) |
static java.io.File
|
mkdirs(java.io.File dir)
|
static byte[]
|
readFullyBytes(java.io.InputStream is)
|
static java.lang.String
|
readFullyString(java.io.InputStream is)
|
static boolean
|
removeShutdownHook(java.lang.Thread hook)
|
static java.net.URL
|
tidy(java.net.URL url)
|
static java.lang.String
|
tidyFileUrl(java.lang.String url)
|
static java.io.File
|
writeToTempFile(java.io.InputStream is, java.lang.String prefix, java.lang.String suffix)
|
static java.io.File
|
writeToTempFile(java.io.InputStream is, java.io.File tempDir, java.lang.String prefix, java.lang.String suffix)
|
static java.io.File
|
writeToTempFile(java.util.Properties props, java.lang.String prefix, java.lang.String suffix)
|
static java.io.File
|
writeToTempFile(java.util.Properties props, java.io.File tempDir, java.lang.String prefix, java.lang.String suffix)
|
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Constructor Detail |
---|
public ResourceUtils(java.lang.ClassLoader loader, java.lang.Object contextObject, java.lang.String contextMessage)
public ResourceUtils(java.lang.Object contextObject, java.lang.String contextMessage)
public ResourceUtils(java.lang.Object context)
Method Detail |
---|
public static void addClassLoaderProvider(Function provider)
public static java.lang.Thread addShutdownHook(java.lang.Runnable task)
public static void copy(java.io.InputStream input, java.io.OutputStream output)
public java.lang.String getClassLoaderDir()
public java.lang.String getClassLoaderDir(java.lang.String resourceInThatDir)
public static java.lang.ClassLoader getClassLoaderForObject(java.lang.Object contextObject)
public java.lang.ClassLoader getLoader()
public static java.lang.String getProtocol(java.lang.String url)
public java.lang.String getResourceAsString(java.lang.String url)
public java.io.InputStream getResourceFromUrl(java.lang.String url)
URLs can be of the form classpath://com/acme/Foo.properties as well as file:///home/... and http://acme.com/....
Throws exception if not found, using the context parameter passed into the constructor.
TODO may want OSGi, or typed object; should consider pax url
public static java.lang.String mergePaths(java.lang.String... items)
public static java.io.File mkdirs(java.io.File dir)
public static byte[] readFullyBytes(java.io.InputStream is)
public static java.lang.String readFullyString(java.io.InputStream is)
public static boolean removeShutdownHook(java.lang.Thread hook)
public static java.net.URL tidy(java.net.URL url)
public static java.lang.String tidyFileUrl(java.lang.String url)
public static java.io.File writeToTempFile(java.io.InputStream is, java.lang.String prefix, java.lang.String suffix)
public static java.io.File writeToTempFile(java.io.InputStream is, java.io.File tempDir, java.lang.String prefix, java.lang.String suffix)
public static java.io.File writeToTempFile(java.util.Properties props, java.lang.String prefix, java.lang.String suffix)
public static java.io.File writeToTempFile(java.util.Properties props, java.io.File tempDir, java.lang.String prefix, java.lang.String suffix)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.