How do I programmatically know which run-mode the instance is running? I created a custom tag that provides the config depending on the instance run-mode, but I can not determine the current run-mode.
I found a method that returns a list of run-mods instance:
SlingSettings settings = ...get from BundleContext...
Set<String> currentRunModes = settings.getRunModes();
But I can not get the objects SlingSettings or BundleContext. How can I get these objects or perhaps there is another way to get the current run-mode?
Note: Only primary run modes (ex: author,publish) are applicable for renaming jar. How to check the run mode of a running AEM instances? Go to Felix Console. Go to Status tab in Navigation and click on sling settings option.
Run modes allow you to tune your AEM instance for a specific purpose; for example author or publish, test, development, intranet or others. You can: Define collections of configuration parameters for each run mode.
Important: The run mode of an instance cannot be changed from author to publish, or vice versa, once an AEM instance has been installed. Some run modes, such as the author run mode and the publish run mode, are mutually exclusive. If both are specified, only the first run mode is used.
SlingSetttings is the right way - If it's from Java the simplest way to get it is with an SCR @Reference annotation in a class that's an SCR @Component, saves you from having to go through BundleContext.
If it's from a Sling script, you can use sling.getService(....) to get the SlingSettings.
Note that the cases where you need to read the run modes are rare, usually you'd rather setup your OSGi configurations to depend on the run modes and have the OSGi components modify their behavior based on that.
You can also try this:
RunModeService runModeService = getSlingScriptHelper().getService(RunModeService.class);
author = runModeService.isActive("author");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With