Hi All,
Is there any alternative to detect run-mode of instance in AEM as cloud service as slingSettingsService shows as deprecated?
The use case is to execute code only on author or publish instances but not both.
Thanks,
Ram
Solved! Go to Solution.
Views
Replies
Total Likes
Not sure if this blog article has been specifically been written for you
https://blog.osoco.de/2021/07/the-truth-about-aem-run-modes/
Hi @rampai
The solution is still in planning phase and no API is exposed like SlingSettingService to get the run mode.
https://github.com/Adobe-Consulting-Services/acs-aem-commons/issues/2476
In the mean time you can create an OSGi service and set the run mode config value in OSGi configuration and read it in your code. That should resolve the issue.
Here is an article which will give a good idea:
https://cqdump.joerghoh.de/2018/09/12/referencing-runmodes-in-java/
Thanks!
Hello,
Please check https://medium.com/adobetech/custom-runmodes-on-aem-as-a-cloud-service-79b757f51a6b for custom runmodes (not to be used or used cautiously) which discusses about some good practices.
It seems to provide an example of refactored code.
From the reference above, we can try this
@Property(label = "Environment Type", description = "Should be dev/stage/prod/local - default is local") private static final String ENVIRONMENT_TYPE = "environment.type"; private String environmentType; @Activate @Modified protected void activate(final Map<String, String> config) { environmentType = PropertiesUtil.toString(config.get(ENVIRONMENT_TYPE), DEFAULT_ENVIRONMENT_TYPE); log.debug("Environment Type Service Activated with Environment Type of {}", environmentType); } public String getEnvironmentType() { return environmentType; }
Not sure if this blog article has been specifically been written for you
https://blog.osoco.de/2021/07/the-truth-about-aem-run-modes/
Views
Likes
Replies
Views
Likes
Replies