Class OsgiUtil


  • public class OsgiUtil
    extends java.lang.Object
    Utility methods to use in an OSGi environment.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Filter getFilter​(java.lang.Class<?> clazz, java.util.Map<java.lang.String,​java.lang.String> attributes)
      Create a Filter using the passed Class as an objectClass and the map as the filter attributes.
      static java.lang.String lookup​(BundleContext context, java.lang.String name)
      Looks a property up by name in the set of framework properties.
      static java.lang.String lookup​(ComponentContext context, java.lang.String name)
      Looks a property up by name in a component context.
      static java.lang.String lookupConfigurationThenFramework​(ComponentContext context, java.lang.String name)
      Looks a property up by name in the component context first, falling back in the framework properties if not found.
      static java.lang.String lookupConfigurationThenFramework​(ComponentContext context, java.lang.String nameInComponent, java.lang.String nameInFramework)
      Looks a property up by name in the component context first, falling back in the framework properties if not found.
      static java.lang.String lookupFrameworkThenConfiguration​(ComponentContext context, java.lang.String name)
      Looks a property up by name in the framework properties first, falling back to the component context if not not found.
      static java.lang.String lookupFrameworkThenConfiguration​(ComponentContext context, java.lang.String nameInComponent, java.lang.String nameInFramework)
      Looks a property up by name in the framework properties first, falling back to the component context if not not found.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • lookup

        public static java.lang.String lookup​(ComponentContext context,
                                              java.lang.String name)
        Looks a property up by name in a component context. Returns null if the property is not found or if the property is found but it is an empty string.
        Parameters:
        context - Component context.
        name - Name of the property.
        Returns:
        The property value serialized as a string, or null.
      • lookup

        public static java.lang.String lookup​(BundleContext context,
                                              java.lang.String name)
        Looks a property up by name in the set of framework properties. Returns null if the property is not found or if the property is found but it is an empty string.
        Parameters:
        context - Bundle context.
        name - Name of the property.
        Returns:
        The property value serialized as a string, or null.
      • lookupConfigurationThenFramework

        public static java.lang.String lookupConfigurationThenFramework​(ComponentContext context,
                                                                        java.lang.String name)
        Looks a property up by name in the component context first, falling back in the framework properties if not found. Returns null if the property is not found or if the property is found but it is an empty string.
        Parameters:
        context - Component context.
        name - Name of the property.
        Returns:
        The property value serialized as a string, or null.
      • lookupConfigurationThenFramework

        public static java.lang.String lookupConfigurationThenFramework​(ComponentContext context,
                                                                        java.lang.String nameInComponent,
                                                                        java.lang.String nameInFramework)
        Looks a property up by name in the component context first, falling back in the framework properties if not found. Returns null if the property is not found or if the property is found but it is an empty string.
        Parameters:
        context - Component context.
        nameInComponent - Name of the property in the component context.
        nameInFramework - Name of the property in the framework properties.
        Returns:
        The property value serialized as a string, or null.
      • lookupFrameworkThenConfiguration

        public static java.lang.String lookupFrameworkThenConfiguration​(ComponentContext context,
                                                                        java.lang.String name)
        Looks a property up by name in the framework properties first, falling back to the component context if not not found. Returns null if the property is not found or if the property is found but it is an empty string.
        Parameters:
        context - Component context.
        name - Name of the property.
        Returns:
        The property value serialized as a string, or null.
      • lookupFrameworkThenConfiguration

        public static java.lang.String lookupFrameworkThenConfiguration​(ComponentContext context,
                                                                        java.lang.String nameInComponent,
                                                                        java.lang.String nameInFramework)
        Looks a property up by name in the framework properties first, falling back to the component context if not not found. Returns null if the property is not found or if the property is found but it is an empty string.
        Parameters:
        context - Component context.
        nameInComponent - Name of the property in the component context.
        nameInFramework - Name of the property in the framework properties.
        Returns:
        The property value serialized as a string, or null.
      • getFilter

        public static Filter getFilter​(java.lang.Class<?> clazz,
                                       java.util.Map<java.lang.String,​java.lang.String> attributes)
        Create a Filter using the passed Class as an objectClass and the map as the filter attributes.
        Parameters:
        clazz - the target objectClass
        attributes - target attributes (null value for the absence)
        Returns:
        OSGi filter representing the input