How to initialize ResourceResolver reference variable.
Hi
How I can initialize Resourceresolver reference variable without @3214626 annotation.
Hi
How I can initialize Resourceresolver reference variable without @3214626 annotation.
Hi @akshaybhujbale ,
Before you get ResourceResolver using service/system user. You must have
1. Must have service user created with needed permissions.
2. It should map with your bundle. if you use for specific project/operations.
You should not do any of these task manually. These should be done by code/configurations.
Created service user and adding permission can done by ACS Commons or Repository Initialization (repoinit). Recommended to use Repository Initialization (repoinit) for aem as a cloud service
Using ACS Commons- Create this OSGi config
com.adobe.acs.commons.users.impl.EnsureServiceUser
Or Using Repository Initialization
org.apache.sling.jcr.repoinit.RepositoryInitializer
Map service user to bundle using this OSGi config
org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl
Once you are done with these configs. Get ResourceResolver using this service user
@Reference ResourceResolverFactory resourceResolverFactory; final Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put( ResourceResolverFactory.SUBSERVICE, "SERVICE_USER" ); ResourceResolver resolver = resourceResolverFactory.getServiceResourceResolver(paramMap);
Hope this will help
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.