本文整理匯總了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();
}