Whats is the equivalent for "propertyPrivate = true" in r6 annotation ? | Community
Skip to main content
kamalakannank62
Level 3
November 14, 2018
Solved

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

  • November 14, 2018
  • 4 replies
  • 2845 views

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" }) })

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

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"

               })

4 replies

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
November 14, 2018

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
kamalakannank62
Level 3
November 15, 2018

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

arunpatidar
Community Advisor
Community Advisor
November 15, 2018

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
kamalakannank62
Level 3
November 15, 2018

Thank You for the Reply,