Empty Activate function with @Activate annotation | Community
Skip to main content
Level 2
March 11, 2022
Solved

Empty Activate function with @Activate annotation

  • March 11, 2022
  • 2 replies
  • 1660 views

In a project I am working on there are multiple servlets, services with an activate function with @580286 annotation where the function has no body, said activate function is taking a configuration as parameter. The configuration has a single field. I am attaching code snippet for one such case below for reference. 
What is the reason behind these empty activate functions, as they are not passing any value from configuration. furthermore what impact might removing such activate function can cause.

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 lukasz-m

Hi @shubham_naik to me it looks like a dead code. In my opinion having empty activate method does not bring any benefit. I think that removing such an empty activate method will not affect component/service functionality. In other words it should be safe to remove those methods. There is a nice documentation page that explains OSGi component lifecycle including activate, modify, deactivate annotation/methods usage - maybe this could be useful for you.

https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/developing/osgi-services/lifecycle.html?lang=en

 

2 replies

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
March 11, 2022

Hi @shubham_naik to me it looks like a dead code. In my opinion having empty activate method does not bring any benefit. I think that removing such an empty activate method will not affect component/service functionality. In other words it should be safe to remove those methods. There is a nice documentation page that explains OSGi component lifecycle including activate, modify, deactivate annotation/methods usage - maybe this could be useful for you.

https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/developing/osgi-services/lifecycle.html?lang=en

 

Level 2
March 11, 2022

Thanks @lukasz-m , even I thought the same, but it always helps to get a confirmation before decommissioning any code, thanks a lot for the help.👍

DEBAL_DAS
New Member
March 11, 2022

Yes I agree with @lukasz-m here, if you want to understand OCD with @580286 ,modify and deactivate annotations , please refer this : https://aem4beginner.blogspot.com/ocd-issue-with-activate-annotation

 

Debal Das, Senior AEM Consultant
Level 2
March 11, 2022

Thanks a lot for the confirmation and resources @debal_das