Thursday, 9 March 2017

Managing multiple instances of the same Adobe Experience Manager OSGi service

When developing custom services for Adobe Experience Manager, you can define a service that can be configured using the Felix Configuration screen.

You define configuration fields that show up in the Felix configuration screen by using a @Property annotations. For example: 

@Property(description="adress to whom email is sent",value=DEFAULT_ADDRESS)
    private static final String ADDRESS = "mailservice.address";
    private String address;

You can configure your AEM service to use different configuration values. For example, you can configure 1 to many different instances of the same service. 

Assume you want to develop a custom email service that contain the following configuration values. 
  • the email address to which an email is sent
  • the email address from which the email is sent
You can configure the custom email service so that each service instance has a different value for these configuration settings. You can enter an AEM configuration value into an AEM configuration dialog, as shown here. 

In this configuration dialog, the to and from email addresses are configurable. You can configure additional configuration settings for the same service.  

When you use the custom Service within AEM, you can create a reference to the exact configuration service that you want to reference. To do this, you use the @Reference annotation and additional metadata such as: 

 @Reference(target = "(mailservice.label=InternetA)")
     MailService mailServiceA; 
     @Reference(target = "(mailservice.label=InternetB)")
     MailService mailServiceB;      

In the above dialog, there is a additional field named emailservice.label. You can reference the value in this field with the target value when using the @Reference annotation. 

This development article guides you through how to create an OSGi service where there are multiple configured services and how to use the  @Reference(target = "(mailservice.label=InternetA)") annotation properly.  

Adobe Digital Marketing Community

Join the Adobe Digital Marketing Community. Start by clicking this banner

I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with over 18 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.

TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeMktgCare.

TwitterFollow me on Twitter @smac2020  


  1. You can also use a particular implementation of a service interface by writing its fully qualified name in target. Example: If HelloServiceImpl1 and HelooServiceImpl2 are implementations of HelloService, use fully qualified name of the implementation in @Reference.

  2. This article will show use of this.

  3. This comment has been removed by a blog administrator.

  4. Digital marketing is an umbrella term for the marketing of products or services using digital technologies, mainly on the Internet, but also including mobile phones, display advertising, and any other digital medium

  5. Really i appreciate, this is very best information, Keep more posting.
    Seo Services in Nagpur

  6. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Adobe Experience manager, kindly contact us
    MaxMunus Offer World Class Virtual Instructor led training on Adobe Experience manager . We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us:
    Name : Arunkumar U
    Email :
    Skype id: training_maxmunus
    Contact No.-+91-9738507310
    Company Website –