Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Use of Activator.java in CQ bundle

askdctm
Level 9
Level 9

Hi All,

Can someone please let me know on this.

Any sample snippet of code/references will be helpful.

1 Accepted Solution
Peter_Puzanovs
Correct answer by
Community Advisor
Community Advisor

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/...

Thanks,

Peter

View solution in original post

3 Replies
Peter_Puzanovs
Correct answer by
Community Advisor
Community Advisor

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/...

Thanks,

Peter

Yogesh_Upadhyay
Level 5
Level 5

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
Level 1
Level 1

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.