In my project we have few servlets that are osgi components and have properties tied to them. Like
@Component(label = "Default Address Servlet", immediate = true)
@Service(value = Servlet.class)
@Properties(
@Property(name = "sling.servlet.resourceTypes", value = { "sling/servlet/default" }),
@Property(name = "sling.servlet.selectors", value = { "defaultaddress" }),
@Property(name = "sling.servlet.extensions", value = { "json" }),
@Property(name = "sling.servlet.methods", value = { "POST" }),
@Property(name = "prop1", value = { "value1" }) })
public class SetDefaultAddressServlet extends SlingAllMethodsServlet {
Now I have a requirement to use this prop1 inside a sling model class during a load of a component. While technically servlets are osgi components, it is ok to reference this servlet as osgi component? Like
@Model(adaptables = SlingHttpServletRequest.class)
public class Address {
@Inject
@Reference
private SetDefaultAddressServlet service;
Though this technically works right, is it a good approach? Or alternate, I need to create separate OSGi service with the respective property and reference it. What is the advisable approach?