April 8, 2020
Estimated Post Reading Time ~

OSGI Services without annotation

[code language=”java”]
BundleContext bundleContext = FrameworkUtil.getBundle(YourClass.class).getBundleContext();

//alternate to @Reference private ResourceResolverFactory resolverFactory;ServiceReference factoryRef = bundleContext.getServiceReference(ResourceResolverFactory.class.getName());

resolverFactory = (ResourceResolverFactory) bundleContext.getService(factoryRef);

//alternate to @Reference private CustomPageManager customPageManager

ServiceReference articleRef = bundleContext.getServiceReference(CustomPageManager.class.getName());

customPageManager = (CustomPageManager.) bundleContext.getService(articleRef);

[/code]


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.