Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back port module to enable ConfigProxyFactory for legacy archaius #401

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

elandau
Copy link
Contributor

@elandau elandau commented Apr 2, 2016

This change makes it possible to use ConfigProxyFactory with any application that still uses Archaius1 for its configuration. Libraries can now develop to the Archaius2 style of configuration using interfaces and ConfigProxyFactory to bind those interfaces to configuration.

To enable just install Archaius2BackportModule on the injector and add configuration interface bindings as you would with Archaius2. Note that Archacius2Backport is meant to be installed instead of ArchaiusModule and StaticArchaiusBridgeModule.

Note that there are a few minor restrictions here. This change does not add support for @ConfigurationSource annotations in applications still using Archaius1. For internal Netflix applications configuration classes would need to specify both @ConfigurationSource (for Archaius2) and @NFProperties (for Archaius1). @configuration is also not supported so library modules should specify the property prefix when creating a proxy instance.

For example,

// This is the library's configuration interface
@ConfigurationSource("myconfig")
@NFProperties("myconfig")
public interface MyConfig {
    int getSomeProperty();
}
// This is the library module that an application will need to install
public class MyConfigModule {
    @Override
    public void configure() {}

    @Provides
    @Singleton
    MyConfig getMyConfig(ConfigProxyFactory factory) {
        return factory.newProxy(MyConfig.class, "prefix");
    }
}

The above setup will load properties from 'myconfig.properties' into archaius and bind the properties

prefix.someProperty=123

@cloudbees-pull-request-builder

archaius-pull-requests #387 SUCCESS
This pull request looks good

@cloudbees-pull-request-builder

NetflixOSS » archaius » archaius-pull-requests #221 SUCCESS
This pull request looks good

@@ -38,6 +39,12 @@

public CommonsToConfig(AbstractConfiguration config) {
this.config = config;
config.addConfigurationListener(new ConfigurationListener() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really having hard time wrapping my head around all these re-directions. So we're adding a listener here to make sure whoever is depending on CommonsToConfig will have a chance to get notified when underneath config (Archaius1 AbstractConfiguration) changes? Only use case I can think of is one Archaius2 based library being based on another Archaius1 bridged Archaius2 library instead of just directly on the base Archaius1 config? Let me know if I'm wrong, but otherwise, I think we're overloading this bridge. The bridge should just bridge one Archaius1 AbstractConfiguration to another Archaius2 AbstractConfig.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants