AEM 6.3 - Migrate Felix to OSGi annotations: How to deal with propertyPrivate?

Viewed 2069

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!

2 Answers
Related