common-configuration

Provides Spring config and ServerConfig necessary to support configuration

Лицензия

Лицензия

Категории

Категории

Configuration Библиотеки уровня приложения config
Группа

Группа

nz.ac.auckland.common
Идентификатор

Идентификатор

common-configuration
Последняя версия

Последняя версия

3.5
Дата

Дата

Тип

Тип

jar
Описание

Описание

common-configuration
Provides Spring config and ServerConfig necessary to support configuration
Ссылка на сайт

Ссылка на сайт

https://github.com/uoa-group-applications/common-configuration
Система контроля версий

Система контроля версий

https://github.com/uoa-group-applications/common-configuration

Скачать common-configuration

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/nz.ac.auckland.common/common-configuration/ -->
<dependency>
    <groupId>nz.ac.auckland.common</groupId>
    <artifactId>common-configuration</artifactId>
    <version>3.5</version>
</dependency>
// https://jarcasting.com/artifacts/nz.ac.auckland.common/common-configuration/
implementation 'nz.ac.auckland.common:common-configuration:3.5'
// https://jarcasting.com/artifacts/nz.ac.auckland.common/common-configuration/
implementation ("nz.ac.auckland.common:common-configuration:3.5")
'nz.ac.auckland.common:common-configuration:jar:3.5'
<dependency org="nz.ac.auckland.common" name="common-configuration" rev="3.5">
  <artifact name="common-configuration" type="jar" />
</dependency>
@Grapes(
@Grab(group='nz.ac.auckland.common', module='common-configuration', version='3.5')
)
libraryDependencies += "nz.ac.auckland.common" % "common-configuration" % "3.5"
[nz.ac.auckland.common/common-configuration "3.5"]

Зависимости

compile (5)

Идентификатор библиотеки Тип Версия
nz.ac.auckland.composite : composite-configuration jar [3.2,)
net.stickycode.configuration : sticky-configuration jar [1.5, 2)
nz.ac.auckland.composite : composite-spring jar [4,)
nz.ac.auckland.composite : composite-logging-api jar [2,)
commons-io : commons-io jar 2.4

provided (2)

Идентификатор библиотеки Тип Версия
nz.ac.auckland.composite : composite-servlet jar [1.3,)
nz.ac.auckland.composite : composite-spring-web jar [4,)

test (2)

Идентификатор библиотеки Тип Версия
nz.ac.auckland.composite : composite-unittest jar [2.4,3)
nz.ac.auckland.composite : composite-logging-deploy jar [3.4,)

Модули Проекта

Данный проект не имеет модулей.

commons-configuration

This provides a Spring scanned configuration file to support the @ConfigKey annotation from Sticky Code that injects System properties into your Spring objects.

e.g.

@UniversityComponent
class MyClass {
  @ConfigKey("person.name") String name
  @ConfigKey("person.age") Integer age
  @ConfigKey Boolean alive   // myclass.alive
  @ConfigKey List<String> aliases // myclass.aliases
  @ConfigKey Map<String, Integer> childrenAges  // myclass.childrenAges
}

in system properties you would have

person.name=fred
person.age=35
myClass.alive=true
myClass.aliases=The Hammer, Sooty, Sweep
myClass.childrenAges=Barbara:7, William:2

You can include in your class a @PostConfigured annotation to then do post processing on the configuration.

@UniversityComponent
class AlsoMyClass {
   @ConfigKey String parts = "gibberish"
   @ConfigKey String password


   @PostConfigured
   public void configure() {
     // do something here
   }
}

Configuration Sources

There are two - the Jar Manifest file is first, the System Properties are second. Jar Manifest's can't use keys with a "." in their name, so those are immediately skipped.

Alternatives

We can use the @Value annotation from Spring, but this has a number of "issues":

  • @Value annotated fields in base classes will not pull their configuration settings when the bean is configured
  • @Value requires you to specify where your properties are coming from, which generally is undesirable as the source of configuration is extensible.
  • @Value's default mechanism is clumsy, requiring error prone stringization of defaults

Web Usage

The artifact includes a web fragment, if included in a Servlet 3.x container, it will automatically be added to the global web.xml

Other Spring usage

Anyone using the Artifact outside of a web container will need to get the StickyBootstrap object and call "start" on it (see the StickyBootStrapServlet for an example).

Notes

  • if you don't give a default value and the user doesnt provide a value, the initialization of your application will immediately fail (FAST FAIL)

Applications using: pretty much everything

nz.ac.auckland.common

University of Auckland - Group Applications

MIT Licensed Java/Groovy libraries we use

Версии библиотеки

Версия
3.5
3.4
3.3
3.2
3.1
2.6