AEM – Fetch product info via API


Here is a code snippet that can be used to fetch AEM’s product information via APIs.

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.adobe.granite.license.ProductInfo;
import com.adobe.granite.license.ProductInfoProvider;

@Component(immediate = true)
@Service(ProductInfoImpl.class)
public class ProductInfoImpl {
   private static final Logger LOG = LoggerFactory.getLogger(ProductInfoImpl.class);

   @Reference
   private ProductInfoProvider piProvider;

   @Activate
   @Modified
   protected void activate(ComponentContext cc) {
       if (piProvider != null) {
           ProductInfo pi = piProvider.getProductInfo();

           //Logging product information
           LOG.info("Product name: " + pi.getName());
           LOG.info("Product short name: " + pi.getShortName());
           LOG.info("Product version: " + pi.getVersion());
           LOG.info("Product short version: " + pi.getShortVersion());
       }
   }
}

 

Information printed in logs:

Product name: Adobe Experience Manager
Product short name: AEM
Product version: 6.3.0
Product short version: 6.3

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s