2

我有一个 OSGi 服务,它只需要在发布实例中运行。当我只有 resourceResolver 而没有 request 时,如何在 java 中获得运行模式?

4

1 回答 1

9

要获取当前 AEM 实例正在使用的运行模式列表,您可以SlingSettingService在服务和/或 servlet 中使用。

import org.apache.felix.scr.annotations.Component;
import org.apache.sling.settings.SlingSettingsService;

@Component
public class MyService {

    @Reference
    private SlingSettingsService slingSettingsService;

    private boolean isPublish() {
        return this.slingSettingsService.getRunModes().contains("publish");
    }
}

看:

AEM 6.1:https ://docs.adobe.com/docs/en/aem/6-1/ref/javadoc/org/apache/sling/settings/SlingSettingsService.html

AEM 6.2:https ://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/org/apache/sling/settings/SlingSettingsService.html

AEM 6.3:https ://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/org/apache/sling/settings/SlingSettingsService.html

AEM 6.4:https ://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/javadoc/org/apache/sling/settings/SlingSettingsService.html

于 2016-09-23T17:12:52.180 回答