Reputation: 95
I'm migrating an AEM 6.1 application to AEM 6.3. Since Felix annotations (org.apache.felix.scr.annotations.*) are deprecated, I decided to migrate my components to the OSGi annotations (org.osgi.service.component.annotations.*).
Once I figured out how it works, it is pretty easy. But there is one case I don't know how to handle: Properties with propertyPriavte = true.
The old implementation looks like this:
@Component(metatype = true)
@Service(Servlet.class)
@Properties({
@Property(name = "sling.servlet.selectors", value = "overlay", propertyPrivate = true),
})
public class OverlayServletImpl extends OverlayServlet {
...
}
The property sling.servlet.selectors would not be configurable in the Configuration Manager at the AEM console, but it would be configurable due to a config file, right? So, I still need to define this property.
For other properties I changed my implementation like this:
// OverlayServletImpl
@Component(
service = Servlet.class,
configurationPid = "my.package.path.OverlayServletImpl"
)
@Designate(
ocd = OverlayServletImplConfiguration.class
)
public class OverlayServletImpl extends OverlayServlet {
...
}
// Configuration
@ObjectClassDefinition(name = "Overlay Servlet")
public @interface OverlayServletImplConfiguration {
String sling_servlet_selectors() default "overlay";
...
}
Now, I have the property sling.servlet.selectors, but it is also available in Configuration Manager and it'S value can be changed there. But I don't want that.
How can I do that? Is this possible with the OSGi annotations?
Thank you and best regards!
Upvotes: 3
Views: 2388
Reputation: 1008
It looks like this might be possible if you use the @Component
annotation to specify your private properties.
@Component(service = Servlet.class,
property =
{ SLING_SERVLET_RESOURCE_TYPES + "=aemhtlexamples/structure/page",
SLING_SERVLET_METHODS + "=GET",
SLING_SERVLET_EXTENSIONS + "=html",
SLING_SERVLET_SELECTORS + "=hello" })
public class SimpleServlet extends SlingSafeMethodsServlet {
@Override
protected void doGet(final SlingHttpServletRequest req, final SlingHttpServletResponse resp)
throws ServletException, IOException {
final Resource resource = req.getResource();
resp.getOutputStream().println(resource.toString());
resp.getOutputStream().println("This content is generated by the SimpleServlet");
}
}
Upvotes: 1
Reputation: 19606
As far as I know this is not possible. Every property you define can be overridden by config.
Upvotes: 0