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

How to share a configuration across multiple bundles in AEM6.4

Avatar

Avatar
Validate 1
Level 1
jamesc25111500
Level 1

Likes

0 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
jamesc25111500
Level 1

Likes

0 likes

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
jamesc25111500
Level 1

01-02-2020

Hello,

 

I have multiples OSGi bundles that use the same configuration properties.  Now I create a below service for each bundle:

@ObjectClassDefinition(name = "My configuration service", description = "Configuration for bundle")
public @interface MyConfig {
           @AttributeDefinition(name = "My API:", description = "API endpoint for project", type = AttributeType.STRING)
           String myPropAPI() default "....";
...
}
@activate
protected void activate(final MyConfig config) {
         this.api_endpoint = this.config.myPropAPI();
}

 

Is it possible for other bundles to share this configuration service? Or  should I create a property file accessed directly by all bundles?  

 

Thanks for any input

View Entire Topic

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,118 likes

Total Posts

3,149 posts

Correct Reply

1,073 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,118 likes

Total Posts

3,149 posts

Correct Reply

1,073 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

03-02-2020

In case you have multiple services which share the same configuration (for whatever reason), I don't think that service factories are the right solution. Because service factories solve the issue of the same service with multiple configurations. Your problem seems to be the other way 'round.

 

In your case you should create a proper abstraction (e.g. "Endpoint Connection"), which can be configured centrally. All the other services use this "Endpoint Connection" service and do something like "myEndPointConnection.executeCommand(myCommand)", just to give an example.