本文整理了Java中org.osgi.service.cm.Configuration.setBundleLocation()
方法的一些代码示例,展示了Configuration.setBundleLocation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.setBundleLocation()
方法的具体详情如下:
包路径:org.osgi.service.cm.Configuration
类名称:Configuration
方法名:setBundleLocation
[英]Bind this Configuration object to the specified location. If the location parameter is null then the Configurationobject will not be bound to a location/region. It will be set to the bundle's location before the first time a Managed Service/Managed Service Factory receives this Configuration object via the updated method and before any plugins are called. The bundle location or region will be set persistently.
If the location starts with ? then all targets registered with the given PID must be updated.
If the location is changed then existing targets must be informed. If they can no longer see this configuration, the configuration must be deleted or updated with null. If this configuration becomes visible then they must be updated with this configuration.
Also notifies all Configuration Listeners with a ConfigurationEvent#CM_LOCATION_CHANGED event.
[中]将此配置对象绑定到指定位置。如果位置参数为null,则Configurationobject将不会绑定到位置/区域。在托管服务/托管服务工厂第一次通过更新的方法接收此配置对象之前,以及在调用任何插件之前,它将被设置为捆绑包的位置。捆绑包位置或区域将持续设置。
如果位置以开始?然后,必须更新使用给定PID注册的所有目标。
如果位置发生变化,则必须通知现有目标。如果他们无法再看到此配置,则必须删除该配置或使用null更新该配置。如果此配置可见,则必须使用此配置更新它们。
还使用ConfigurationEvent#CM#U LOCATION_CHANGED事件通知所有配置侦听器。
代码示例来源:origin: apache/felix
/**
* @see org.osgi.service.cm.Configuration#setBundleLocation(java.lang.String)
*/
public void setBundleLocation(String bundleLocation) {
configuration.setBundleLocation(bundleLocation);
}
代码示例来源:origin: openhab/openhab-core
private void setPackage(String parameter) {
try {
Configuration cfg = configurationAdmin.getConfiguration(OpenHAB.ADDONS_SERVICE_PID, null);
Dictionary<String, Object> props = cfg.getProperties();
if (props == null) {
props = new Hashtable<>();
}
props.put(OpenHAB.CFG_PACKAGE, parameter);
cfg.setBundleLocation(null);
cfg.update(props);
} catch (IOException e) {
logger.error("Error while accessing the configuration admin: {}", e.getMessage());
}
}
代码示例来源:origin: org.fusesource.fabric/fabric-jaas
/**
* Enables the Zookeeper Realm
*/
public void updateRealm(String pid, String realmProperty, String realm) {
try {
Configuration config = configAdmin.getConfiguration(pid);
Dictionary props = config.getProperties();
if (!realm.equals(props.get(realmProperty))) {
LOGGER.debug("Changing pid {} to {} realm.",pid, realm);
props.put(realmProperty, realm);
config.setBundleLocation(null);
config.update(props);
}
} catch (Exception e) {
LOGGER.error("Error enabling zookeeper realm for " + realmProperty,e);
}
}
代码示例来源:origin: openhab/openhab-core
try {
Configuration paxCfg = configurationAdmin.getConfiguration(PAX_URL_PID, null);
paxCfg.setBundleLocation("?");
Dictionary<String, Object> properties = paxCfg.getProperties();
if (properties == null) {
代码示例来源:origin: org.ow2.chameleon/chameleon-core
private void readAndApplyConfiguration(File file, ConfigurationAdmin admin) throws Exception {
synchronized (this) {
if (admin == null) {
LOGGER.warn("Cannot apply configuration " + file.getName() + " - no configuration admin");
configurations.put(file, UnmanagedConfiguration.INSTANCE);
} else {
Properties properties = read(file);
String[] pid = parsePid(file.getName());
Dictionary<Object, Object> ht = new Properties();
for (String k : properties.stringPropertyNames()) {
ht.put(k, properties.getProperty(k));
}
Configuration config = configurations.get(file);
if (config == null || config == UnmanagedConfiguration.INSTANCE) {
config = getConfiguration(pid[0], pid[1], admin);
if (config.getBundleLocation() != null) {
config.setBundleLocation(null);
}
}
LOGGER.info("Updating configuration {} in the configuration admin, configuration: {}",
config.getPid(), configurations);
config.update(ht);
configurations.put(file, config);
}
}
}
代码示例来源:origin: apache/jackrabbit-oak
current.put(MARKER_NAME, pidString);
if (config.getBundleLocation() != null) {
config.setBundleLocation(null);
代码示例来源:origin: com.github.livesense/org.liveSense.misc.configurationLoader
config.setBundleLocation(null);
代码示例来源:origin: org.apache.felix/org.apache.felix.webconsole
config.setBundleLocation( UNBOUND_LOCATION );
代码示例来源:origin: org.apache.servicemix.kernel/org.apache.servicemix.kernel.filemonitor
protected void updateConfiguration(File file) throws IOException, InvalidSyntaxException {
ConfigurationAdmin configurationAdmin = activator.getConfigurationAdmin();
if (configurationAdmin == null) {
if (!loggedConfigAdminWarning) {
LOGGER.warn("No ConfigurationAdmin so cannot deploy configurations");
loggedConfigAdminWarning = true;
}
} else {
Properties properties = new Properties();
InputStream in = new FileInputStream(file);
try {
properties.load(in);
interpolation(properties);
closeQuietly(in);
String[] pid = parsePid(file);
Hashtable<Object, Object> hashtable = new Hashtable<Object, Object>();
hashtable.putAll(properties);
if (pid[1] != null) {
hashtable.put(ALIAS_KEY, pid[1]);
}
Configuration config = getConfiguration(pid[0], pid[1]);
if (config.getBundleLocation() != null) {
config.setBundleLocation(null);
}
config.update(hashtable);
} finally {
closeQuietly(in);
}
}
}
代码示例来源:origin: jboss-fuse/fabric8
private Configuration getConfiguration(ConfigurationAdmin configAdmin, String zooKeeperPid, String pid, String factoryPid) throws Exception {
String filter = "(" + FABRIC_ZOOKEEPER_PID + "=" + zooKeeperPid + ")";
Configuration[] oldConfiguration = configAdmin.listConfigurations(filter);
if (oldConfiguration != null && oldConfiguration.length > 0) {
return oldConfiguration[0];
} else {
Configuration newConfiguration;
if (factoryPid != null) {
newConfiguration = configAdmin.createFactoryConfiguration(pid, null);
} else {
newConfiguration = configAdmin.getConfiguration(pid, null);
// 104.4.2 Dynamic Binding:
// A null location parameter can be used to create Configuration objects that are not yet bound.
// In this case, the Configuration becomes bound to a specific location the first time that it is
// compared to a Bundle’s location.
//
// It is recommended that management agents explicitly set the location to a ? (a multi-location)
// to allow multiple bundles to share PIDs and not use the dynamic binding facility.
newConfiguration.setBundleLocation("?");
}
return newConfiguration;
}
}
代码示例来源:origin: io.fabric8/fabric8-karaf-cm
private Configuration getConfiguration(ConfigurationAdmin configAdmin, String fabric8pid, String pid, String factoryPid) throws Exception {
String filter = "(" + FABRIC8_PID + "=" + fabric8pid + ")";
Configuration[] oldConfiguration = configAdmin.listConfigurations(filter);
if (oldConfiguration != null && oldConfiguration.length > 0) {
return oldConfiguration[0];
} else {
Configuration newConfiguration;
if (factoryPid != null) {
newConfiguration = configAdmin.createFactoryConfiguration(pid, null);
} else {
newConfiguration = configAdmin.getConfiguration(pid, null);
// 104.4.2 Dynamic Binding:
// A null location parameter can be used to create Configuration objects that are not yet bound.
// In this case, the Configuration becomes bound to a specific location the first time that it is
// compared to a Bundle’s location.
//
// It is recommended that management agents explicitly set the location to a ? (a multi-location)
// to allow multiple bundles to share PIDs and not use the dynamic binding facility.
newConfiguration.setBundleLocation("?");
}
return newConfiguration;
}
}
代码示例来源:origin: apache/felix
config.setBundleLocation( UNBOUND_LOCATION );
代码示例来源:origin: apache/felix
private Configuration getConfiguration(final ConfigurationAdmin admin, final String pid,
final Bundle bundle) {
if (admin == null) {
return null;
}
try {
// Even if it is possible, we don't build the filter with bundle.location to detect the case where the
// configuration exists but can't be managed by iPOJO.
final Configuration cfg = admin.getConfiguration(pid);
final String bundleLocation = bundle.getLocation();
if (cfg.getBundleLocation() == null || bundleLocation.equals(cfg.getBundleLocation())
|| m_context.getBundle().getLocation().equals(cfg.getBundleLocation())) {
cfg.setBundleLocation(bundleLocation);
return cfg;
}
// Multi-location
if (cfg.getBundleLocation().startsWith("?")) {
if (bundle.hasPermission(new ConfigurationPermission(cfg.getBundleLocation(), "target"))) {
return cfg;
}
}
// configuration belongs to another bundle, cannot be used here
m_logger.log(Log.ERROR, "Cannot use configuration pid=" + pid + " for bundle "
+ bundleLocation + " because it belongs to bundle " + cfg.getBundleLocation());
} catch (IOException ioe) {
m_logger.log(Log.WARNING, "Failed reading configuration for pid=" + pid, ioe);
}
return null;
}
代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.features
cfg.setBundleLocation(null);
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo
private Configuration getConfiguration(final ConfigurationAdmin admin, final String pid,
final Bundle bundle) {
if (admin == null) {
return null;
}
try {
// Even if it is possible, we don't build the filter with bundle.location to detect the case where the
// configuration exists but can't be managed by iPOJO.
final Configuration cfg = admin.getConfiguration(pid);
final String bundleLocation = bundle.getLocation();
if (cfg.getBundleLocation() == null || bundleLocation.equals(cfg.getBundleLocation())
|| m_context.getBundle().getLocation().equals(cfg.getBundleLocation())) {
cfg.setBundleLocation(bundleLocation);
return cfg;
}
// Multi-location
if (cfg.getBundleLocation().startsWith("?")) {
if (bundle.hasPermission(new ConfigurationPermission(cfg.getBundleLocation(), "target"))) {
return cfg;
}
}
// configuration belongs to another bundle, cannot be used here
m_logger.log(Log.ERROR, "Cannot use configuration pid=" + pid + " for bundle "
+ bundleLocation + " because it belongs to bundle " + cfg.getBundleLocation());
} catch (IOException ioe) {
m_logger.log(Log.WARNING, "Failed reading configuration for pid=" + pid, ioe);
}
return null;
}
代码示例来源:origin: io.fabric8/fabric-boot-commands
properties.put("zookeeper.url", zookeeperUrl);
properties.put("zookeeper.password", PasswordEncoder.encode(encodedPassword));
config.setBundleLocation(null);
config.update(properties);
if (!nonManaged) {
代码示例来源:origin: org.osgi/osgi.enroute.configurer.simple.provider
configuration.setBundleLocation("?");
configuration.update(newer);
代码示例来源:origin: org.apache.felix.karaf.features/org.apache.felix.karaf.features.core
protected void doInstallFeature(InstallationState state, Feature feature) throws Exception {
for (Feature dependency : feature.getDependencies()) {
Feature f = getFeature(dependency.getName(), dependency.getVersion());
if (f == null) {
throw new Exception("No feature named '" + dependency.getName()
+ "' with version '" + dependency.getVersion() + "' available");
}
doInstallFeature(state, f);
}
for (String config : feature.getConfigurations().keySet()) {
Dictionary<String,String> props = new Hashtable<String, String>(feature.getConfigurations().get(config));
String[] pid = parsePid(config);
Configuration cfg = findExistingConfiguration(configAdmin, pid[0], pid[1]);
if (cfg == null) {
cfg = createConfiguration(configAdmin, pid[0], pid[1]);
String key = (pid[1] == null ? pid[0] : pid[0] + "-" + pid[1]);
props.put(CONFIG_KEY, key);
if (cfg.getBundleLocation() != null) {
cfg.setBundleLocation(null);
}
cfg.update(props);
}
}
Set<Long> bundles = new HashSet<Long>();
for (String bundleLocation : feature.getBundles()) {
Bundle b = installBundleIfNeeded(state, bundleLocation);
bundles.add(b.getBundleId());
}
state.features.put(feature, bundles);
}
代码示例来源:origin: jboss-fuse/fabric8
properties.put("zookeeper.url", zookeeperUrl);
properties.put("zookeeper.password", PasswordEncoder.encode(encodedPassword));
config.setBundleLocation(null);
config.update(properties);
if (!nonManaged) {
代码示例来源:origin: org.fusesource.fabric/fabric-configadmin
c.put(FABRIC_ZOOKEEPER_PID, pid);
if (config.getBundleLocation() != null) {
config.setBundleLocation(null);
内容来源于网络,如有侵权,请联系作者删除!