Interface Environment

  • All Known Implementing Classes:
    ContextEnvironment

    public interface Environment
    Interface representing the environment in which the current application is running. Models two key aspects of the application environment: profiles and properties.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ACTIVE_PROFILES_PROPERTY_NAME
      Name of property to set to specify active profiles: "aspectran.profiles.active".
      static java.lang.String DEFAULT_PROFILES_PROPERTY_NAME
      Name of property to set to specify profiles active by default: "aspectran.profiles.default".
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean acceptsProfiles​(java.lang.String... profiles)
      Return whether one or more of the given profiles is active or, in the case of no explicit active profiles, whether one or more of the given profiles is included in the set of default profiles.
      java.lang.String[] getActiveProfiles()
      Returns the set of profiles explicitly made active for this environment.
      java.lang.String[] getDefaultProfiles()
      Returns the set of profiles to be active by default when no active profiles have been set explicitly.
      <T> T getProperty​(java.lang.String name, Activity activity)
      Returns the value of the property on environment via Activity.
    • Field Detail

      • ACTIVE_PROFILES_PROPERTY_NAME

        static final java.lang.String ACTIVE_PROFILES_PROPERTY_NAME
        Name of property to set to specify active profiles: "aspectran.profiles.active". Value may be comma delimited.
        See Also:
        Constant Field Values
      • DEFAULT_PROFILES_PROPERTY_NAME

        static final java.lang.String DEFAULT_PROFILES_PROPERTY_NAME
        Name of property to set to specify profiles active by default: "aspectran.profiles.default". Value may be comma delimited.
        See Also:
        Constant Field Values
    • Method Detail

      • getActiveProfiles

        java.lang.String[] getActiveProfiles()
        Returns the set of profiles explicitly made active for this environment.
        Returns:
        the set of profiles explicitly made active
      • getDefaultProfiles

        java.lang.String[] getDefaultProfiles()
        Returns the set of profiles to be active by default when no active profiles have been set explicitly.
        Returns:
        the set of profiles to be active by default
      • acceptsProfiles

        boolean acceptsProfiles​(java.lang.String... profiles)
        Return whether one or more of the given profiles is active or, in the case of no explicit active profiles, whether one or more of the given profiles is included in the set of default profiles. If a profile begins with '!' the logic is inverted, i.e. the method will return true if the given profile is not active. For example,
        env.acceptsProfiles("p1", "!p2")
        will return true if profile 'p1' is active or 'p2' is not active.
        Parameters:
        profiles - the given profiles
        Returns:
        true if the given profile is active; false otherwise
        Throws:
        java.lang.IllegalArgumentException - if called with zero arguments or if any profile is null, empty or whitespace-only
        See Also:
        getActiveProfiles(), getDefaultProfiles()
      • getProperty

        <T> T getProperty​(java.lang.String name,
                          Activity activity)
        Returns the value of the property on environment via Activity.
        Type Parameters:
        T - the type of the value
        Parameters:
        name - the given property name
        activity - the current activity
        Returns:
        the value of the property on environment