Use of Activator.java in CQ bundle | Community
Skip to main content
October 16, 2015
Solved

Use of Activator.java in CQ bundle

  • October 16, 2015
  • 3 replies
  • 3372 views

Hi All,

Can someone please let me know on this.

Any sample snippet of code/references 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 Peter_Puzanovs

Hi,

Activator.java can be used to initialize(start) things.

headwire provides an excellent open source project that uses Activator.java to initialize logging:

https://github.com/headwirecom/aem-solr-search/blob/master/aemsolrsearch-services/src/main/java/com/headwire/aemsolrsearch/services/osgi/Activator.java

Thanks,

Peter

3 replies

Peter_Puzanovs
Community Advisor
Peter_PuzanovsCommunity AdvisorAccepted solution
Community Advisor
October 16, 2015

Hi,

Activator.java can be used to initialize(start) things.

headwire provides an excellent open source project that uses Activator.java to initialize logging:

https://github.com/headwirecom/aem-solr-search/blob/master/aemsolrsearch-services/src/main/java/com/headwire/aemsolrsearch/services/osgi/Activator.java

Thanks,

Peter

partyush
Community Advisor
Community Advisor
January 25, 2023

Thanks

Yogesh_Upadhyay
October 16, 2015

Hello,

As far as name is concern you can use any name for activation class (Need not have to be Activator.java), you just have to mention that in your bundle configuration as

Bundle-Activator:fully-qualified-activator-class-name

Please use this only if you want to do some initialization at bundle level. For Service level initialization use something like this (This will get called when your service get initialized)

@Activate protected final void activate(final ComponentContext componentContext) { }

Yogesh

www.wemblog.com

ambivert09
January 22, 2016

Hi Yogesh,

So does it mean that bundle activator class is optional for AEM OSGI bundles and i assume i can live fine by using @Activate/@Deactivate at service level and there will not be any bundle activator class at all in bundle. Here i assume that felix framework will initialize the bundle without any activator class with caveat that i am not doing any initialization at bundle level which we usually do not do.

It would be helpful if i can get reference to docs describing this.

Regards.