本文整理汇总了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);
}
}
示例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;
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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();
}
}
示例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();
}
}