Class RunMode


  • @ProviderType
    public final class RunMode
    extends java.lang.Object
    Sling run mode utility methods.

    Most methods in this class are deprecated because SlingSettingsService is deprecated in recent AEM versions. The OSGi service InstanceTypeService can be used instead.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String AUTHOR
      Runmode for author instance
      static java.lang.String PUBLISH
      Runmode for publish instance
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static boolean disableIfNoRunModeActive​(java.util.Set<java.lang.String> runModes, java.lang.String[] allowedRunModes, org.osgi.service.component.ComponentContext componentContext, org.slf4j.Logger log)
      Deprecated.
      Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy).
      static boolean disableIfNotAuthor​(java.util.Set<java.lang.String> runModes, org.osgi.service.component.ComponentContext componentContext, org.slf4j.Logger log)
      Deprecated.
      Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy).
      static boolean disableIfNotPublish​(java.util.Set<java.lang.String> runModes, org.osgi.service.component.ComponentContext componentContext, org.slf4j.Logger log)
      Deprecated.
      Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy).
      static boolean is​(java.util.Set<java.lang.String> runModes, java.lang.String... expectedRunModes)
      Deprecated.
      Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy).
      static boolean isAuthor​(java.util.Set<java.lang.String> runModes)
      Deprecated.
      Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy).
      static boolean isPublish​(java.util.Set<java.lang.String> runModes)
      Deprecated.
      Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • AUTHOR

        public static final java.lang.String AUTHOR
        Runmode for author instance
        See Also:
        Constant Field Values
      • PUBLISH

        public static final java.lang.String PUBLISH
        Runmode for publish instance
        See Also:
        Constant Field Values
    • Method Detail

      • is

        @Deprecated
        public static boolean is​(java.util.Set<java.lang.String> runModes,
                                 java.lang.String... expectedRunModes)
        Deprecated.
        Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy). In this case, a component gets only active if a configuration is available. Such a configuration can be put into the repository for the specific run mode.
        Checks if given run mode is active.
        Parameters:
        runModes - Run modes for current instance
        expectedRunModes - Run mode(s) to check for
        Returns:
        true if any of the given run modes is active
      • isAuthor

        @Deprecated
        public static boolean isAuthor​(java.util.Set<java.lang.String> runModes)
        Deprecated.
        Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy). In this case, a component gets only active if a configuration is available. Such a configuration can be put into the repository for the specific run mode.
        Checks if context is running on author instance.
        Parameters:
        runModes - Run modes
        Returns:
        true if "author" run mode is active
      • isPublish

        @Deprecated
        public static boolean isPublish​(java.util.Set<java.lang.String> runModes)
        Deprecated.
        Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy). In this case, a component gets only active if a configuration is available. Such a configuration can be put into the repository for the specific run mode.
        Checks if context is running on publish instance.
        Parameters:
        runModes - Run modes
        Returns:
        true if "publish" run mode is active
      • disableIfNoRunModeActive

        @Deprecated
        public static boolean disableIfNoRunModeActive​(java.util.Set<java.lang.String> runModes,
                                                       java.lang.String[] allowedRunModes,
                                                       org.osgi.service.component.ComponentContext componentContext,
                                                       org.slf4j.Logger log)
        Deprecated.
        Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy). In this case, a component gets only active if a configuration is available. Such a configuration can be put into the repository for the specific run mode.
        Use this to disable a component if none of its run modes are active. Component activation status is logged with DEBUG level. This method is a replacement for the com.day.cq.commons.RunModeUtil#disableIfNoRunModeActive(RunMode, String[], ComponentContext, Logger) method which is deprecated.
        Parameters:
        runModes - Run modes
        allowedRunModes - Allowed run modes
        componentContext - OSGI component context
        log - Logger
        Returns:
        true if component was disabled
      • disableIfNotAuthor

        @Deprecated
        public static boolean disableIfNotAuthor​(java.util.Set<java.lang.String> runModes,
                                                 org.osgi.service.component.ComponentContext componentContext,
                                                 org.slf4j.Logger log)
        Deprecated.
        Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy). In this case, a component gets only active if a configuration is available. Such a configuration can be put into the repository for the specific run mode.
        Use this to disable a component if the runmode "author" is not active. Component activation status is logged with DEBUG level. This method is a replacement for the com.day.cq.commons.RunModeUtil#disableIfNoRunModeActive(RunMode, String[], ComponentContext, Logger) method which is deprecated.
        Parameters:
        runModes - Run modes
        componentContext - OSGI component context
        log - Logger
        Returns:
        true if component was disabled
      • disableIfNotPublish

        @Deprecated
        public static boolean disableIfNotPublish​(java.util.Set<java.lang.String> runModes,
                                                  org.osgi.service.component.ComponentContext componentContext,
                                                  org.slf4j.Logger log)
        Deprecated.
        Instead of directly using the run modes, it is better to make the component in question require a configuration (see OSGI Declarative Services Spec: configuration policy). In this case, a component gets only active if a configuration is available. Such a configuration can be put into the repository for the specific run mode.
        Use this to disable a component if the runmode "publish" is not active. Component activation status is logged with DEBUG level. This method is a replacement for the com.day.cq.commons.RunModeUtil#disableIfNoRunModeActive(RunMode, String[], ComponentContext, Logger) method which is deprecated.
        Parameters:
        runModes - Run modes
        componentContext - OSGI component context
        log - Logger
        Returns:
        true if component was disabled