本文整理匯總了Java中org.osgi.service.cm.Configuration.delete方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.delete方法的具體用法?Java Configuration.delete怎麽用?Java Configuration.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osgi.service.cm.Configuration
的用法示例。
在下文中一共展示了Configuration.delete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
@Override
public Object execute() throws Exception {
if (schedulerManager.getScheduler(schedulerName) == null) {
throw new IllegalArgumentException("Scheduler with that name doesn't exists");
}
for (Configuration configuration : configurationAdmin.listConfigurations(VolatileSchedulerProvider.CONFIG_FACTORY_NAME)) {
String name = (String)configuration.getProperties().get(VolatileSchedulerProvider.PROPERTY_NAME);
if (name.equalsIgnoreCase(schedulerName)) {
configuration.delete();
return null;
}
}
throw new IllegalArgumentException("Scheduler configuration not found!");
}
示例2: refreshConfig
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
private void refreshConfig() throws IOException {
Set<Configuration> copy = new HashSet<>(ownedConfiguration);
dockerClient.refresh();
Set<DockerContainer> containers = dockerClient.getContainers();
int containerCount = 0;
for (DockerContainer dockerContainer : containers) {
for (Entry<String, DockerServiceMapping> serviceMapping : dockerContainer
.getMappings().entrySet()) {
String id = dockerContainer.getId();
String serviceId = generateServiceId(id,serviceMapping.getValue());
String servicePid = generateServicePid(serviceMapping.getValue());
if(servicePid!=null) {
Configuration newConfig = injectConfig(serviceId, servicePid,serviceMapping.getValue());
copy.remove(newConfig);
} else {
logger.info("Skipping incomplete mapping: "+serviceMapping.getValue());
}
}
containerCount++;
}
for (Configuration orphan : copy) {
orphan.delete();
ownedConfiguration.remove(orphan);
logger.info("# orphans: "+copy.size()+" containers: "+containerCount);
}
}
示例3: deleteFactoryConfigurations
import org.osgi.service.cm.Configuration; //導入方法依賴的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: handleRemovedDiscoveryNode
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
private void handleRemovedDiscoveryNode(RemovedNode event) {
DiscoveryNode node = event.getNode();
DiscoveryPath path = node.getPath();
// Only do something with config paths
if (path.isConfigPath()) {
try {
Configuration config = this.getConfig(path);
logger.debug("Removing configuration {}", config.getPid());
config.delete();
} catch (IOException e) {
logger.error("Error while removing configuration {}", path.toString(), e);
}
}
}
示例5: delete
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
public void delete ( final String pid ) throws IOException
{
final Configuration cfg = this.configAdmin.getConfiguration ( pid );
if ( cfg != null )
{
cfg.delete ();
}
}
示例6: deactivate
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
@Deactivate
public void deactivate() {
Map<String,Configuration> copy = new HashMap<>(ownedConfiguration);
for (Configuration configuration : copy.values()) {
try {
configuration.delete();
} catch (IOException e) {
logger.error("Error: ", e);
}
}
ownedConfiguration.clear();
running = false;
pool.shutdown();
}
示例7: deactivate
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
@Deactivate
public void deactivate() {
Set<Configuration> copy = new HashSet<>(ownedConfiguration);
for (Configuration configuration : copy) {
try {
configuration.delete();
} catch (IOException e) {
logger.error("Error: ", e);
}
}
ownedConfiguration.clear();
running = false;
pool.shutdown();
}
示例8: deleteConfig
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
protected void deleteConfig( final String pid )
{
final ConfigurationAdmin ca = getConfigurationAdmin();
try
{
final Configuration config = ca.getConfiguration( pid );
config.delete();
}
catch ( IOException ioe )
{
TestCase.fail( "Failed deleting configuration " + pid + ": " + ioe.toString() );
}
}
示例9: test_basic_configuration_configure_then_start
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
@Test
public void test_basic_configuration_configure_then_start() throws BundleException, IOException
{
// 1. create config with pid and locationA
// 2. update config with properties
final String pid = "test_basic_configuration_configure_then_start";
final Configuration config = configure( pid, null, true );
// 3. register ManagedService ms1 with pid from said locationA
bundle = installBundle( pid, ManagedServiceTestActivator.class );
bundle.start();
delay();
// ==> configuration supplied to the service ms1
final ManagedServiceTestActivator tester = ManagedServiceTestActivator.INSTANCE;
TestCase.assertNotNull( tester.props );
TestCase.assertEquals( pid, tester.props.get( Constants.SERVICE_PID ) );
TestCase.assertNull( tester.props.get( ConfigurationAdmin.SERVICE_FACTORYPID ) );
TestCase.assertNull( tester.props.get( ConfigurationAdmin.SERVICE_BUNDLELOCATION ) );
TestCase.assertEquals( PROP_NAME, tester.props.get( PROP_NAME ) );
TestCase.assertEquals( 1, tester.numManagedServiceUpdatedCalls );
// delete
config.delete();
delay();
// ==> update with null
TestCase.assertNull( tester.props );
TestCase.assertEquals( 2, tester.numManagedServiceUpdatedCalls );
}
示例10: test_basic_configuration_start_then_configure
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
@Test
public void test_basic_configuration_start_then_configure() throws BundleException, IOException
{
final String pid = "test_basic_configuration_start_then_configure";
// 1. register ManagedService ms1 with pid from said locationA
bundle = installBundle( pid, ManagedServiceTestActivator.class );
bundle.start();
delay();
// 1. create config with pid and locationA
// 2. update config with properties
final Configuration config = configure( pid, null, true );
delay();
// ==> configuration supplied to the service ms1
final ManagedServiceTestActivator tester = ManagedServiceTestActivator.INSTANCE;
TestCase.assertNotNull( tester.props );
TestCase.assertEquals( pid, tester.props.get( Constants.SERVICE_PID ) );
TestCase.assertNull( tester.props.get( ConfigurationAdmin.SERVICE_FACTORYPID ) );
TestCase.assertNull( tester.props.get( ConfigurationAdmin.SERVICE_BUNDLELOCATION ) );
TestCase.assertEquals( PROP_NAME, tester.props.get( PROP_NAME ) );
TestCase.assertEquals( 2, tester.numManagedServiceUpdatedCalls );
// delete
config.delete();
delay();
// ==> update with null
TestCase.assertNull( tester.props );
TestCase.assertEquals( 3, tester.numManagedServiceUpdatedCalls );
}
示例11: test_basic_configuration_factory_configure_then_start
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
@Test
public void test_basic_configuration_factory_configure_then_start() throws BundleException, IOException
{
final String factoryPid = "test_basic_configuration_factory_configure_then_start";
bundle = installBundle( factoryPid, ManagedServiceFactoryTestActivator.class );
bundle.start();
delay();
final Configuration config = createFactoryConfiguration( factoryPid, null, true );
final String pid = config.getPid();
delay();
// ==> configuration supplied to the service ms1
final ManagedServiceFactoryTestActivator tester = ManagedServiceFactoryTestActivator.INSTANCE;
Dictionary<?, ?> props = tester.configs.get( pid );
TestCase.assertNotNull( props );
TestCase.assertEquals( pid, props.get( Constants.SERVICE_PID ) );
TestCase.assertEquals( factoryPid, props.get( ConfigurationAdmin.SERVICE_FACTORYPID ) );
TestCase.assertNull( props.get( ConfigurationAdmin.SERVICE_BUNDLELOCATION ) );
TestCase.assertEquals( PROP_NAME, props.get( PROP_NAME ) );
TestCase.assertEquals( 0, tester.numManagedServiceUpdatedCalls );
TestCase.assertEquals( 1, tester.numManagedServiceFactoryUpdatedCalls );
TestCase.assertEquals( 0, tester.numManagedServiceFactoryDeleteCalls );
// delete
config.delete();
delay();
// ==> update with null
TestCase.assertNull( tester.configs.get( pid ) );
TestCase.assertEquals( 0, tester.numManagedServiceUpdatedCalls );
TestCase.assertEquals( 1, tester.numManagedServiceFactoryUpdatedCalls );
TestCase.assertEquals( 1, tester.numManagedServiceFactoryDeleteCalls );
}
示例12: test_basic_configuration_factory_start_then_configure
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
@Test
public void test_basic_configuration_factory_start_then_configure() throws BundleException, IOException
{
// 1. create config with pid and locationA
// 2. update config with properties
final String factoryPid = "test_basic_configuration_factory_start_then_configure";
final Configuration config = createFactoryConfiguration( factoryPid, null, true );
final String pid = config.getPid();
// 3. register ManagedService ms1 with pid from said locationA
bundle = installBundle( factoryPid, ManagedServiceFactoryTestActivator.class );
bundle.start();
delay();
// ==> configuration supplied to the service ms1
final ManagedServiceFactoryTestActivator tester = ManagedServiceFactoryTestActivator.INSTANCE;
Dictionary<?, ?> props = tester.configs.get( pid );
TestCase.assertNotNull( props );
TestCase.assertEquals( pid, props.get( Constants.SERVICE_PID ) );
TestCase.assertEquals( factoryPid, props.get( ConfigurationAdmin.SERVICE_FACTORYPID ) );
TestCase.assertNull( props.get( ConfigurationAdmin.SERVICE_BUNDLELOCATION ) );
TestCase.assertEquals( PROP_NAME, props.get( PROP_NAME ) );
TestCase.assertEquals( 0, tester.numManagedServiceUpdatedCalls );
TestCase.assertEquals( 1, tester.numManagedServiceFactoryUpdatedCalls );
TestCase.assertEquals( 0, tester.numManagedServiceFactoryDeleteCalls );
// delete
config.delete();
delay();
// ==> update with null
TestCase.assertNull( tester.configs.get( pid ) );
TestCase.assertEquals( 0, tester.numManagedServiceUpdatedCalls );
TestCase.assertEquals( 1, tester.numManagedServiceFactoryUpdatedCalls );
TestCase.assertEquals( 1, tester.numManagedServiceFactoryDeleteCalls );
}
示例13: releaseDataset
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
@Override
public void releaseDataset(Dataset d) {
// remove adapters
List<Configuration> configurations = adapters.remove(d);
if(configurations != null){
for(Configuration c : configurations){
try {
c.delete();
} catch (IOException e) {
}
}
}
}
示例14: removeConfiguration
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
private void removeConfiguration(String pid) throws IOException {
Configuration conf = admin().getConfiguration(pid);
conf.delete();
}
示例15: handleRemove
import org.osgi.service.cm.Configuration; //導入方法依賴的package包/類
private void handleRemove(String args, ConfigurationAdmin admin) throws IOException {
String pid = args.substring("remove".length()).trim();
Configuration conf = admin.getConfiguration(pid);
conf.delete();
}