MCPcopy Index your code
hub / github.com/Netflix/archaius

github.com/Netflix/archaius @v2.8.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.8.8 ↗ · + Follow
1,597 symbols 5,509 edges 172 files 248 documented · 16%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Archaius is a configuration library for accessing a mixture of static as well as dynamic configurations as a single configuration unit.

There are two key concepts to note:

  • Properties that can be read by your code.
  • Configurations that organize properties into objects you can bootstrap your application with.

Features

  • Lock-free property reads.
  • Dependency Injection (i.e., Guice) friendly so you don't have to rely on static code execution.

2.x Changes

  • Not backwards compatible with 1.x.
  • Clean separation of API and backing configurations (i.e. commons-configuration, typesafe-configuration, etc).
  • Minimal external dependencies.
  • Improved bootstrapping process that doesn't rely on class loading.

Getting Started

Archaius provides a set of specialized configuration classes that may be combined using com.netflix.archaius.api.config.CompositeConfig into a specific override structure.
Check out com.netflix.archaius.ProxyFactoryTest (under archaius2-core/test/java/) for an example on how to bootstrap a config and access dynamic properties from it.

Accessing configuration

All com.netflix.archaius.api.Config (under archaius2-api/) derived classes provide access to their underlying configuration via the numerous getString(), getInt(), getBoolean() methods.
In addition to basic primitives and collections Config will allow parsing to any type that has a constructor that takes a single String argument or a static valueOf(String.class) method.

Replacements

Archaius supports standard variable replacement syntax such as ${other.property.name}.

Configuration loaders

Archaius has a default built in loader for .properties files but can also be extended with custom property specifications such as HOCON. In addition multiple contextual overrides for a single configuration resource name may be derived using a com.netflix.archaius.api.CascadeStrategy. The strategy may also specify replacements from already loaded configurations (such as System and Environment properties).

Dynamic Properties

One of the core differentiators between Archaius and other configuration libraries is its support for dynamically changing configuration. Traditionally applications require a restart whenever configuration changes. This can result in unnecessary service interruption during minor configuration changes, such as timeout values. Through Archaius, code can have direct access to the most recent configuration without the need to restart. In addition, code can react to configuration changes by registering a change handler.

Dynamic configuration support is split into the configuration loading and property value resolution.

Configuration loading

When adding a DynamicConfig derived configuration CompositeConfig will automatically register for configuration change notifications and incorporate new values into the main configuration.
Archaius provides a base PollingDynamicConfig for use with configuration sources that are polled frequently to refresh the entire configuration snapshot. Implement Config directly for fine grained configuration sources, such as ZooKeeper, which support updates at the individual property granularity.

config.addConfig(new PollingDynamicConfig(
            "REMOTE", 
            new URLConfigReader("http://remoteconfigservice/snapshot"), 
            new FixedPollingStrategy(30, TimeUnit.SECONDS)) 

Property access

Use the Property API for optimized access to any property that is expected to be updated at runtime. Access to dynamic configuration follows two access patterns. The first (and most common) is to get the most recent value directly from a Property object.
Property optimizes caching of the resolved property value (from the hierarchy) and is much more efficient than calling the Config object for frequently accessed properties.
The second, and more advanced, access pattern is to react to property value changes via a com.netflix.archaius.api.PropertyListener.

To create a fast property factory using any Config as the source

DefaultPropertyFactory factory = DefaultPropertyFactory.from(config);

To create a com.netflix.archaius.api.Property object

Property<Integer> timeout = factory.getProperty("server.timeout").asInteger(DEFAULT_TIMEOUT_VALUE);

To access the cached property value

Thread.sleep(timeout.get());

To react to property change notification

Property<Integer> timeout = factory
    .getProperty("server.timeout")
    .asInteger() 
    .addListener(new PropertyListener<Integer>() {
        public void onChange(Integer value) {
            socket.setReadTimeout(value);
        }

        public void onError(Throwable error) {
        }
    });

Extension points exported contracts — how you extend this code

ConfigListener (Interface)
Listener for property updates. Due to the cascading nature of property value resolution there's not much value in speci [7 …
archaius2-api/src/main/java/com/netflix/archaius/api/ConfigListener.java
ScopedValueResolver (Interface)
Contract for resolving a list of ScopesValues into a single value. @author elandau [6 implementers]
archaius2-persisted2/src/main/java/com/netflix/archaius/persisted2/ScopedValueResolver.java
FailingError (Interface)
(no doc) [7 implementers]
archaius2-core/src/test/java/com/netflix/archaius/ProxyFactoryTest.java
DefaultMethodWithAnnotation (Interface)
(no doc) [7 implementers]
archaius2-guice/src/test/java/com/netflix/archaius/guice/ProxyTest.java
CascadeStrategy (Interface)
Strategy for determining a set of cascading resource names. The strategy will resolve a single resource name into an or [8 …
archaius2-api/src/main/java/com/netflix/archaius/api/CascadeStrategy.java
ScopePredicate (Interface)
Predicate for excluding properties that are no in scope @author elandau [5 implementers]
archaius2-persisted2/src/main/java/com/netflix/archaius/persisted2/ScopePredicate.java
ListenerUpdater (Interface)
(no doc) [2 implementers]
archaius2-core/src/main/java/com/netflix/archaius/property/ListenerManager.java
MySubConfig (Interface)
(no doc) [2 implementers]
archaius2-guice/src/test/java/com/netflix/archaius/guice/ProxyTest.java

Core symbols most depended-on inside this repo

get
called by 338
archaius2-api/src/main/java/com/netflix/archaius/api/Config.java
put
called by 243
archaius2-core/src/main/java/com/netflix/archaius/ReadOnlyMap.java
setProperty
called by 172
archaius2-api/src/main/java/com/netflix/archaius/api/config/SettableConfig.java
build
called by 106
archaius2-core/src/main/java/com/netflix/archaius/config/MapConfig.java
getString
called by 87
archaius2-api/src/main/java/com/netflix/archaius/api/Config.java
builder
called by 78
archaius2-core/src/main/java/com/netflix/archaius/config/MapConfig.java
decode
called by 64
archaius2-api/src/main/java/com/netflix/archaius/api/Decoder.java
getName
called by 57
archaius2-api/src/main/java/com/netflix/archaius/api/PropertySource.java

Shape

Method 1,347
Class 184
Interface 63
Enum 3

Languages

Java100%

Modules by API surface

archaius2-core/src/test/java/com/netflix/archaius/ProxyFactoryTest.java106 symbols
archaius2-core/src/main/java/com/netflix/archaius/DefaultPropertyFactory.java54 symbols
archaius2-core/src/test/java/com/netflix/archaius/property/PropertyTest.java48 symbols
archaius2-core/src/main/java/com/netflix/archaius/config/AbstractConfig.java47 symbols
archaius2-core/src/test/java/com/netflix/archaius/mapper/ProxyFactoryTest.java44 symbols
archaius2-core/src/main/java/com/netflix/archaius/config/DefaultCompositeConfig.java36 symbols
archaius2-core/src/main/java/com/netflix/archaius/ConfigProxyFactory.java34 symbols
archaius2-api/src/main/java/com/netflix/archaius/api/Config.java34 symbols
archaius2-test/src/main/java/com/netflix/archaius/test/Archaius2TestConfig.java33 symbols
archaius2-guice/src/test/java/com/netflix/archaius/guice/ArchaiusModuleTest.java33 symbols
archaius2-core/src/test/java/com/netflix/archaius/config/MapConfigTest.java33 symbols
archaius2-core/src/main/java/com/netflix/archaius/property/DefaultPropertyContainer.java30 symbols

For agents

$ claude mcp add archaius \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact