object Configure
Provides access to application configuration resource
The application configuration is defined in the application.conf
file
stored in the application resource directory. The configuration
file is a superset of the JSON format. All JSON constructs are
supported (e.g. string, number, array, object, etc) along with
extensions like comments and environment variable substitution.
The Typesafe Config
library
is wrapped by this class and full details on the configuration file
format can be found in their
documentation.
The reason to wrap an existing library is to provide an interface
supporting a consistent return type using
Either[Error, A] .
Example configuration file:
server { # The interface the server should bind to for servicing requests. # The default value of 0.0.0.0 forces the server to bind to all # interfaces on the machine. interface = 0.0.0.0 interface = ${?SERVER_INTERFACE} # The port the server should bind to when accepting requests. The # default port used is 8000. port = 8000 port = ${?SERVER_PORT} }
The ${?variable}
construct indicates an environment variable should
be consulted for a value. If a value is found it overrides the default
setting.
Referential Transparency
The application configuration (stored in the resources/application.conf
file) is read once first accessed. It is then cached for the life of the
application. Hence the configuration definition itself is immutable.
When a setting is consulted and the setting depends on an environment
variable the environment is only read once and cached (via
System.getEnv()
). Since it is not possible change an environment
variable value (as the values are cached and Java does not provide
a mechanism to do so) the values are effectively immutable. Hence
referential transparency is enforced.
- Source
- Configure.scala
- Alphabetic
- By Inheritance
- Configure
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def apply(): Either[Error, Configure]
Provides access to underlying application configuration resource
Provides access to underlying application configuration resource
The first time a Configure is requested the application configuration resource is read and then cached. Subsequent calls return the cached resource enduring referential transparency and very fast execution.
Example:
val config = Configure()
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Documentation for the Axiell Utilities Project
Overview
The Axiell Utilities Project attempts to provide a small library of classes and object applicable to most Axiell developments. The library is not geared towards any one project and so should be useful for new projects as well as existing ones.
The library is based on a few simple principles, namely:
Package structure
The
package consists of a number of utilities, where each utility provides a single piece of functionality.com.axiell.util
Notable utilities are:
Configure
generic configuration reader allowing application settings defined as resources to be interrogated.Error
generic error handling class defining a locale independent error message along with details relating to the context of the error. The context may include an exception and other relevant values.Formatter
retrieves and formats a locale specific string from a specified resource bundle. The formatting is specified in aC
printf style.Implicits
implements implicit methods and classes used to pimp methods onto existing classes (e.g.fold()
method toBoolean
class) and to provide implicit implementations for the JsonLocal and ShowLocal type classes.JsonLocal
type class used to output locale specific JSON structures. Implementations exist for Message and Error.Message
provides a locale independent mechanism for handling strings. The strings for a given locale are stored in resource bundles that are accessed when the message is to be displayed.ShowLocal
type class used to show locale specific strings. Allows Message and Error to be converted to a given language string.Dependencies
The list of dependencies are:
Typesafe Config
a generic configuration file reader. The library is used by theConfigure
class to access settings stored as resources within an application.