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

Archaius 0.x to Archaius 2 migration help request #500

Open
Crystark opened this issue Jun 28, 2017 · 1 comment
Open

Archaius 0.x to Archaius 2 migration help request #500

Crystark opened this issue Jun 28, 2017 · 1 comment

Comments

@Crystark
Copy link

Hi,

We've been working with Archaius 0.x for over 3 years now and have always been very pleased with it.
We're starting a new project so I wanted to update archaius to the latest 2.x version.

However, the API seems to have changed ALOT and i'm really not sure how to adapt to this. First, I haven't been able to understand the new Archaius 2 approach for now. Second, I'm not sure if we can reproduce the same behavior we had with archaius 0.7.5.

Here's what we used:

  • An empty config.properties file that was just there so that Archaius finds it when we initialize it.
  • The following app-specific config files:
    • app.properties
    • app-user.properties
    • app-dev.properties
      • Would contain @next=app-user.properties
    • app-prod.properties

At runtime we would use

java \
  -Darchaius.deployment.environment=dev \
  -Darchaius.configurationSource.additionalUrls=http://myhost/override.properties \
  -Darchaius.fixedDelayPollingScheduler.initialDelayMills=5000 \
  -Darchaius.fixedDelayPollingScheduler.delayMills=10000 \
  -jar my.jar

The code would the look like this:

private static DynamicPropertyFactory	I = DynamicPropertyFactory.getInstance();

static {
	try {
		ConfigurationManager.loadAppOverrideProperties("app");
	} catch (IOException e) {
		logger.error(e.getMessage(), e);
		throw new RuntimeException(e);
	}
	String env = ConfigurationManager.getDeploymentContext().getDeploymentEnvironment();
	if (env == null) {
		String err = "You need to define -Darchaius.deployment.environment=env";
		logger.error(err);
		throw new RuntimeException(err);
	}
	else {
		logger.info("Environnement: " + env);
	}
}

public final DynamicStringProperty		name;

private MyConfig(String prefix, IConfig defaultConfig) {
	this.name = F.getStringProperty(prefix + "name", defaultConfig.getName());
}

We only use override properties cause that's what works for us. When we pull various project, we also initialized the override with the config from the new project (e.g. ConfigurationManager.loadAppOverrideProperties("app2") to load app2.properties)

What we would like to keep is:

  • Dynamic properties reloaded at runtime
  • Possibility to easily override any conf through a couple external URLs (file:// and http://)
  • Environment-specific configuration files

Can anyone help me with this migration and point me in the right direction ?

I'm also interested in the guice intergration as we're also using it but that's secondary.
Thanks

@TheXs
Copy link

TheXs commented Jul 26, 2020

Same problem here. Any comment?

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

No branches or pull requests

2 participants