Expand my Community achievements bar.

SOLVED

How to change bundle start level.

Avatar

Level 4

Hello,

I need to change bundle start level from default 20 into 21 to prevent some timing issues.

I've found solution via bundle activator.

Something like this:

Bundle bundle = context.getBundle();

StartLevel startLevel = (StartLevel) context.getService(context.getServiceReference(StartLevel.class.getName()));

startLevel.setBundleStartLevel(bundle, 21);

Is it possible to change start level by another way?

Thanks,

Alex

1 Accepted Solution

Avatar

Correct answer by
Level 4

I think that such fix will be temporary.

We have a huge team and I can't control that all team will use such workaround (Someone can change query, implement new service with QueryBuilder, etc..).

We found another solution:

Place our bundles under /apps/{project}/install/21 (Default is 20).

Thanks,

Alex

View solution in original post

4 Replies

Avatar

Employee Advisor

If you need to change the startlevel of a bundle to prevent race conditions, you are doing something wrong. Just having the right service dependencies should always be sufficient. I do not recommend this approach.

kind regards,
Jörg

Avatar

Level 4

Definitely it's true.

But, in our application we are using in-memory cache which is initialized on service activate method.

In init method we are using Query Builder (Query contains predicate).

In error.log on AEM start up I see:

20.06.2017 08:30:47.189 ERROR [FelixStartLevel] com.day.cq.search.impl.builder.QueryBuilderImpl Unable to get PredicateEvaluator instance: group

And my query executed without some limitation (template, etc..).

It seems that we have such issues because QueryBuilder tries to get PredicateEvaluator via BundleContext.getServiceReference().

Note: Such issues reproducible from time to time.

Thanks,

Alex

Avatar

Employee Advisor

Ok, the QueryBuilder has a number of optional PredicateEvaluators. And just the availability of the QueryBuilder does not mean, that you can start a query and use this PredicateEvaluator.

I think that the PredicateEvaluators are also Services. Can you identify the correct service and build a dependency on the PredicateEvaluator you need directly in your service?

Jörg

Avatar

Correct answer by
Level 4

I think that such fix will be temporary.

We have a huge team and I can't control that all team will use such workaround (Someone can change query, implement new service with QueryBuilder, etc..).

We found another solution:

Place our bundles under /apps/{project}/install/21 (Default is 20).

Thanks,

Alex