Expand my Community achievements bar.

SOLVED

'generateComponent = false' property in @SlingServlet annotation

Avatar

Level 9

Hi All,

@SlingServlet(
        paths = { "/content/data" }, generateComponent = false)

In couple of servlets, have seen the above. Went through http://sling.apache.org/documentation/the-sling-engine/servlets.html.

But could not get 

a] What exactly is the purpose of generateComponent = false.

Any thoughts on this will be helpful.

1 Accepted Solution

Avatar

Correct answer by
Level 10

@slingServlet includes @Component internally and hence we dont use that annotation specifically which is nothing by generateComponent=true (refer [1]). This enables all the methods or life cycle of component like activate, deactivate etc... 

If you are using @Component also along with your @slingServlet, then we need to use generateComponent=false for @slingServlet else it would have a conflict and throw an exception. refer [2]

 

[1] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.scr.annotations/1....

[2] http://versatileankur.blogspot.com/2015/02/maven-scr-plugin-error-in-aem.html

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

@slingServlet includes @Component internally and hence we dont use that annotation specifically which is nothing by generateComponent=true (refer [1]). This enables all the methods or life cycle of component like activate, deactivate etc... 

If you are using @Component also along with your @slingServlet, then we need to use generateComponent=false for @slingServlet else it would have a conflict and throw an exception. refer [2]

 

[1] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.felix/org.apache.felix.scr.annotations/1....

[2] http://versatileankur.blogspot.com/2015/02/maven-scr-plugin-error-in-aem.html

Avatar

Level 9

Hi Lokesh,

Thank you for your reply.