public class Utils extends Object
| Modifier and Type | Field and Description |
|---|---|
static org.slf4j.Logger |
LOG |
| Modifier and Type | Method and Description |
|---|---|
static Boolean |
asBoolean(String propertyName,
Object value) |
static Integer |
asInteger(String propertyName,
Object value) |
static Long |
asLong(String propertyName,
Object value) |
static String |
asString(String propertyName,
Object value) |
static String[] |
asStringArray(String propertyName,
Object value)
Helper method to convert generic property value into array of Strings.
|
static String[] |
asStringArray(String propertyName,
Object value,
boolean splitStrings)
Helper method to convert generic property value into array of Strings.
|
static org.osgi.framework.Filter |
createFilter(org.osgi.framework.BundleContext bundleContext,
Class<?>... trackedClass)
Creates a
Filter based on a non-empty list of classes. |
static Boolean |
getBooleanProperty(org.osgi.framework.ServiceReference<?> serviceReference,
String key)
Get a property which can be specified as String or Boolean and return it as Boolean.
|
static String |
getFirstObjectClass(org.osgi.framework.ServiceReference<?> ref)
Returns first available
Constants.OBJECTCLASS property value from ServiceReference
or null if not available (but it should be). |
static OsgiContextModel |
getHighestRankedModel(Set<OsgiContextModel> rankedSet)
Gets first
OsgiContextModel from ranked set or null if not available. |
static Integer |
getIntegerProperty(org.osgi.framework.ServiceReference<?> serviceReference,
String key)
Returns a service property as
Integer. |
static org.osgi.framework.Bundle |
getJettyWebSocketBundle(org.osgi.framework.Bundle bundle)
Specialized method that's used to add Jetty WebSocket bundle that we know to contain required
ServletContainerInitializer services. |
static Long |
getLongProperty(org.osgi.framework.ServiceReference<?> serviceReference,
String key)
Returns a service property as
Long. |
static String |
getManifestHeader(org.osgi.framework.Bundle bundle,
String key)
Returns a named header from a bundle or from one of its attached fragments
|
static String[] |
getObjectClasses(org.osgi.framework.ServiceReference<?> ref)
Returns all
Constants.OBJECTCLASS property values from ServiceReference |
static org.osgi.framework.Bundle |
getPaxWebJspBundle(org.osgi.framework.Bundle bundle) |
static org.osgi.framework.Bundle |
getPaxWebJspBundle(org.osgi.framework.BundleContext bundleContext) |
static <T> T |
getPaxWebProperty(org.osgi.framework.ServiceReference<?> serviceReference,
String legacyName,
String whiteboardName,
BiFunction<String,Object,T> propertyProvider)
Gets a service property by checking legacy and whiteboard property names, printing relevant warnings, if needed.
|
static org.osgi.framework.Bundle |
getPaxWebUndertowWebSocketBundle(org.osgi.framework.Bundle bundle)
Specialized method that's used to add Undertow WebSocket bundle that we know to contain required
ServletContainerInitializer services |
static org.osgi.framework.Bundle |
getPaxWebWebSocketsBundle(org.osgi.framework.Bundle bundle)
Find Pax Web bundle for generic (Whiteboard and HttpService) support for WebSockets
|
static long |
getServiceId(org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> ref)
Returns
Constants.SERVICE_ID or -1 if not available |
static String |
getStringProperty(org.osgi.framework.ServiceReference<?> serviceReference,
String key)
Returns a service property as
String. |
static org.osgi.framework.Bundle |
getTomcatWebSocketBundle(org.osgi.framework.Bundle bundle)
Specialized method that's used to add Tomcat WebSocket bundle that we know to contain required
ServletContainerInitializer services |
static org.osgi.framework.Bundle |
getUndertowWebSocketBundle(org.osgi.framework.Bundle bundle)
Specialized method that's used to add Undertow WebSocket bundle that we know to contain required
ServletContainerInitializer services |
static boolean |
isBundleProtocol(URL url)
Checks whether given
URL uses protocol used by Bundle.getResource(String) (at least for Felix
and Equinox). |
static boolean |
isConfigurationAdminAvailable(Class<?> cls) |
static boolean |
isDirectory(URL location)
Checks if given location is a directory
|
static boolean |
isEventAdminAvailable(Class<?> cls)
Check if
org.osgi.service.event.EventAdmin is available |
static boolean |
isFragment(org.osgi.framework.Bundle bundle)
Checkes whether a
Bundle is a fragment bundle. |
static boolean |
isJasyptAvailable(Class<?> cls)
Check if Jasypt bundle is available
|
static String |
resolve(Map<String,String> properties,
String value,
String defaultValue) |
static String |
resolve(String value) |
static String |
resolve(String value,
String defaultValue) |
static boolean |
same(Dictionary<String,?> cfg1,
Dictionary<String,?> cfg2) |
static boolean |
same(Object v1,
Object v2) |
static Hashtable<String,Object> |
toHashtable(Dictionary<String,?> dictionary) |
static Map<String,String> |
toMap(Dictionary<?,?> dictionary)
Helper method to convert incoming
Dictionary with unspecified types to map of Strings. |
static Map<String,String> |
toMap(org.osgi.framework.ServiceReference<?> reference)
Special method to be called from R6 framwork (
ServiceReference#getProperties() was
added in R7 == org.osgi.framework;version=1.9). |
static boolean |
useSameContextPath(ElementModel<?,?> model1,
ElementModel<?,?> model2)
Returns
true if two elements models use at least one OsgiContextModel referring to the same
cotext path. |
public static boolean same(Dictionary<String,?> cfg1, Dictionary<String,?> cfg2)
public static Map<String,String> toMap(Dictionary<?,?> dictionary)
Helper method to convert incoming Dictionary with unspecified types to map of Strings.
Especially useful when translating from ConfigurationAdmin configs to maps specified at e.g.,
ServletConfig.getInitParameterNames().
dictionary - dictionary of potentially diffent types of keys and valuespublic static Hashtable<String,Object> toHashtable(Dictionary<String,?> dictionary)
public static Map<String,String> toMap(org.osgi.framework.ServiceReference<?> reference)
ServiceReference#getProperties() was
added in R7 == org.osgi.framework;version=1.9).reference - public static String resolve(Map<String,String> properties, String value, String defaultValue)
public static long getServiceId(org.osgi.framework.ServiceReference<org.ops4j.pax.web.service.WebContainer> ref)
Constants.SERVICE_ID or -1 if not availableref - public static org.osgi.framework.Filter createFilter(org.osgi.framework.BundleContext bundleContext,
Class<?>... trackedClass)
Filter based on a non-empty list of classes.bundleContext - trackedClass - public static String[] getObjectClasses(org.osgi.framework.ServiceReference<?> ref)
Constants.OBJECTCLASS property values from ServiceReferenceref - public static String getFirstObjectClass(org.osgi.framework.ServiceReference<?> ref)
Constants.OBJECTCLASS property value from ServiceReference
or null if not available (but it should be).ref - public static String getStringProperty(org.osgi.framework.ServiceReference<?> serviceReference, String key)
String.serviceReference - service reference; cannot be nullkey - property key; cannot be nullnull if property is not set or property value is not a StringIllegalArgumentException - - If service reference is null or if key is nullpublic static Integer getIntegerProperty(org.osgi.framework.ServiceReference<?> serviceReference, String key)
Integer.serviceReference - service reference; cannot be nullkey - property key; cannot be nullnull if property is not set or property value is not a IntegerIllegalArgumentException - - If service reference is null or if key is nullpublic static Long getLongProperty(org.osgi.framework.ServiceReference<?> serviceReference, String key)
Long.serviceReference - service reference; cannot be nullkey - property key; cannot be nullnull if property is not set or property value is not a LongIllegalArgumentException - - If service reference is null or if key is nullpublic static Boolean getBooleanProperty(org.osgi.framework.ServiceReference<?> serviceReference, String key)
serviceReference - key - public static String[] asStringArray(String propertyName, Object value)
Collection<String>propertyName - value - public static String[] asStringArray(String propertyName, Object value, boolean splitStrings)
asStringArray(String, Object), which may be told to treat String values as comma-separated values.propertyName - value - splitStrings - public static <T> T getPaxWebProperty(org.osgi.framework.ServiceReference<?> serviceReference,
String legacyName,
String whiteboardName,
BiFunction<String,Object,T> propertyProvider)
T - serviceReference - legacyName - whiteboardName - propertyProvider - public static OsgiContextModel getHighestRankedModel(Set<OsgiContextModel> rankedSet)
OsgiContextModel from ranked set or null if not available.rankedSet - public static boolean isBundleProtocol(URL url)
URL uses protocol used by Bundle.getResource(String) (at least for Felix
and Equinox).url - public static org.osgi.framework.Bundle getPaxWebJspBundle(org.osgi.framework.BundleContext bundleContext)
public static org.osgi.framework.Bundle getPaxWebJspBundle(org.osgi.framework.Bundle bundle)
public static org.osgi.framework.Bundle getJettyWebSocketBundle(org.osgi.framework.Bundle bundle)
ServletContainerInitializer services.
Actually Jetty has two bundles with SCIs (websocket-server and javax-websocket-server-impl), but the JSR356 one
is wired to the native onebundle - public static org.osgi.framework.Bundle getTomcatWebSocketBundle(org.osgi.framework.Bundle bundle)
ServletContainerInitializer servicesbundle - public static org.osgi.framework.Bundle getUndertowWebSocketBundle(org.osgi.framework.Bundle bundle)
ServletContainerInitializer servicesbundle - public static org.osgi.framework.Bundle getPaxWebUndertowWebSocketBundle(org.osgi.framework.Bundle bundle)
ServletContainerInitializer servicesbundle - public static org.osgi.framework.Bundle getPaxWebWebSocketsBundle(org.osgi.framework.Bundle bundle)
bundle - public static String getManifestHeader(org.osgi.framework.Bundle bundle, String key)
bundle - key - public static boolean isFragment(org.osgi.framework.Bundle bundle)
Bundle is a fragment bundle.bundle - public static boolean isDirectory(URL location)
location - public static boolean useSameContextPath(ElementModel<?,?> model1, ElementModel<?,?> model2)
true if two elements models use at least one OsgiContextModel referring to the same
cotext path.model1 - model2 - public static boolean isConfigurationAdminAvailable(Class<?> cls)
public static boolean isEventAdminAvailable(Class<?> cls)
org.osgi.service.event.EventAdmin is availabletrue if EventAdmin class can be loaded,
false otherwhisepublic static boolean isJasyptAvailable(Class<?> cls)
Copyright © 2006–2024 OPS4J - Open Participation Software for Java. All rights reserved.