本文整理匯總了Java中org.osgi.framework.ServiceReference.getPropertyKeys方法的典型用法代碼示例。如果您正苦於以下問題:Java ServiceReference.getPropertyKeys方法的具體用法?Java ServiceReference.getPropertyKeys怎麽用?Java ServiceReference.getPropertyKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osgi.framework.ServiceReference
的用法示例。
在下文中一共展示了ServiceReference.getPropertyKeys方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: printServiceRefs
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
private void printServiceRefs(ServiceReference[] refs) {
for (ServiceReference ref : refs) {
String[] keys = ref.getPropertyKeys();
logger.info(ref);
for (String key : keys) {
if (Constants.OBJECTCLASS.equals(key)) {
logger.info("\t" + key + " = " + Arrays.toString((String[]) ref.getProperty(key)));
} else {
logger.info("\t" + key + " = " + ref.getProperty(key));
}
}
}
}
示例2: getServicePropertiesSnapshotAsMap
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
/**
* Returns a {@link Map} containing the properties available for the given service reference. This method takes a
* snapshot of the properties; future changes to the service properties will not be reflected in the returned
* dictionary.
*
* @param reference OSGi service reference
* @return a <code>Map</code> containing the service reference properties taken as a snapshot
*/
public static Map getServicePropertiesSnapshotAsMap(ServiceReference reference) {
Assert.notNull(reference);
String[] keys = reference.getPropertyKeys();
Map map = new LinkedHashMap(keys.length);
for (int i = 0; i < keys.length; i++) {
map.put(keys[i], reference.getProperty(keys[i]));
}
// mark it as read-only
map = Collections.unmodifiableMap(map);
return map;
}
示例3: nullSafeToString
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
/**
* Returns a String representation of the given <code>ServiceReference</code>.
*
* @param reference OSGi service reference (can be <code>null</code>)
* @return String representation of the given service reference
*/
public static String nullSafeToString(ServiceReference reference) {
if (reference == null)
return NULL_STRING;
StringBuilder buf = new StringBuilder();
Bundle owningBundle = reference.getBundle();
buf.append("ServiceReference [").append(OsgiStringUtils.nullSafeSymbolicName(owningBundle)).append("] ");
String clazzes[] = (String[]) reference.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
buf.append(ObjectUtils.nullSafeToString(clazzes));
buf.append("={");
String[] keys = reference.getPropertyKeys();
for (int i = 0; i < keys.length; i++) {
if (!org.osgi.framework.Constants.OBJECTCLASS.equals(keys[i])) {
buf.append(keys[i]).append('=').append(reference.getProperty(keys[i]));
if (i < keys.length - 1) {
buf.append(',');
}
}
}
buf.append('}');
return buf.toString();
}
示例4: getProperties
import org.osgi.framework.ServiceReference; //導入方法依賴的package包/類
/**
* Returns a dictionary containing the properties of a {@code
* ServiceReference}.
*
* @param serviceReference the service reference
* @return a dictionary containing the properties of a {@code
* ServiceReference}
* @review
*/
public static <T> Dictionary<String, Object> getProperties(
ServiceReference<T> serviceReference) {
Dictionary<String, Object> properties = new Hashtable<>();
String[] propertyKeys = serviceReference.getPropertyKeys();
for (String propertyKey : propertyKeys) {
properties.put(
propertyKey, serviceReference.getProperty(propertyKey));
}
return properties;
}