Expand my Community achievements bar.

No services bound

Avatar

Level 2

HI TEAM,

      

           How to resolve the unsatisfied status to satisfied for Resource Resolver. Below is the screenshot of resource resolver service.In this I'm using OSGI annotation.

@Reference (org.osgi.service.component.annotations.Reference;)

protected ResourceResolver resourceResolver;(org.apache.sling.api.resource.ResourceResolver;)

1591949_pastedImage_0.png

Thanks & Regards,

Ashwini

5 Replies

Avatar

Community Advisor

Dear Ashwini,

Resource Resolver can be retrieved from Resource Resolver Factory API[0], please change your implementation to

@Referece

ResourceResolverFactory factory; //, then you can use factory to retrieve ResourceResolver for your needs.

[0] ResourceResolverFactory (Apache Sling 7 API)

Regards,

Peter

Avatar

Level 10

The proper code to obtain a ResourceResolver is:

@Component

public class EmployeeImpl implements EmployeeInter {

   

    /** Default log. */

    protected final Logger log = LoggerFactory.getLogger(this.getClass());

           

    private Session session;

               

    //Inject a Sling ResourceResolverFactory

    @Reference

    private ResourceResolverFactory resolverFactory;

   

   

    public String getEmployeeData()

    {

        Employee employee = null;

          

        List<Employee> employList = new ArrayList<Employee>();

        Map<String, Object> param = new HashMap<String, Object>();

        param.put(ResourceResolverFactory.SUBSERVICE, "datawrite");

        ResourceResolver resolver = null;

try {

                    

            //Invoke the adaptTo method to create a Session used to create a QueryManager

            resolver = resolverFactory.getServiceResourceResolver(param);

See - Adobe Experience Manager Help | Querying Adobe Experience Manager 6.4 JCR data