|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlivespace.osgi.bootstrap.BootstrapUtils
public final class BootstrapUtils
This class is mainly copies of methods from DFC and livespace.osgi that the bootstrap system can't use directly due to it, well, needing to bootstrap this stuff in the first place.
Method Summary | |
---|---|
static void |
cache(URL sourceUrl,
File targetFile)
Cache a file from a source URL to a local file. |
static File |
cacheBundle(URL remoteBundleUrl)
Caches a remote bundle and returns a reference to the cached bundle. |
static void |
copy(String sourceUrl,
File targetFile)
|
static void |
diagnostic(String message)
|
static void |
error(String message)
|
static void |
error(String message,
Throwable ex)
|
static String |
expandSymbols(String str,
Map<String,String> symbols)
Copied from StringUtility.expandSymbols(String, Map) . |
static String |
expandSymbols(String str,
Map<String,String> symbols,
String symbolPrefixes,
boolean useDelimeters)
Copied from StringUtility.expandSymbols(String, Map, String, boolean) . |
static URL |
getBundleURL(String bundleName)
Gets the full URL to the bundle in the bundle repository. |
static String |
getShortHostName()
Orginally from OsgiUtil.getShortHostName() . |
static int |
indexOfChar(String str,
String chars)
Copied from StringUtility.indexOfChar(String, String) . |
static int |
indexOfChar(String str,
String chars,
int start)
Copied from StringUtility.indexOfChar(String, String, int) . |
static void |
info(String message)
|
static org.osgi.framework.Bundle |
installBundle(org.osgi.framework.BundleContext bundleContext,
String bundleName,
int bundleStartlevel)
Install a bundle from the bundle repository. |
static boolean |
isRemoteUrl(String url)
|
static org.osgi.framework.Bundle |
istartBundle(org.osgi.framework.BundleContext bundleContext,
String bundleName,
int bundleStartlevel)
Installs and starts a bundle from the bundle repository. |
static String |
join(Object[] objects)
Copy of StringUtility.join(Object[], String) . |
static Properties |
loadProperties(String url)
|
static Properties |
loadProperties(URL url)
|
static Properties |
loadProperties(URL url,
Properties properties)
|
static InputStream |
openUrl(URL url)
Copied from OsgiUtil.openUrl(URL) . |
static String |
readScriptLine(Reader input)
Copied from Files.readScriptLine(Reader) . |
static String |
requiredProperty(Properties properties,
String property)
|
static String |
requiredProperty(String property)
|
static URL |
toUrl(String path)
|
static String |
urlPrefix(String path)
|
static void |
warn(String message)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String expandSymbols(String str, Map<String,String> symbols)
StringUtility.expandSymbols(String, Map)
.
Expand symbolic variables embedded within a string. Each
occurrence of a variable such as ${var} (alternatively can use
str
- The string to expand.symbols
- The symbol definitions.
public static String expandSymbols(String str, Map<String,String> symbols, String symbolPrefixes, boolean useDelimeters)
StringUtility.expandSymbols(String, Map, String, boolean)
.
Expand symbolic variables embedded within a string. Each
occurrence of a variable such as ${var} in the string will be
expanded to the result of symbols.get ("var")
or ""
if var is not defined in the property set.
str
- The string to expand.symbols
- The symbol definitions.symbolPrefixes
- The set of character prefixes that
variables may begin with (eg "$%").useDelimeters
- True if {}'s are allowed as symbol name
delimeters, allowing multi-character names. When true,
single character symbols may still be specified without
{}'s.
public static int indexOfChar(String str, String chars)
StringUtility.indexOfChar(String, String)
.
Return the first character index in a string that is one of a specified
set of characters.
str
- The string to search.chars
- The set of characters to match.
indexOfChar(String, String, int)
public static int indexOfChar(String str, String chars, int start)
StringUtility.indexOfChar(String, String, int)
.
Return the first character index in a string that is one of a specified
set of characters.
str
- The string to search.chars
- The set of characters to match.start
- The starting index to search from.
public static String readScriptLine(Reader input) throws IOException
Files.readScriptLine(Reader)
.
Read the next line from a "script-like stream", where script-like
streams are line-oriented text streams with "#" comments and \ as
a line-continuation operator, similar to Bourne shell scripts and
Java .property files. White space at the start and end of the
line is ignored, as are lines starting with "#".
input
- The input stream.
IOException
- if an error occurs reading the stream.public static void info(String message)
public static void diagnostic(String message)
public static void error(String message)
public static void error(String message, Throwable ex)
public static void warn(String message)
public static Properties loadProperties(String url) throws IOException
IOException
public static Properties loadProperties(URL url) throws IOException
IOException
public static Properties loadProperties(URL url, Properties properties) throws IOException
IOException
public static void copy(String sourceUrl, File targetFile) throws IOException
IOException
public static String requiredProperty(String property)
public static String requiredProperty(Properties properties, String property) throws InvalidPropertyException
InvalidPropertyException
public static URL toUrl(String path)
public static boolean isRemoteUrl(String url)
public static String urlPrefix(String path)
public static InputStream openUrl(URL url) throws IOException
OsgiUtil.openUrl(URL)
.
Open an input stream on a URL. Adds some logic to generate a
FileNotFoundException for HTTP 404's.
IOException
public static String getShortHostName() throws IOException, UnknownHostException
OsgiUtil.getShortHostName()
. This version always
returns the host name minus the domain, since it's always used in a local
context to reolve which config files apply to the host.
IOException
UnknownHostException
public static String join(Object[] objects)
StringUtility.join(Object[], String)
.
public static org.osgi.framework.Bundle installBundle(org.osgi.framework.BundleContext bundleContext, String bundleName, int bundleStartlevel) throws FileNotFoundException, IOException, org.osgi.framework.BundleException
bundleContext
- A valid bundle context.bundleName
- The bundle name (this should include the
version number if the bundle is not the default
version)bundleStartlevel
- The startlevel of the bundle.
FileNotFoundException
- If the bundle is not found in the
bundle repository.
IOException
org.osgi.framework.BundleException
- If there is an error installing the
bundle.public static org.osgi.framework.Bundle istartBundle(org.osgi.framework.BundleContext bundleContext, String bundleName, int bundleStartlevel) throws FileNotFoundException, IOException, org.osgi.framework.BundleException
bundleContext
- A valid bundle context.bundleName
- The bundle name (this should include the
version number if the bundle is not the default
version)bundleStartlevel
- The startlevel of the bundle.
FileNotFoundException
- If the bundle is not found in the
bundle repository.
IOException
org.osgi.framework.BundleException
- If there is an error installing the
bundle.public static URL getBundleURL(String bundleName)
bundleName
- The name of the bundle, including the version
number if it is not the default version.
public static File cacheBundle(URL remoteBundleUrl) throws IOException
This will check if a matching bundle already exists in the cache and if so will download an updated version of the bundle if the remote bundle has been changed. If the cached bundle is the same as the remote bundle then the remote bundle will not be downloaded and the cached copy will be used.
remoteBundleUrl
- the URL of the remote bundle
IOException
- if a problem occurs copying the remote bundlepublic static void cache(URL sourceUrl, File targetFile) throws IOException
sourceUrl
- An HTTP URL pointing to the source file.targetFile
- The file to copy to.
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |