I was writting one service and observed @Property we can define also inside the service as in my below code :
@Component(metatype = true, immediate = true, description = "Demo Service to test")
@Service(value = DemoService.class)
@Properties({
@Property(name = "testprop" , value = "This is Test Property")
})
public class DemoServiceImpl implements DemoService {
@Property(name = "localprop", value = "Local Value")
@Activate
public void activate(ComponentContext ctx)
{
String testprop = (String)ctx.getProperties().get("testprop");
String localprop = (String)ctx.getProperties().get("localprop");
}
}
Both properties display in felix console & accessible inside my service. So what creates the difference to declare them inside component or outside. One i saw we can not use @Properties inside component. But not sure what makes them functionally different from each other & when to use each.