当前位置: 首页>>代码示例>>Java>>正文


Java MapEntry.getKey方法代码示例

本文整理汇总了Java中org.osgi.service.blueprint.reflect.MapEntry.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java MapEntry.getKey方法的具体用法?Java MapEntry.getKey怎么用?Java MapEntry.getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.osgi.service.blueprint.reflect.MapEntry的用法示例。


在下文中一共展示了MapEntry.getKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testParseServer

import org.osgi.service.blueprint.reflect.MapEntry; //导入方法依赖的package包/类
@Test
public void testParseServer() throws Exception {
    Element root = parseRootElement();
    NodeList nodes = root.getElementsByTagNameNS(NAMESPACE_URI, "server");
    Element element = (Element) nodes.item(0);

    Metadata parsed = handler.parse(element, parserContext);

    assertTrue(parsed instanceof ServiceMetadata);
    ServiceMetadata serviceMetadata = (ServiceMetadata) parsed;
    assertEquals(1, serviceMetadata.getServiceProperties().size());

    final MapEntry entry = serviceMetadata.getServiceProperties().get(0);
    final ValueMetadata key = (ValueMetadata) entry.getKey();
    assertEquals("microbule.server", key.getStringValue());
    assertEquals(String.class.getName(), key.getType());

    final ValueMetadata value = (ValueMetadata) entry.getValue();
    assertEquals("true", value.getStringValue());
    assertEquals(String.class.getName(), value.getType());

    assertEquals(Lists.newArrayList(HelloService.class.getName()), serviceMetadata.getInterfaces());
    final Target target = serviceMetadata.getServiceComponent();
    assertTrue(target instanceof RefMetadata);
    RefMetadata targetRef = (RefMetadata) target;
    assertEquals("helloService", targetRef.getComponentId());
}
 
开发者ID:Microbule,项目名称:microbule,代码行数:28,代码来源:MicrobuleNamespaceHandlerTest.java

示例2: doExecute

import org.osgi.service.blueprint.reflect.MapEntry; //导入方法依赖的package包/类
@Override
 protected Object doExecute() throws Exception {
 	final Collection<ServiceReference<BlueprintContainer>> services = this.bundleContext.getServiceReferences(BlueprintContainer.class, null);
 	for (final ServiceReference<BlueprintContainer> sr : services) {

 		final List<String> commands = new ArrayList<String>();
 		
 		final BlueprintContainer container = this.bundleContext.getService(sr);
final Collection<ServiceMetadata> metadata = container.getMetadata(ServiceMetadata.class);
 		for (final ServiceMetadata data : metadata) {
 			String scope = null;
 			String function = null;

 			// Implements OSGi API
 			@SuppressWarnings("unchecked")
	final List properties = data.getServiceProperties();
 			for (final Object o : properties) {
 				final MapEntry entry = (MapEntry)o;
 				String key, value;
 				if (entry.getKey() instanceof ValueMetadata) {
 					final ValueMetadata vmKey = (ValueMetadata)entry.getKey();
 					key = vmKey.getStringValue();
 				} else {
 					key = entry.getKey().toString();
 				}
 				if (entry.getValue() instanceof ValueMetadata) {
 					final ValueMetadata vmValue = (ValueMetadata)entry.getValue();
 					value = vmValue.getStringValue();
 				} else {
 					value = entry.getValue().toString();
 				}
 				if (key.equals("osgi.command.scope")) {
 					scope = value;
 				} else if (key.equals("osgi.command.function")) {
 					function = value;
 				}
 			}
 			if (scope != null && function != null) {
 				commands.add(scope + ":" + function);
 			}
 		}
 		
 		if (commands.size() > 0) {
  		System.out.println(sr.getBundle());
  		
 			for (final String command : commands) {
 				System.out.println("    " + command);
 			}
  		
  		System.out.println();
 		}
 	}

 	return null;
 }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:56,代码来源:CommandProviderShellCommand.java


注:本文中的org.osgi.service.blueprint.reflect.MapEntry.getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。