...
Code Block |
---|
public class MyClass { @Inject @OsgiService ResourceResolverFactory factory; ... } |
...
Enhanced injector registration
By convention, Slice reads injector name from second part of a resource type, e.g. if you request a a /apps/myapp/mycomponent
resource, the injector name will be "myapp
". This may be limiting in some cases, especially if you have multiple applications running on a single Sling/AEM instance and you want to group them meaningfully. Since Slice 4.1. you can instruct Slice where to look for an application, e.g. /apps/plugins/my-super-plugin-app
. In this case your injector name will be "my-super-plugin-app" instead of "plugins". You can do this by creating InjectorRunner appropriately in your application Acticator, passing passing applicationPath
argument, e.g.:
Code Block |
---|
@Override public void start(final BundleContext bundleContext) { final InjectorRunner injectorRunner = new InjectorRunner(bundleContext, INJECTOR_NAME, "/apps/plugins/my-super-plugin-app", BUNDLE_NAME_FILTER, BASE_PACKAGE); //modules installation injectorRunner.start(); } |
...