'generateComponent = false' property in @SlingServlet annotation | Community
Skip to main content
New Participant
April 2, 2016
Solved

'generateComponent = false' property in @SlingServlet annotation

  • April 2, 2016
  • 2 replies
  • 936 views

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.

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 Lokesh_Shivalingaiah

@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.9.8/org/apache/felix/scr/annotations/sling/SlingServlet.java#SlingServlet.generateComponent%28%29

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

2 replies

askdctmAuthor
New Participant
April 3, 2016

Hi Lokesh,

Thank you for your reply.

Lokesh_Shivalingaiah
Lokesh_ShivalingaiahAccepted solution
New Participant
April 2, 2016

@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.9.8/org/apache/felix/scr/annotations/sling/SlingServlet.java#SlingServlet.generateComponent%28%29

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