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


Java ConfigurationEvent.getType方法代码示例

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


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

示例1: configurationEvent

import org.osgi.service.cm.ConfigurationEvent; //导入方法依赖的package包/类
@Override
public void configurationEvent(final ConfigurationEvent event) {
    final int type = event.getType();
    final String pid = event.getPid();
    if (type == CM_UPDATED) {
        final Map<String, Boolean> configuredFeatures = getConfiguredFeatures(pid, configurationAdmin);
        for (final Entry<String, Boolean> entry : configuredFeatures.entrySet()) {
            final String featureID = entry.getKey();
            final boolean isEnabled = entry.getValue();
            final Collection<Feature> features = allFeatures.get(pid);
            //@formatter:off
            features.stream()
                    .filter(f -> f.id.equalsIgnoreCase(featureID))
                    .peek(f -> logger.log(LOG_INFO, String.format("Updated feature [%s] to [%b]", f.toString(), isEnabled)))
                    .forEach(f -> f.isEnabled = isEnabled);
            //@formatter:on
        }
    } else {
        allFeatures.removeAll(pid);
    }
}
 
开发者ID:amitjoy,项目名称:feature-flags-for-osgi,代码行数:22,代码来源:FeatureManagerProvider.java

示例2: configurationEvent

import org.osgi.service.cm.ConfigurationEvent; //导入方法依赖的package包/类
@Override
public void configurationEvent(ConfigurationEvent event) {
    if (StringUtils.equals(OSGI_MGR_PID, event.getPid())) {
        switch (event.getType()) {
            case CM_DELETED:
                OSGiConsolePasswordVault.INSTANCE.setPassword(null);
                break;
            case CM_UPDATED:
                this.handleOSGiManagerPwd(event.getPid());
                break;
            default:
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Ignoring the ConfigurationEvent type: [{}]", event.getType());
                }
                break;
        }
    }
}
 
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:19,代码来源:OSGiManagerConfigListener.java

示例3: configurationEvent

import org.osgi.service.cm.ConfigurationEvent; //导入方法依赖的package包/类
/**
 * @{inheritDoc
 * 
 *              Whenever a {@link Configuration} is updated all items for
 *              the given <code>pid</code> are queried and updated. Since
 *              the {@link ConfigurationEvent} contains no information which
 *              key changed we have to post updates for all configured
 *              items.
 */
@Override
public void configurationEvent(ConfigurationEvent event) {
	// we do only care for updates of existing configs!
	if (ConfigurationEvent.CM_UPDATED == event.getType()) {
		try {
			Configuration config = configAdmin.getConfiguration(event.getPid());
			for (ConfigAdminBindingProvider provider : this.providers) {
				for (ConfigAdminBindingConfig bindingConfig : provider.getBindingConfigByPid(event.getPid())) {
					postUpdate(config, bindingConfig);
				}
			}
		} catch (IOException ioe) {
			logger.warn("Fetching configuration for pid '" + event.getPid() + "' failed", ioe);
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:26,代码来源:ConfigAdminBinding.java

示例4: configurationEvent

import org.osgi.service.cm.ConfigurationEvent; //导入方法依赖的package包/类
@Override
public void configurationEvent(ConfigurationEvent event) {
	try {
		ConfigurationEventProperties cep = new ConfigurationEventProperties();
		cep.factoryPid = event.getFactoryPid();
		cep.pid = event.getPid();
		if (ConfigurationEvent.CM_DELETED != event.getType()) {
			Configuration configuration = cm.getConfiguration(event
					.getPid());
			cep.location = configuration.getBundleLocation();
			Dictionary<String, Object> properties = configuration
					.getProperties();
			if (properties == null) {
				cep.properties = new HashMap<>();
			} else
				cep.properties = toMap(properties);
		}
		ea.postEvent(new Event(TOPIC, dtos.asMap(cep)));
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:osgi,项目名称:osgi.enroute.examples,代码行数:23,代码来源:CmApplication.java

示例5: configurationEvent

import org.osgi.service.cm.ConfigurationEvent; //导入方法依赖的package包/类
/**
 * @{inheritDoc
 *
 *              Whenever a {@link Configuration} is updated all items for
 *              the given <code>pid</code> are queried and updated. Since
 *              the {@link ConfigurationEvent} contains no information which
 *              key changed we have to post updates for all configured
 *              items.
 */
@Override
public void configurationEvent(ConfigurationEvent event) {
    // we do only care for updates of existing configs!
    if (ConfigurationEvent.CM_UPDATED == event.getType()) {
        try {
            Configuration config = configAdmin.getConfiguration(event.getPid());
            for (ConfigAdminBindingProvider provider : this.providers) {
                for (ConfigAdminBindingConfig bindingConfig : provider.getBindingConfigByPid(event.getPid())) {
                    postUpdate(config, bindingConfig);
                }
            }
        } catch (IOException ioe) {
            logger.warn("Fetching configuration for pid '" + event.getPid() + "' failed", ioe);
        }
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:26,代码来源:ConfigAdminBinding.java

示例6: configurationEvent

import org.osgi.service.cm.ConfigurationEvent; //导入方法依赖的package包/类
@Override
// [TODO] #47 Revisit configurationEvent on JmxAttributeProvider
// This is an asynchronous callback. How is data integrity preserved?
// Should this depend the the lifecycle of dependent components?
public void configurationEvent(ConfigurationEvent event) {
    String pid = event.getPid();
    if (pid.equals(MANAGEMENT_PID) && event.getType() == ConfigurationEvent.CM_UPDATED) {
        processConfiguration();
    }
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:11,代码来源:KarafJmxAttributeProvider.java

示例7: configurationEvent

import org.osgi.service.cm.ConfigurationEvent; //导入方法依赖的package包/类
public void configurationEvent(ConfigurationEvent event) {
    String pid = event.getPid();
    ResourceEvent resourceEvent;
    ConfigurationResource configurationResource;
    try {
        Configuration configuration = m_configAdmin.getConfiguration(pid);
        if (!m_configurationResourceMap.containsKey(pid)) {
            configurationResource = new ConfigurationResource(configuration);
            synchronized (m_lock ) {
                m_configurationResourceMap.put(pid, configurationResource);
            }
            resourceEvent = ResourceEvent.CREATED;
        } else {
            synchronized (m_lock ) {
                configurationResource = m_configurationResourceMap.get(pid);
            }
            if (event.getType() != ConfigurationEvent.CM_DELETED) {
                resourceEvent = ResourceEvent.UPDATED;
            } else {
                resourceEvent = ResourceEvent.DELETED;
                synchronized (m_lock ) {
                   m_configurationResourceMap.remove(pid);
                }
            }
        }
        Everest.postResource(resourceEvent, configurationResource);
    } catch (IOException e) {
        // something gone wrong
        //TODO
        e.printStackTrace();
    }

}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:34,代码来源:ConfigAdminResourceManager.java


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