com.groiss.util
Class Settings

java.lang.Object
  extended by com.groiss.util.Settings
All Implemented Interfaces:
Lifecycle, Service

public class Settings
extends java.lang.Object
implements Service

This class defines some settings of the server. The settings are read from the configuration file. This implies that the configuration must be loaded when this class is initialized.


Constructor Summary
Settings()
           
 
Method Summary
static java.util.List<java.io.File> getApplicationClasspath()
           
static java.util.Locale[] getAvailableLocales()
          Return the list of locales from the configuration.
static java.io.File getBaseDir()
          Return the base directory (from the configuration).
static java.util.List<java.io.File> getBootClasspath()
           
static java.lang.ClassLoader getClassLoader()
          Get the application class loader.
static java.util.List<java.io.File> getClasspath()
           
static NumberFormat getDecimalFormatter()
           
static NumberFormat getDecimalFormatter(java.lang.String maxDigitSettings, NumberFormat original)
          returns a NumberFormat where the max.
static NumberFormat getLocalNumberFormatter()
           
static ILogger getLogger()
          Get the logger.
static java.lang.String getServerId()
          Get the id of the server.
static MultiMap<java.lang.String,java.lang.String> getShadowedFiles()
          Checks the classpath for duplicate entries.
static java.util.List<java.io.File> getSystemClasspath()
           
static java.io.File getTempDir()
          Return the temporary directory (from the configuration).
 boolean isRunning()
          Ask the object if it has been started
static void log(java.lang.String s, int level)
          Write a message to the log.
static void logError(java.lang.Throwable err)
          Log an error
static void logError(java.lang.Throwable err, java.lang.String errHeader)
          Prints a header line and a stack trace for the given Error or Exception
 void reconfigure()
          Reconfigure gives the service the chance to react on configuration changes.
static void setAvailableLocales(java.util.Locale[] l)
          Change the list of locales.
static void setBaseDir(java.lang.String dir)
          Set the base directory.
static void setClassLoader(java.lang.ClassLoader cl)
          Set the application class loader.
static void setLogger(ILogger l)
          Set the logger.
 void shutdown()
          This method is called on shutdown.
 void startup()
          This method is called when the object is "started".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Settings

public Settings()
Method Detail

setClassLoader

public static void setClassLoader(java.lang.ClassLoader cl)
Set the application class loader.

Parameters:
cl - a class loader

getClassLoader

public static java.lang.ClassLoader getClassLoader()
Get the application class loader.

Returns:
a class loader

setLogger

public static void setLogger(ILogger l)
Set the logger.

Parameters:
l - an ILogger object.

getLogger

public static ILogger getLogger()
Get the logger.

Returns:
an ILogger

log

public static void log(java.lang.String s,
                       int level)
Write a message to the log. The message is written when the current log level is greater or equal the given level.

Parameters:
s - the message
level - the log level

logError

public static void logError(java.lang.Throwable err)
Log an error

Parameters:
err - a throwable.

logError

public static void logError(java.lang.Throwable err,
                            java.lang.String errHeader)
Prints a header line and a stack trace for the given Error or Exception

Parameters:
err - a throwable.
errHeader - the text for the header line

getBaseDir

public static java.io.File getBaseDir()
Return the base directory (from the configuration).

Returns:
a File object

getTempDir

public static java.io.File getTempDir()
Return the temporary directory (from the configuration).

Returns:
a File object

setBaseDir

public static void setBaseDir(java.lang.String dir)
Set the base directory.

Parameters:
dir - the directory path

getServerId

public static java.lang.String getServerId()
Get the id of the server.

Returns:
a string containing the server name

getAvailableLocales

public static java.util.Locale[] getAvailableLocales()
Return the list of locales from the configuration.

Returns:
an array of Locale objects

setAvailableLocales

public static void setAvailableLocales(java.util.Locale[] l)
Change the list of locales.

Parameters:
l - an array of Locale objects

getDecimalFormatter

public static NumberFormat getDecimalFormatter()

getLocalNumberFormatter

public static NumberFormat getLocalNumberFormatter()

startup

public void startup()
Description copied from interface: Lifecycle
This method is called when the object is "started".

Specified by:
startup in interface Lifecycle

shutdown

public void shutdown()
Description copied from interface: Lifecycle
This method is called on shutdown.

Specified by:
shutdown in interface Lifecycle

isRunning

public boolean isRunning()
Description copied from interface: Service
Ask the object if it has been started

Specified by:
isRunning in interface Service
Returns:
true if running.

reconfigure

public void reconfigure()
Description copied from interface: Service
Reconfigure gives the service the chance to react on configuration changes. Whenever the configuration is changed the ServiceManager calls this method for all managed services.

Specified by:
reconfigure in interface Service

getDecimalFormatter

public static NumberFormat getDecimalFormatter(java.lang.String maxDigitSettings,
                                               NumberFormat original)
returns a NumberFormat where the max. fraction and integer digits are set as defined in the passed parameter. all other settings are copied from the passed NumberFormat

Parameters:
maxDigitSettings - the settings for the max. fraction and integer digits. e.g. 18,8 means 8 integer digits and 8 fraction digits
original - the reference-number-format - all other settings are copied from this format

getShadowedFiles

public static MultiMap<java.lang.String,java.lang.String> getShadowedFiles()
Checks the classpath for duplicate entries.

Returns:
MultiMap containing all duplicate entries (key) and their occurances (value)

getBootClasspath

public static java.util.List<java.io.File> getBootClasspath()

getSystemClasspath

public static java.util.List<java.io.File> getSystemClasspath()

getApplicationClasspath

public static java.util.List<java.io.File> getApplicationClasspath()

getClasspath

public static java.util.List<java.io.File> getClasspath()


@enterprise 8.0.22989 Copyright © 2001-2017 Groiss Informatics GmbH. All Rights Reserved.