Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

Whats is the equivalent for "propertyPrivate = true" in r6 annotation ?

Avatar

Level 3

Hello folks,

We are migrating from 6.2 to aem 6.4, So we are replacing scr annotations with OSGI R6 annotations,

While migrating Servlets properties I am not able to find equivalent for "propertyPrivate = true".

Below is the annotation Kindly suggest me the equivalent.

@Component

@Service

@Properties({ @Property(name = "service.description", value = "Servlet used to render alerts"),

        @Property(name = "sling.servlet.resourceTypes", value = "sling/servlet/default", propertyPrivate = true),

        @Property(name = "sling.servlet.selectors", value = "alertbar", propertyPrivate = true),

        @Property(name = "sling.servlet.methods", value = { "GET" }) })

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

You need to declare property inside component annotation.

e.g.

@Component(service = Servlet.class,

                              property = {

Constants.SERVICE_DESCRIPTION + "=Servlet used to render alerts",

               "sling.servlet.methods=" + HttpConstants.METHOD_GET,

               "sling.servlet.resourceTypes=sling/servlet/default",

               "sling.servlet.selectors=alertbar"

               })



Arun Patidar

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Hi,

You need to declare property inside component annotation.

e.g.

@Component(service = Servlet.class,

                              property = {

Constants.SERVICE_DESCRIPTION + "=Servlet used to render alerts",

               "sling.servlet.methods=" + HttpConstants.METHOD_GET,

               "sling.servlet.resourceTypes=sling/servlet/default",

               "sling.servlet.selectors=alertbar"

               })



Arun Patidar

Avatar

Level 3

Yeah I am declaring it under @component, But wasn't clear about the "privateProperty", thank you for the reply.

Avatar

Community Advisor

Hi,

When you declare property under component annotation , it is considered as private property.

And configurable properties are define using ObjectClassDefinition annotation

@Component(

        service = Servlet.class,

        property =

  { "privateprop=value" }

);

//configurable properties

@Designate(ocd = MyServiceImplConfiguration.class)

public class MyServiceImpl extends MyService {

...

}

// Configuration

@ObjectClassDefinition(name = "My Service Config")

public @interface MyServiceImplConfiguration {

    String my_prop1_path() default "/etc/design/MyProj";

...

}



Arun Patidar