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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Get Service from another bundle with JavaScript Use API

akatsuki07
Level 2
Level 2

Hello All,

 

I  want to call a service from another bundle using the sling.getService() method but I'm having a hard time trying to do this with the Javascript Use API. I have both bundles installed onto AEM and no dependencies attached to either.

 

I added a filter in bundle b (where the service I want exists) like so

 

(
        immediate = true,
        property = {"testprop=shopify"})
public class ShopifyStoreServiceCustomImpl implements ShopifyStoreServiceCustom {

 

 

and then in bundle a's use api I'm trying to call it like this:

 

var storeServiceCustom = sling.getServices(Packages.com.canopygrowth.shopify.core.services.ShopifyStoreServiceCustom, "(testprop=shopify)");

 

 

By doing this I'm getting null. Anything I'm doing wrong here?

1 Accepted Solution
Umesh_Thakur
Correct answer by
Community Advisor
Community Advisor

Can you verify you POM.xml for correct bundle export and import. it seems there are some issue.

see the below article that will help you to some extent.

https://www.albinsblog.com/2014/11/referencing-services-between-osgi.html#.YQumG1Mzbso

 

Umesh Thakur

View solution in original post

2 Replies
Umesh_Thakur
Correct answer by
Community Advisor
Community Advisor

Can you verify you POM.xml for correct bundle export and import. it seems there are some issue.

see the below article that will help you to some extent.

https://www.albinsblog.com/2014/11/referencing-services-between-osgi.html#.YQumG1Mzbso

 

Umesh Thakur

View solution in original post

akatsuki07
Level 2
Level 2
@Umesh_Thakur Hey I'm going for a loose coupling approach where both bundles are deployed to AEM. Would I still have to add dependency if I want to reference the service?