Class Util
java.lang.Object
org.eclipse.jetty.osgi.util.Util
Utility methods.
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic org.osgi.framework.FiltercreateFilter(org.osgi.framework.BundleContext bundleContext, String classname, String managedServerName) Create an osgi filter for the given classname and server name.static voidderegisterAsOSGiService(ContextHandler contextHandler) fileNamesAsURLs(String val, String delims) Treating the string as a separated list of filenames, convert and return the list of urls.static PathgetBundlePath(org.osgi.framework.Bundle bundle) Get the install location of a Bundle as a Pathstatic StringgetContextPath(org.osgi.framework.Bundle bundle) Get or create a contextPath from bundle headers and informationstatic org.osgi.framework.Bundle[]getFragmentsAndRequiredBundles(org.osgi.framework.BundleContext bootBundleContext, org.osgi.framework.Bundle targetBundle) Returns the fragments and the required-bundles of a bundle.static URLgetLocalizedEntry(String file, org.osgi.framework.Bundle bundle) static URLgetLocalURL(URL url) static StringgetManifestHeaderValue(String name, String altName, Dictionary<String, String> manifest) Get the value of a manifest header.static StringgetManifestHeaderValue(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 ResourcenewBundleResource(org.osgi.framework.Bundle bundle, ResourceFactory resourceFactory) Convert a bundle installed location into a Resource, taking account of any locations that are actually packed jars, but without a ".jar" extension, eg as found on equinox.static voidregisterAsOSGiService(ContextHandler contextHandler) Register the Jetty deployed context/webapp as a service, as according to the OSGi Web Application Specification.static URIresolvePathAsLocalizedURI(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 StringresolvePropertyValue(String value) recursively substitute the${sysprop}by their actual system property.static voidsetProperty(Dictionary<String, Object> properties, String key, Object value)  
- 
Constructor Details
- 
Util
public Util() 
 - 
 - 
Method Details
- 
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- theBundleContextinstance 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.
 - 
deregisterAsOSGiService
 - 
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
 - 
getBundlePath
 - 
newBundleResource
public static Resource newBundleResource(org.osgi.framework.Bundle bundle, ResourceFactory resourceFactory) throws Exception Convert a bundle installed location into a Resource, taking account of any locations that are actually packed jars, but without a ".jar" extension, eg as found on equinox. Eg file:///a/b/c/org.eclipse.osgi/89/0/bundleFile- Parameters:
 bundle- the Bundle to convertresourceFactory- the ResourceFactory to create the new Resource in- Returns:
 - a new Resource representing the bundle's installed location
 - Throws:
 Exception
 - 
getContextPath
Get or create a contextPath from bundle headers and information- Parameters:
 bundle- the bundle- Returns:
 - a contextPath
 
 - 
getLocalURL
 - 
getLocalizedEntry
 - 
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
 
 - 
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
 - 
registerAsOSGiService
Register the Jetty deployed context/webapp as a service, as according to the OSGi Web Application Specification. - 
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
 - 
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
 
 - 
setProperty
 - 
getFragmentsAndRequiredBundles
public static org.osgi.framework.Bundle[] getFragmentsAndRequiredBundles(org.osgi.framework.BundleContext bootBundleContext, org.osgi.framework.Bundle targetBundle) Returns the fragments and the required-bundles of a bundle. Recursively collect the required-bundles and fragment when the directive visibility:=reexport is added to a required-bundle.- Parameters:
 bootBundleContext- BundleContext associated with the jetty boot bundletargetBundle- the bundle whose fragments and required bundles should be collected- Returns:
 - the flattened tree of all fragments and required bundles associated with the target bundle
 
 
 -