Class Util


  • public class Util
    extends java.lang.Object
    Various useful functions utility methods for OSGi wide use.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_DELIMS  
    • Constructor Summary

      Constructors 
      Constructor Description
      Util()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.osgi.framework.Filter createFilter​(org.osgi.framework.BundleContext bundleContext, java.lang.String classname, java.lang.String managedServerName)
      Create an osgi filter for the given classname and server name.
      static java.util.List<java.net.URL> fileNamesAsURLs​(java.lang.String val, java.lang.String delims)
      Treating the string as a separated list of filenames, convert and return the list of urls.
      static java.lang.String getManifestHeaderValue​(java.lang.String name, java.lang.String altName, java.util.Dictionary<java.lang.String,​java.lang.String> manifest)
      Get the value of a manifest header.
      static java.lang.String resolvePropertyValue​(java.lang.String value)
      recursively substitute the ${sysprop} by their actual system property.
      static void setProperty​(java.util.Dictionary<java.lang.String,​java.lang.Object> properties, java.lang.String key, java.lang.Object value)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • createFilter

        public static org.osgi.framework.Filter createFilter​(org.osgi.framework.BundleContext bundleContext,
                                                             java.lang.String classname,
                                                             java.lang.String managedServerName)
                                                      throws org.osgi.framework.InvalidSyntaxException
        Create an osgi filter for the given classname and server name.
        Parameters:
        bundleContext - the BundleContext instance to use
        classname - the class to match on the filter
        managedServerName - 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 java.lang.String getManifestHeaderValue​(java.lang.String name,
                                                              java.lang.String altName,
                                                              java.util.Dictionary<java.lang.String,​java.lang.String> manifest)
        Get the value of a manifest header.
        Parameters:
        name - the name of the header
        altName - an alternative name for the header (useful for deprecated names)
        manifest - the dictionary
        Returns:
        the value from the manifest
      • fileNamesAsURLs

        public static java.util.List<java.net.URL> fileNamesAsURLs​(java.lang.String val,
                                                                   java.lang.String delims)
                                                            throws java.lang.Exception
        Treating the string as a separated list of filenames, convert and return the list of urls.
        Parameters:
        val - the separated list of filenames
        delims - the separators (default is ,;)
        Returns:
        the list of URLs found in the input list
        Throws:
        java.lang.Exception - if unable to convert entry to a URL
      • setProperty

        public static void setProperty​(java.util.Dictionary<java.lang.String,​java.lang.Object> properties,
                                       java.lang.String key,
                                       java.lang.Object value)
      • resolvePropertyValue

        public static java.lang.String resolvePropertyValue​(java.lang.String value)
        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