Created
          March 27, 2016 18:52 
        
      - 
      
 - 
        
Save nateyolles/f795100e8774cdbbf55c to your computer and use it in GitHub Desktop.  
    AEM com.adobe.granite.confmgr.Conf example of using the com.adobe.granite.confmgr.ConfMgr service
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package com.nateyolles.aem.slashconf.core.models; | |
| import javax.annotation.PostConstruct; | |
| import javax.inject.Inject; | |
| import org.apache.sling.api.SlingHttpServletRequest; | |
| import org.apache.sling.api.resource.Resource; | |
| import org.apache.sling.api.resource.ValueMap; | |
| import org.apache.sling.models.annotations.Model; | |
| import com.adobe.granite.confmgr.Conf; | |
| import com.adobe.granite.confmgr.ConfMgr; | |
| /** | |
| * AEM com.adobe.granite.confmgr.Conf example of getting a configuration using | |
| * the ConfMgr service rather than adapting a Resource. | |
| */ | |
| @Model(adaptables = SlingHttpServletRequest.class) | |
| public class ConfServiceModel { | |
| @Inject | |
| private ConfMgr confMgr; | |
| @Inject | |
| private Resource currentResource; | |
| @PostConstruct | |
| protected void init() { | |
| final Conf conf = confMgr.getConf(currentResource); | |
| final ValueMap fooSettings = conf.getItem("socialmedia/foo"); | |
| final String name = fooSettings.get("name", String.class); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment