Class OsgiUtil


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

      • lookup

        public static String lookup​(org.osgi.service.component.ComponentContext context,
                                    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 String lookup​(org.osgi.framework.BundleContext context,
                                    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 String lookupConfigurationThenFramework​(org.osgi.service.component.ComponentContext context,
                                                              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 String lookupConfigurationThenFramework​(org.osgi.service.component.ComponentContext context,
                                                              String nameInComponent,
                                                              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 String lookupFrameworkThenConfiguration​(org.osgi.service.component.ComponentContext context,
                                                              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 String lookupFrameworkThenConfiguration​(org.osgi.service.component.ComponentContext context,
                                                              String nameInComponent,
                                                              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 org.osgi.framework.Filter getFilter​(Class<?> clazz,
                                                          Map<String,​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