Search code examples
osgiaemapache-felix

@Reference("(service.label=TESTCALL)") Felix SCR annotation error


am trying to implement an OSGI service which can serve me as ConfigurationFactory the service implementation has just two properties as shown below.

@Property(value="this is service variable property value")
static final String MY_SERVICE_VARIABLE = "service.variable";

@Property(description="Label for this MyService")
private static final String MY_SERVICE_LABEL = "service.label";

and am retrieving this service configuration data from an OSGI servlet where i am trying to call this service by below code which compiles fine and retrieves data randomly from the multiple service configuration.

@Reference
MyService myservice;

But when i wanted to get each configuration data by using the service.label and am calling the service by using below code snippet in my OSGI servlet, while compiling am facing the below Error.

@Reference("(service.label=TESTCALL)")
MyService myservice;

cannot find symbol [ERROR] symbol: method value() [ERROR] location: @interface org.apache.felix.scr.annotations.Reference.


Solution

  • use @Reference(target = "(service.label=TESTCALL)") for AEM 6.x versions, it should compile. I have uploaded the sample POC that i have used earlier at my gourivar github and the same POC example you can find at my aemvardhan.wordpress.com