0

I have folowing classses

abstarct class:

@Component(componentAbstract = true)
public abstract class A implements SomeInterface{ 
    @Reference
    private ConfigurationManager manager;
    @Activate
    protected void activate(ComponentContext componentContext) {
       manager.getTimeout();
    }
}

first child:

 @Component(
            enabled = true,
            immediate = true,
            inherit = true,
            metatype = true,
            label = "***",
            description = "***"
    )
    public class A1 extends A {...}

second child:

@Component(
        enabled = true,
        immediate = true,
        inherit = true,
        metatype = true,
        label = "********",
        description = "*************"
)
public class A2 extends A {...}

A and A1 resides in same bundle but A2 in another.

when Apache Felix instantiate A1 manager.getTimeout(); row executes successfully but for A2 this row is cause of NullPointeException.

How to solve this problem?

update:

@Component(
        enabled = true,
        immediate = true,
        metatype = true,
        label = "***"
)
@Service(ConfigurationManager.class)
public class ConfigurationManager {
@Activate
    protected void activate(ComponentContext componentContext) {
        valueDelimiter = PropertiesUtil.toString(componentContext.getProperties().get(PROPERTY_VALUE_DELIMITER), PROPERTY_VALUE_DELIMITER_DEFAULT);
        valueDelimiter = Pattern.quote(StringEscapeUtils.unescapeJava(valueDelimiter));//read value from osgi config
        ...

        LOG.info("Service reconfigured: {}", toString());
    }

}
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

0 Answers0