Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Use of Activator.java in CQ bundle

Avatar

Level 9

Hi All,

Can someone please let me know on this.

Any sample snippet of code/references will be helpful.

1 Accepted Solution

Avatar

Correct answer by
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

4 Replies

Avatar

Correct answer by
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

Avatar

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

Avatar

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.