Adapt WorkflowSession to a ResourceResolver ?
Solved! Go to Solution.
Views
Replies
Total Likes
As mentioned by Ashutosh, you can get resource resolver from workflow session.
Another way of good practice is to get serivce resource resolver, and you can write this reusable mention in one utils class and call it in your workflow
Example:
public static ResourceResolver getServiceResolver() throws LoginException {
Map<String, Object> param = new HashMap<>();
param.put(ResourceResolverFactory.SUBSERVICE, "my-custom-service");
BundleContext bundleContext = FrameworkUtil.getBundle(MyUtils.class).getBundleContext();
ServiceReference resourceResolverFactoryRef = bundleContext
.getServiceReference(ResourceResolverFactory.class.getName());
ResourceResolverFactory resFactory = (ResourceResolverFactory) bundleContext
.getService(resourceResolverFactoryRef);
return resFactory.getServiceResourceResolver(param);
}
Refer more details in : https://aemhub.blogspot.com/2020/12/how-to-get-service-resource-resolver.html
Regards
@anireddy You can adapt to the ResourceResolver interface from workflowSession to get the Resource Resolver object.
ResourceResolver resourceResolver = workflowSession.adaptTo(ResourceResolver.class);
Views
Replies
Total Likes
You can adapt to ResourceResolver from workflowSession. Try this and let me know if this does not work.
Views
Replies
Total Likes
Views
Replies
Total Likes
As mentioned by Ashutosh, you can get resource resolver from workflow session.
Another way of good practice is to get serivce resource resolver, and you can write this reusable mention in one utils class and call it in your workflow
Example:
public static ResourceResolver getServiceResolver() throws LoginException {
Map<String, Object> param = new HashMap<>();
param.put(ResourceResolverFactory.SUBSERVICE, "my-custom-service");
BundleContext bundleContext = FrameworkUtil.getBundle(MyUtils.class).getBundleContext();
ServiceReference resourceResolverFactoryRef = bundleContext
.getServiceReference(ResourceResolverFactory.class.getName());
ResourceResolverFactory resFactory = (ResourceResolverFactory) bundleContext
.getService(resourceResolverFactoryRef);
return resFactory.getServiceResourceResolver(param);
}
Refer more details in : https://aemhub.blogspot.com/2020/12/how-to-get-service-resource-resolver.html
Regards
Views
Likes
Replies