I have a OSGi Transformer component which is instantiated by sling. In my OSGi component I have the following annotations :
@Component(configurationFactory = true, metatype = true, policy = ConfigurationPolicy.REQUIRE, label = "CDN Link Rewriter", description = "Rewrites links to all static files to use configurable CDN")
@Service(value = TransformerFactory.class)
public class StaticLinkTransformer implements Transformer,
TransformerFactory
I have some properties which I have annotated as @Property
@Property(label = "CDN Url prefix", description = "CDN URL prefix", value = "")
private static final String CDN_URL_PREFIX = "cdn_url_prefix";
Now I am able to provide multiple configurations for this class using "+" sign in felix console. If I have "N" number of configurations, sling is instantiating N objects of my StaticLinkRewriter class.
Question : How do I get the proper configurations for the object instantiated ? I mean, when sling instantiates my objects, how can i get the configurations for which the object was instantiated ?
I think this component is not instantiated by Sling but by Declarative Services.
You can get the configuration if you implement the activate method. E.g.:
For more information, see the 112 Declarative Services Specification chapter of OSGi Compendium specification.