當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceReference.getPropertyKeys方法代碼示例

本文整理匯總了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));
            }
        }
    }
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:14,代碼來源:LifecycleTest.java

示例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;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:23,代碼來源:OsgiServiceReferenceUtils.java

示例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();
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:35,代碼來源:OsgiStringUtils.java

示例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;
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:24,代碼來源:ManagerUtil.java


注:本文中的org.osgi.framework.ServiceReference.getPropertyKeys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。