本文整理了Java中org.osgi.service.cm.Configuration.getBundleLocation()
方法的一些代码示例,展示了Configuration.getBundleLocation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getBundleLocation()
方法的具体详情如下:
包路径:org.osgi.service.cm.Configuration
类名称:Configuration
方法名:getBundleLocation
[英]Get the bundle location. Returns the bundle location or region to which this configuration is bound, or null if it is not yet bound to a bundle location or region. If the location starts with ? then the configuration is delivered to all targets and not restricted to a single bundle.
[中]获取捆绑包的位置。返回此配置绑定到的捆绑包位置或区域,如果尚未绑定到捆绑包位置或区域,则返回null。如果位置以开始?然后将配置交付给所有目标,而不限于单个捆绑包。
代码示例来源:origin: apache/felix
/**
* @see org.osgi.service.cm.Configuration#getBundleLocation()
*/
public String getBundleLocation() {
return configuration.getBundleLocation();
}
/**
代码示例来源:origin: neva-dev/felix-search-webconsole-plugin
@Override
public boolean apply(Bundle bundle) {
return StringUtils.equals(configuration.getBundleLocation(), bundle.getLocation());
}
}).orNull();
代码示例来源:origin: apache/felix
private boolean checkBundleLocation(Configuration config, Bundle bundle)
{
if ( config == null )
{
return false;
}
String configBundleLocation = config.getBundleLocation();
return checkBundleLocation( configBundleLocation, bundle );
}
代码示例来源:origin: org.apache.felix/org.apache.felix.scr
private boolean checkBundleLocation(Configuration config, Bundle bundle)
{
if ( config == null )
{
return false;
}
String configBundleLocation = config.getBundleLocation();
return checkBundleLocation( configBundleLocation, bundle );
}
代码示例来源:origin: apache/felix
private final Bundle getBoundBundle(Configuration config)
{
if (null == config)
return null;
final String location = config.getBundleLocation();
if (null == location)
return null;
final Bundle bundles[] = getBundleContext().getBundles();
for (int i = 0; bundles != null && i < bundles.length; i++)
{
if (bundles[i].getLocation().equals(location))
return bundles[i];
}
return null;
}
代码示例来源:origin: de.dentrassi.osgi/net.luminis.cmc
public static void print(final Configuration configuration) {
System.out.println("");
System.out.println("Configuration for service (pid) \"" + configuration.getPid() + "\"");
System.out.println("(bundle location = " + configuration.getBundleLocation() + ")");
print(configuration.getProperties());
}
代码示例来源:origin: org.apache.felix/org.apache.felix.webconsole
private final Bundle getBoundBundle(Configuration config)
{
if (null == config)
return null;
final String location = config.getBundleLocation();
if (null == location)
return null;
final Bundle bundles[] = getBundleContext().getBundles();
for (int i = 0; bundles != null && i < bundles.length; i++)
{
if (bundles[i].getLocation().equals(location))
return bundles[i];
}
return 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: 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.felix.karaf.shell/org.apache.felix.karaf.shell.config
protected void doExecute(ConfigurationAdmin admin) throws Exception {
Configuration[] configs = admin.listConfigurations(query);
for (Configuration config : configs) {
System.out.println("----------------------------------------------------------------");
System.out.println("Pid: " + config.getPid());
if (config.getFactoryPid() != null) {
System.out.println("FactoryPid: " + config.getFactoryPid());
}
System.out.println("BundleLocation: " + config.getBundleLocation());
if (config.getProperties() != null) {
System.out.println("Properties:");
Dictionary props = config.getProperties();
for (Enumeration e = props.keys(); e.hasMoreElements();) {
Object key = e.nextElement();
System.out.println(" " + key + " = " + props.get(key));
}
}
}
}
}
代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.config
protected void doExecute(ConfigurationAdmin admin) throws Exception {
Configuration[] configs = admin.listConfigurations(query);
for (Configuration config : configs) {
io.out.println("----------------------------------------------------------------");
io.out.println("Pid: " + config.getPid());
if (config.getFactoryPid() != null) {
io.out.println("FactoryPid: " + config.getFactoryPid());
}
io.out.println("BundleLocation: " + config.getBundleLocation());
if (config.getProperties() != null) {
io.out.println("Properties:");
Dictionary props = config.getProperties();
for (Enumeration e = props.keys(); e.hasMoreElements();) {
Object key = e.nextElement();
io.out.println(" " + key + " = " + props.get(key));
}
}
}
}
}
代码示例来源:origin: apache/felix
private void printConfiguration(PrintWriter pw, Configuration config)
{
ConfigurationRender.infoLine(pw, "", "PID", config.getPid());
if (config.getFactoryPid() != null)
{
ConfigurationRender.infoLine(pw, " ", "Factory PID", config.getFactoryPid());
}
String loc = (config.getBundleLocation() != null) ? config.getBundleLocation()
: "Unbound";
ConfigurationRender.infoLine(pw, " ", "BundleLocation", loc);
Dictionary props = config.getProperties();
if (props != null)
{
SortedSet keys = new TreeSet();
for (Enumeration ke = props.keys(); ke.hasMoreElements();)
{
keys.add(ke.nextElement());
}
for (Iterator ki = keys.iterator(); ki.hasNext();)
{
String key = (String) ki.next();
ConfigurationRender.infoLine(pw, " ", key, props.get(key));
}
}
pw.println();
}
代码示例来源:origin: org.apache.karaf.config/org.apache.karaf.config.command
System.out.println("FactoryPid: " + config.getFactoryPid());
System.out.println("BundleLocation: " + config.getBundleLocation());
if (config.getProperties() != null) {
System.out.println("Properties:");
代码示例来源:origin: org.apache.felix/org.apache.felix.webconsole
private void printConfiguration(PrintWriter pw, Configuration config)
{
ConfigurationRender.infoLine(pw, "", "PID", config.getPid());
if (config.getFactoryPid() != null)
{
ConfigurationRender.infoLine(pw, " ", "Factory PID", config.getFactoryPid());
}
String loc = (config.getBundleLocation() != null) ? config.getBundleLocation()
: "Unbound";
ConfigurationRender.infoLine(pw, " ", "BundleLocation", loc);
Dictionary props = config.getProperties();
if (props != null)
{
SortedSet keys = new TreeSet();
for (Enumeration ke = props.keys(); ke.hasMoreElements();)
{
keys.add(ke.nextElement());
}
for (Iterator ki = keys.iterator(); ki.hasNext();)
{
String key = (String) ki.next();
ConfigurationRender.infoLine(pw, " ", key, props.get(key));
}
}
pw.println();
}
代码示例来源: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: com.github.danielpacak.osgi.swingconsole/osgi.swingconsole
/**
* Returns configuration for the {@link #getSelectedService() selected} service.
*
* @return configuration data or {@code null}
* @throws IllegalStateException if the selected service is {@code null}
*/
public ConfigurationDTO getConfiguration() {
checkThatSelectedServiceIsNotNull();
String pid = selectedService.getPid();
Configuration configuration = getConfiguration(pid);
if (configuration != null && configuration.getProperties() != null) {
return new ConfigurationDTO().setPid(pid).setBundleLocation(configuration.getBundleLocation())
.setValues(Maps.valueOf(configuration.getProperties()));
}
return null;
}
代码示例来源: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: osgi/osgi.enroute.examples
@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);
}
}
代码示例来源:origin: apache/felix
ObjectClassDefinition getObjectClassDefinition( Configuration config, String locale )
{
// if the configuration is bound, try to get the object class
// definition from the bundle installed from the given location
if ( config.getBundleLocation() != null )
{
Bundle bundle = getBundle( this.getBundleContext(), config.getBundleLocation() );
if ( bundle != null )
{
String id = config.getFactoryPid();
if ( null == id )
{
id = config.getPid();
}
return getObjectClassDefinition( bundle, id, locale );
}
}
// get here if the configuration is not bound or if no
// bundle with the bound location is installed. We search
// all bundles for a matching [factory] PID
// if the configuration is a factory one, use the factory PID
if ( config.getFactoryPid() != null )
{
return this.getObjectClassDefinition( config.getFactoryPid(), locale );
}
// otherwise use the configuration PID
return this.getObjectClassDefinition( config.getPid(), locale );
}
代码示例来源:origin: org.apache.felix/org.apache.felix.webconsole
ObjectClassDefinition getObjectClassDefinition( Configuration config, String locale )
{
// if the configuration is bound, try to get the object class
// definition from the bundle installed from the given location
if ( config.getBundleLocation() != null )
{
Bundle bundle = getBundle( this.getBundleContext(), config.getBundleLocation() );
if ( bundle != null )
{
String id = config.getFactoryPid();
if ( null == id )
{
id = config.getPid();
}
return getObjectClassDefinition( bundle, id, locale );
}
}
// get here if the configuration is not bound or if no
// bundle with the bound location is installed. We search
// all bundles for a matching [factory] PID
// if the configuration is a factory one, use the factory PID
if ( config.getFactoryPid() != null )
{
return this.getObjectClassDefinition( config.getFactoryPid(), locale );
}
// otherwise use the configuration PID
return this.getObjectClassDefinition( config.getPid(), locale );
}
内容来源于网络,如有侵权,请联系作者删除!