Victor Victor - 1 year ago 75
Java Question

How to get rid of OSGi bundle's properties that are not exist in their corresponding configuration ("", etc.)?

I have the class similar to the following:

@Component(configurationPid = "", configurationPolicy = ConfigurationPolicy.REQUIRE)
public class MyClass {

public void activate(Map<String, Object> properties) throws Exception {
for (String property : properties.keySet()) {
if (!isValidProperty(property)) {
throw new IllegalArgumentException("Unknown property: " + property);


map must contain the properties from the corresponding configuration source (e.g. a file provided by an user). And it is, but it also contains some properties that are not really exist (
, etc.), so my program is broken. I want to get rid of them somehow.

I tried to use
and also blueprint
but this gives the same effect.

I can't hardcode the names of the properties to exclude, because I don't know what they are.

Is there any means to tell the OSGi runtime not to put them at all in my map?

I'm doing this using ServiceMix's OSGi support (which is essentially Karaf, Felix, and Aries).

Answer Source

Currently there is no way to exclude these artificial properties but I agree this is pretty bad.

You can open an issue and the Apache felix project jira.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download