Class ServerConfigEnvProps

java.lang.Object
com.iizix.prop.GProp<GProp<?>[]>
com.iizix.prop.PropCnr
com.iizix.server.prop.ServerConfigEnvProps
All Implemented Interfaces:
EventListener, IGProp<GProp<?>[]>, IPropCnr, IServerConfigEnvProps, Cloneable
Direct Known Subclasses:
EditorServerConfigEnvProps

public class ServerConfigEnvProps extends PropCnr implements IServerConfigEnvProps
This configuration environment defines the configuration setup for the available plug-ins. Several configuration environments may be present in a Server, e.g. "development", "test", "acceptance", "preproduction" and "production".

The environment owns the definitions of its applications (CC-FIX-APP-DEFINITIONS): the predefined ServerAppConfigs container Atom.APPS holds one ServerAppConfig per application. A file written before the container had the definitions as direct children of the environment; such a file still loads: the entries are moved into the container at load, one WARNING names the file and the entries, and the file is rewritten in the new layout when saved.

  • Field Details

    • ALLOW_PARALLEL_SESSIONS

      public static final String ALLOW_PARALLEL_SESSIONS
      Property name: Allow parallel sessions.
      See Also:
    • MAX_CLIENTS_PER_APP_SESSION

      public static final String MAX_CLIENTS_PER_APP_SESSION
      Property name: Max client sessions/app session.
      See Also:
    • APP_TIMEOUT

      public static final String APP_TIMEOUT
      Property name: App session timeout.
      See Also:
    • CUSTOM_APP_SETTINGS

      public static final String CUSTOM_APP_SETTINGS
      Property name: Custom app settings.
      See Also:
    • ALLOWED_DOMAINS

      public static final String ALLOWED_DOMAINS
      Property name: Allowed domains.
      See Also:
    • REQUIRE_TLS

      public static final String REQUIRE_TLS
      Property name: Require TLS.
      See Also:
    • KEY_GOOGLE_MAPS

      public static final String KEY_GOOGLE_MAPS
      The name of the property for Google Maps key: the key Browser clients of this environment's applications use, set in ServerAdmin's environment page or in the file; an application's definition (ServerAppConfig.KEY_GOOGLE_MAPS) and its distribution may carry a key of their own (CC-FIX-MAPS-KEY-SERVER).
      See Also:
  • Constructor Details

    • ServerConfigEnvProps

      public ServerConfigEnvProps()
      Creates the configuration environment properties without a name. The name must be set in all cases using the setPropertyAtom call.
    • ServerConfigEnvProps

      public ServerConfigEnvProps(Atom atom)
      Creates the configuration environment properties with an atom manager.
      Parameters:
      atom - The atom.
  • Method Details

    • clone

      public ServerConfigEnvProps clone()
      Creates a clone out of this property. The cloning is overridden by the subclasses in order to handle cloning of its class variables appropriately.
      Overrides:
      clone in class PropCnr
      Returns:
      A cloned instance.
    • onPropInvalidateCache

      protected void onPropInvalidateCache()
      Invalidates a potential cache in this property. This method is called during a synchronized state of the property.
      Overrides:
      onPropInvalidateCache in class GProp<GProp<?>[]>
    • createServerAppConfigs

      protected ServerAppConfigs createServerAppConfigs()
      Creates the applications container, overridden by the Designer version.
      Returns:
      A new container named Atom.APPS.
    • addPredefinedProps

      protected void addPredefinedProps() throws PropException
      Adds the predefined properties for this container: the applications container.
      Overrides:
      addPredefinedProps in class PropCnr
      Throws:
      PropException - for property exceptions.
    • getPredefinedProps

      protected void getPredefinedProps()
      Gets the references to the predefined properties after cloning or loading.
      Overrides:
      getPredefinedProps in class PropCnr
    • getServerAppConfigs

      public ServerAppConfigs getServerAppConfigs()
      Gets the applications container of this environment: the definitions of its applications.
      Returns:
      The container, never null.
    • convertLoadedProp

      protected GProp<?> convertLoadedProp(GProp<?> childProp) throws PropException
      Moves an application definition loaded as a direct child of the environment - the layout of a file written before the applications container - into the container (CC-FIX-APP-DEFINITIONS), and merges the predefined container's entries into a loaded container.
      Overrides:
      convertLoadedProp in class PropCnr
      Parameters:
      childProp - The child property that is about to be added.
      Returns:
      The property to add, null when it was moved into the container.
      Throws:
      PropException - for property errors.
    • onPropTreeInitialized

      public void onPropTreeInitialized() throws IOException, PropException
      Logs the one WARNING of a migrated file once the tree is loaded (CC-FIX-APP-DEFINITIONS).
      Specified by:
      onPropTreeInitialized in interface IGProp<GProp<?>[]>
      Overrides:
      onPropTreeInitialized in class PropCnr
      Throws:
      IOException - For file errors.
      PropException - When there is an initialization problem.
    • getConfigurationFileName

      protected String getConfigurationFileName()
      Gets the name of the configuration file this environment was loaded from, for the log: the server's configuration file; overridden by the Designer version.
      Returns:
      The file name, or null when unknown.
    • getDescription

      public String getDescription()
      Gets the description of this configuration environment.
      Returns:
      The description, or null for none.
    • getPluginConfigs

      public ServerPluginConfig[] getPluginConfigs()
      Gets the server plug-in configurations in the environment, normally one per plug-in type.
      Returns:
      A cached value.
    • getServerApplicationSetup

      public IServerApplicationSetupPropCnr[] getServerApplicationSetup(String pluginID)
      Gets the configuration setup's for a plug-in with specified ID. Each plug-in may present several configurations, although most commonly a single one.
      Parameters:
      pluginID - The plug-in ID.
      Returns:
      The configuration setup, or null if plug-in configuration is not found. If the plug-in is found but no configurations, an empty array is returned.
    • isUserParallelSessionsAllowed

      public boolean isUserParallelSessionsAllowed()
      Gets the flag indicating if a user is allowed to start multiple parallel sessions or if just one per user and app is allowed (default true).
      Returns:
      The allow flag.
    • getMaxClientsPerAppSession

      public int getMaxClientsPerAppSession()
      Gets the maximum number of clients sessions per app session, zero = no limit.
      Returns:
      The value, default zero.
    • getAppTimeout

      public long getAppTimeout()
      Gets the timeout before an app session is disposed of when no more client sessions are present, default 1 hour.
      Returns:
      The timeout value in milliseconds.
    • getCustomAppValue

      public String getCustomAppValue(String key)
      Gets a value for a key in the custom app properties.
      Parameters:
      key - The key or name of the property to retrieve.
      Returns:
      The value, or null if no value is defined for the key, or the custom map is not defined.
    • onAppSessionEndPoint

      public void onAppSessionEndPoint(EndPointPropCnr cnr, AppSessionGyro appGyro)
      Called when a new end point property container is added for a server monitor instance. This is delegated to the plug-ins in the application's server environment in order to enable them to add information for the application session.
      Parameters:
      cnr - The container for the end point.
      appGyro - The application session gyro of the end point.
    • getAllowedDomains

      public String getAllowedDomains()
      Gets the allowed domains that are allowed access to this environment.
      Returns:
      The domain name as e.g. "hello.example.com", or null if not associated with Let's Encrypt.
    • getAllowedDomainSet

      public Set<String> getAllowedDomainSet()
      Gets the different domain names as String set. The domains names set includes all defined domain names that are configured for this port.
      Returns:
      A new set of domain names.
    • isTLSRequired

      public boolean isTLSRequired()
      Returns if access to this environment requires TLS.
      Returns:
      true if secured, false if HTTP is accepted.
    • isDomainAccessAllowed

      public boolean isDomainAccessAllowed(String domain, boolean isSecure)
      Checks if a domain is allowed access to this environment. It is assumed that the caller of this method already has checked the validity of the 'host' header with the domain name from the URL.
      Parameters:
      domain - The domain name extracted from the URL.
      isSecure - Flag for session secured.
      Returns:
      true for access allowed, false for no access.
    • getKeyGoogleMaps

      public String getKeyGoogleMaps()
      Gets the key to use for Browser use of Google Maps: the environment's key, the fallback of every application of the environment (CC-FIX-MAPS-KEY-SERVER). The map component asks the application's distribution first (UIMap.onInitialize), which answers the key of the application's definition in this environment when the deployment set one, else the distribution's own key, and this one when neither has one. If none is found, a Browser client shows "Google Maps key not configured" in the map.
      Specified by:
      getKeyGoogleMaps in interface IServerConfigEnvProps
      Returns:
      The key for Google Maps, or null for none.
    • getKeyGoogleMaps

      public String getKeyGoogleMaps(String appID)
      Gets the key to use for Browser use of Google Maps by an application of this environment, as the configuration file alone decides it (CC-FIX-MAPS-KEY-SERVER): the key of the application's definition (ServerAppConfig.getKeyGoogleMaps()) when the deployment set one, else the environment's key. The application's distribution key, between the two for the map component, is not the file's.
      Parameters:
      appID - The application ID, null for none.
      Returns:
      The key for Google Maps, or null for none.
    • checkKeyGoogleMaps

      public static String checkKeyGoogleMaps(String key)
      Checks the shape of a Google Maps key, not that Google accepts it (CC-FIX-MAPS-KEY-SERVER): what ServerAdmin refuses a typed key with and what the verification of a definition reports. No key is not an error.
      Parameters:
      key - The key as typed, null or empty for none.
      Returns:
      The error text, or null when the key is of the shape of a key, or none.