Class Configuration

java.lang.Object
com.groiss.component.Configuration
All Implemented Interfaces:
Cloneable

public class Configuration extends Object implements Cloneable
This class handles the access to the configuration. There are two types of configurations: the configuration of @enterprise and the configuration of the applications. On startup @enterprise reads the configuration files and keeps the contents in memory. For access to the system configuration use Configuration.get(). For accessing the configuration of an application use Configuration.get("appl-id").

A configuration object contains the map between parameter names and values.

  • Field Details

  • Method Details

    • getChangedAt

      public Date getChangedAt()
    • isAmendedProperty

      public boolean isAmendedProperty(String name)
    • create

      public static Configuration create(String id)
      Add a configuration to the internal map of configurations. This is called on startup for the system configuration and the application configurations.
      Parameters:
      id - the id of the application
      Returns:
      a new Configuration object
    • get

      public static Configuration get(String id)
      Get the configuration by the given id.
      Parameters:
      id - the id of the configuration, normally the id of an application.
      Returns:
      a Configuration object
    • getConfigurations

      public static Map<String,Configuration> getConfigurations()
      Return the whole map of configurations.
      Returns:
      a map
    • get

      public static Configuration get()
      Return the @enterprise configuration.
      Returns:
      the configuration object.
    • remove

      public static Configuration remove(String id)
      Remove a configuration. The "avw" configuration cannot be removed. Intended to be used solely internally.
      Parameters:
      id - the id of the configuration to be removed
      Returns:
      the removed configuration or null if it could not be found
    • setResource

      public void setResource(Resource res)
      Set a resource for internationalization of this configuration. The resource of the application configuration objects is set to the application resource on startup.
      Parameters:
      res - a resource object
    • getResource

      public Resource getResource()
      Return the resource for this configuration.
      Returns:
      a resource or null if none is set.
    • restartList

      public List<String> restartList()
    • setVisibility

      public void setVisibility(String paramGroupId, boolean visible)
      Set the visibility of a parameter group in the configuration
      Parameters:
      paramGroupId - the id of the group
      visible - the new visibility
    • getDefinition

      public Element getDefinition()
      Return the definition of a configuration.
      Returns:
      the root node of the definition as JDOM Element
    • setPropFile

      public void setPropFile(String url)
      Set the url for the description file for the configuration.
      Parameters:
      url -
    • addParameterGroup

      public void addParameterGroup(String s)
      Parameters:
      s -
    • addPropertiesChangeListener

      public void addPropertiesChangeListener(PropertiesChangeListener l, String... props)
    • needsRestart

      public boolean needsRestart(String param)
      Returns true if the property change needs a server restart to become effective.
      Parameters:
      param - name of the property
      Returns:
      true if restart is necessary
    • allowOnClient

      public boolean allowOnClient(String param)
      Returns true if this property may be send to the smartclient via ep/config
      Parameters:
      param - name of the property
      Returns:
      true if restart is necessary
    • load

      public boolean load() throws IOException
      Load or reload the configuration.
      Returns:
      true if file was found
      Throws:
      IOException
    • getAmendedProperties

      public Properties getAmendedProperties()
    • getFileTime

      public static long getFileTime(File file) throws IOException
      Throws:
      IOException
    • reload

      public boolean reload() throws IOException
      Reload the configuration from the configured files.
      Throws:
      IOException
    • convertType

      public static Object convertType(Class<?> type, String key, String value)
      converts the string value to the specified data-type
      Parameters:
      type - target-type
      key - property-id
      value - property-value
      Returns:
    • loadDefinition

      public void loadDefinition()
    • loadTopLevel

      public static void loadTopLevel(String fileNames) throws IOException
      Load the main configuration.
      Throws:
      IOException
    • setSystemProps

      @Deprecated public void setSystemProps()
      Deprecated.
      since @ep9.0
      Copy all properties of this configuration into the system properties.
    • getFileName

      public String getFileName()
      Return the file name the configuration is loaded from.
      Returns:
      a path name
    • getFiles

      public List<File> getFiles()
    • setFileName

      public void setFileName(String filename)
      Set the file name for the configuration. The file name is used when the configuration is stored.
      Parameters:
      filename -
    • getId

      public String getId()
      Return the id of this configuration.
      Returns:
      a string
    • getPropertiesStartingWith

      public Properties getPropertiesStartingWith(String prefix)
      Returns the subset of properties with names that start with a given prefix.
      Parameters:
      prefix - the prefix to search for
      Returns:
      the matching properties
    • getPropertyAsProperties

      public Properties getPropertyAsProperties(String name)
      Returns the value of the (multi-valued) property with the given name in the form of a property. If there is no property with this name the method returns null.
      Parameters:
      name - name of a property
      Returns:
      the value of the specified property as Property Object or null if the configuration entry is either not found or empty.
    • getProperty

      public String getProperty(String name)
      Returns the value of the property with the given name. If there is no property with this name the method returns null. If the property value is not of type string the method toString() is called on it.
      Parameters:
      name - name of a property
      Returns:
      the value
    • getProperty

      @Deprecated public String getProperty(String name, String defValue)
      Deprecated.
      define default values in the xml decsription of the configuration.
      Returns the value of the specified configuration key or the defValue, if the configuration entry is not found.
      Parameters:
      name - the configuration entry key
      defValue - the default value
      Returns:
      the value of the specified configuration key or the defValue, if the configuration entry is not found.
    • getBoolean

      public boolean getBoolean(String name)
      Return the property value as boolean.
      Parameters:
      name - the name of the property
      Returns:
      the value casted to boolean, if value is not present, false is returned.
    • getInt

      public Integer getInt(String name)
      Return the property value as Integer. If the property is of type Duration, this method returns the time in seconds.
      Parameters:
      name - the name of the property
      Returns:
      the value casted to Integer
    • getLong

      public Long getLong(String name)
      Return the property value as Long. If the property is of type Duration, this method returns the time in seconds.
      Parameters:
      name - the name of the property
      Returns:
      the value casted to Long
    • getFloat

      public Float getFloat(String name)
      Return the property value as Float.
      Parameters:
      name - the name of the property
      Returns:
      the value casted to Float
    • getDouble

      public Double getDouble(String name)
      Return the property value as Double.
      Parameters:
      name - the name of the property
      Returns:
      the value casted to Double
    • getClass

      public Class<?> getClass(String name)
      Return the property value as class.
      Parameters:
      name - the name of the property
      Returns:
      the value casted to Class
    • getDate

      public Date getDate(String name)
    • getDuration

      public Duration getDuration(String name)
      Return the property value as Duration.
      Parameters:
      name - the name of the property
      Returns:
      the value parsed to Duration
    • getObject

      public Object getObject(String name)
      Return the property value.
      Parameters:
      name - the name of the property
      Returns:
      the value without any conversion
    • getList

      public List<String> getList(String name)
      Return the parameter as list. Parameter type must be string, separators are space, tab, newline, comma.
      Parameters:
      name - the name of the property
    • setProperty

      public void setProperty(String name, String value)
      Set a property to a value.
      Parameters:
      name - the name of the property
      value - the value string
    • setProperty

      public void setProperty(String name, Object value)
      Set a property to a value.
      Parameters:
      name - the name of the property
      value - the value object
    • isPasswordProperty

      public boolean isPasswordProperty(String name)
    • getPasswordProperty

      public String getPasswordProperty(String name)
      Get the value of a "mangled" property.
      Parameters:
      name -
      Returns:
      the plain value
    • getType

      public Class<?> getType(String name)
      Return the type of the given property.
      Parameters:
      name - the name of the property
      Returns:
      the type
    • getLabel

      public String getLabel(String name)
      Return the label of the given property.
      Parameters:
      name - the name of the property
      Returns:
      the label
    • getFile

      public File getFile(String propname)
      return the file of the property, if the property is not yet in a file we return the last file - this is the one where it will be stored.
      Parameters:
      propname -
    • getDefaultValue

      public Object getDefaultValue(String propname)
    • setProperties

      protected void setProperties(Properties props)
    • store

      public void store()
    • valToString

      public static String valToString(Object value)
      Convert a value from the configuration to a string. The method converts null to the empty string, returns the classname for classes and calls toString() to all other values. Moreover it calls trim() on the result.
      Parameters:
      value - an object
      Returns:
      a string representation of a configuration value
    • mansch

      @Deprecated public static String mansch(String arg)
      Deprecated.
      This method makes a string unreadable. Is is used to store passwords in a configuration file. It is not an encryption but is much better than storing the value unchanged.
    • demansch

      @Deprecated public static String demansch(String arg)
      Deprecated.
      Inverse function to mansch.
    • getProperties

      public Properties getProperties()
      Return the whole parameter map.
      Returns:
      a Properties object
    • saveConvert

      public static String saveConvert(String theString, boolean escapeSpace)
    • getClientParams

      public Set<String> getClientParams()
      returns all property names which are allowed to be used on the html-client
      Returns: