Package org.eclipse.jetty.osgi.util
Class Util
java.lang.Object
org.eclipse.jetty.osgi.util.Util
Various useful functions utility methods for OSGi wide use.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.osgi.framework.Filter
createFilter
(org.osgi.framework.BundleContext bundleContext, String classname, String managedServerName) Create an osgi filter for the given classname and server name.fileNamesAsURLs
(String val, String delims) Treating the string as a separated list of filenames, convert and return the list of urls.static URL
getLocalizedEntry
(String file, org.osgi.framework.Bundle bundle) static URL
getLocalURL
(URL url) static String
getManifestHeaderValue
(String name, String altName, Dictionary<String, String> manifest) Get the value of a manifest header.static String
getManifestHeaderValue
(String name, Dictionary<String, String> manifest) Get the value of a manifest header.getPathsToBundlesBySymbolicNames
(String bundleSymbolicNames, org.osgi.framework.BundleContext bundleContext) Resolve the file system paths to bundles identified by their symbolic names.static URI
resolvePathAsLocalizedURI
(String path, org.osgi.framework.Bundle bundle, Path jettyHome) Resolve a path either absolutely or against the bundle install location, or against jetty home.static String
resolvePropertyValue
(String value) recursively substitute the${sysprop}
by their actual system property.static void
setProperty
(Dictionary<String, Object> properties, String key, Object value)
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
resolvePathAsLocalizedURI
public static URI resolvePathAsLocalizedURI(String path, org.osgi.framework.Bundle bundle, Path jettyHome) throws Exception Resolve a path either absolutely or against the bundle install location, or against jetty home.- Parameters:
path
- the path to resolvebundle
- the bundlejettyHome
- the path to jetty home- Returns:
- the URI resolved either absolutely or against the bundle install location or jetty home.
- Throws:
Exception
-
getLocalURL
- Throws:
Exception
-
getLocalizedEntry
- Throws:
Exception
-
getPathsToBundlesBySymbolicNames
public static List<Path> getPathsToBundlesBySymbolicNames(String bundleSymbolicNames, org.osgi.framework.BundleContext bundleContext) throws Exception Resolve the file system paths to bundles identified by their symbolic names.- Parameters:
bundleSymbolicNames
- comma separated list of symbolic bundle namesbundleContext
- the bundle on whose behalf to resolve- Returns:
- List of resolved Paths matching the bundle symbolic names
- Throws:
Exception
-
createFilter
public static org.osgi.framework.Filter createFilter(org.osgi.framework.BundleContext bundleContext, String classname, String managedServerName) throws org.osgi.framework.InvalidSyntaxException Create an osgi filter for the given classname and server name.- Parameters:
bundleContext
- theBundleContext
instance to useclassname
- the class to match on the filtermanagedServerName
- the name of the jetty server instance- Returns:
- a new filter
- Throws:
org.osgi.framework.InvalidSyntaxException
- If the filter contains an invalid string that cannot be parsed.
-
getManifestHeaderValue
public static String getManifestHeaderValue(String name, String altName, Dictionary<String, String> manifest) Get the value of a manifest header.- Parameters:
name
- the name of the headeraltName
- an alternative name for the header (useful for deprecated names)manifest
- the dictionary- Returns:
- the value from the manifest
-
getManifestHeaderValue
Get the value of a manifest header.- Parameters:
name
- the name of the headermanifest
- the dictionary- Returns:
- the value from the manifest
-
fileNamesAsURLs
Treating the string as a separated list of filenames, convert and return the list of urls.- Parameters:
val
- the separated list of filenamesdelims
- the separators (default is,;
)- Returns:
- the list of URLs found in the input list
- Throws:
Exception
- if unable to convert entry to a URL
-
setProperty
-
resolvePropertyValue
recursively substitute the${sysprop}
by their actual system property.${sysprop,defaultvalue}
will use'defaultvalue'
as the value if no sysprop is defined. Not the most efficient code but we are shooting for simplicity and speed of development here.- Parameters:
value
- the input string- Returns:
- the string with replaced properties
-