本文整理汇总了Java中org.osgi.service.cm.ConfigurationAdmin.listConfigurations方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationAdmin.listConfigurations方法的具体用法?Java ConfigurationAdmin.listConfigurations怎么用?Java ConfigurationAdmin.listConfigurations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.service.cm.ConfigurationAdmin
的用法示例。
在下文中一共展示了ConfigurationAdmin.listConfigurations方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: factory
import org.osgi.service.cm.ConfigurationAdmin; //导入方法依赖的package包/类
@Test
public void factory() throws IOException, InvalidSyntaxException {
ServiceReference<ConfigurationAdmin> reference = bundleContext
.getServiceReference(ConfigurationAdmin.class);
ConfigurationAdmin configurationAdmin = bundleContext.getService(reference);
org.osgi.service.cm.Configuration[] configurations = configurationAdmin
.listConfigurations("(service.factoryPid=test)");
assertNotNull(configurations);
Dictionary<String, Object> properties = configurations[0].getProperties();
assertNotNull(properties);
assertEquals("value3", properties.get("test3"));
bundleContext.ungetService(reference);
}
示例2: getConfiguration
import org.osgi.service.cm.ConfigurationAdmin; //导入方法依赖的package包/类
protected Configuration getConfiguration( final String pid )
{
final ConfigurationAdmin ca = getConfigurationAdmin();
try
{
final String filter = "(" + Constants.SERVICE_PID + "=" + pid + ")";
final Configuration[] configs = ca.listConfigurations( filter );
if ( configs != null && configs.length > 0 )
{
return configs[0];
}
}
catch ( InvalidSyntaxException ise )
{
// unexpected
}
catch ( IOException ioe )
{
TestCase.fail( "Failed listing configurations " + pid + ": " + ioe.toString() );
}
TestCase.fail( "No Configuration " + pid + " found" );
return null;
}
示例3: deleteFactoryConfigurations
import org.osgi.service.cm.ConfigurationAdmin; //导入方法依赖的package包/类
protected void deleteFactoryConfigurations( String factoryPid )
{
ConfigurationAdmin ca = getConfigurationAdmin();
try
{
final String filter = "(service.factoryPid=" + factoryPid + ")";
Configuration[] configs = ca.listConfigurations( filter );
if ( configs != null )
{
for ( Configuration configuration : configs )
{
configuration.delete();
}
}
}
catch ( InvalidSyntaxException ise )
{
// unexpected
}
catch ( IOException ioe )
{
TestCase.fail( "Failed deleting configurations " + factoryPid + ": " + ioe.toString() );
}
}
示例4: handleList
import org.osgi.service.cm.ConfigurationAdmin; //导入方法依赖的package包/类
private void handleList(String args, ConfigurationAdmin admin, PrintStream out) throws IOException, InvalidSyntaxException {
Configuration[] configurations = null;
if (args.equals("list")) {
configurations = admin.listConfigurations(null);
} else {
configurations = admin.listConfigurations(args.substring(
"list".length()).trim());
}
if (configurations != null) {
for (Configuration configuration : configurations) {
Dictionary properties = configuration.getProperties();
for (Enumeration e = properties.keys(); e
.hasMoreElements();) {
Object key = e.nextElement();
out.println(key + "=" + properties.get(key));
}
}
}
}
示例5: handleRemoveFactory
import org.osgi.service.cm.ConfigurationAdmin; //导入方法依赖的package包/类
private void handleRemoveFactory(String args, ConfigurationAdmin admin) throws IOException, InvalidSyntaxException {
Configuration[] configurations = admin
.listConfigurations("(service.pid=" +
args.substring("remove-factory".length()).trim() + ")");
configurations[0].delete();
}