Package org.opencastproject.util
Class OsgiUtil
java.lang.Object
org.opencastproject.util.OsgiUtil
Contains general purpose OSGi utility functions.
-
Method Summary
Modifier and TypeMethodDescriptionfilterByPrefix(Dictionary d, String prefix) Filter a dictionary by key prefix.static StringgetCfg(Dictionary d, String key) Get a mandatory, non-blank value from a dictionary.static intgetCfgAsInt(Dictionary d, String key) Get a mandatory integer from a dictionary.static StringgetComponentContextProperty(org.osgi.service.component.ComponentContext cc, String key) Get a mandatory, non-blank value from the component context.static StringgetComponentContextProperty(org.osgi.service.component.ComponentContext cc, String key, String defaultValue) Get a mandatory, non-blank value from the component context.static StringgetContextProperty(org.osgi.service.component.ComponentContext cc, String key) Get a mandatory, non-blank value from the bundle context.getOptCfg(Dictionary d, String key) Get a value from a dictionary.getOptCfgAsBoolean(Dictionary d, String key) Get an optional boolean from a dictionary.getOptCfgAsInt(Dictionary d, String key) Get a value from a dictionary.getOptContextProperty(org.osgi.service.component.ComponentContext cc, String key) Get an optional, non-blank value from the bundle context.static org.osgi.framework.ServiceRegistration<?> registerServlet(org.osgi.framework.BundleContext bundleContext, Object service, String alias)
-
Method Details
-
getContextProperty
Get a mandatory, non-blank value from the bundle context.- Throws:
RuntimeException- key does not exist or its value is blank
-
getOptContextProperty
public static Option<String> getOptContextProperty(org.osgi.service.component.ComponentContext cc, String key) Get an optional, non-blank value from the bundle context.- Throws:
RuntimeException- key does not exist or its value is blank
-
getComponentContextProperty
public static String getComponentContextProperty(org.osgi.service.component.ComponentContext cc, String key) Get a mandatory, non-blank value from the component context.- Throws:
RuntimeException- key does not exist or its value is blank
-
getComponentContextProperty
public static String getComponentContextProperty(org.osgi.service.component.ComponentContext cc, String key, String defaultValue) Get a mandatory, non-blank value from the component context. In case the propertie is not defined (null), the default value will be returned. -
getCfg
public static String getCfg(Dictionary d, String key) throws org.osgi.service.cm.ConfigurationException Get a mandatory, non-blank value from a dictionary.- Throws:
org.osgi.service.cm.ConfigurationException- key does not exist or its value is blank
-
getOptCfg
Get a value from a dictionary. Return none if the key does either not exist or the value is blank. -
getOptCfgAsInt
Get a value from a dictionary. Return none if the key does either not exist or the value is blank. -
filterByPrefix
Filter a dictionary by key prefix. For example the following map{w.p.key1: "value1", w.p.key2: "value2", x: "1"}filtered byfilterByPrefix(d, "w.p.")returns{key1: "value1", key2: "value"}. -
getOptCfgAsBoolean
Get an optional boolean from a dictionary. -
getCfgAsInt
public static int getCfgAsInt(Dictionary d, String key) throws org.osgi.service.cm.ConfigurationException Get a mandatory integer from a dictionary.- Throws:
org.osgi.service.cm.ConfigurationException- key does not exist or is not an integer
-
registerServlet
-