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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

No services bound

ashwiniv5325199
Level 2
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
Peter_Puzanovs
Community Advisor
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

smacdonald2008
Level 10
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