Skip to content

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

@Crystark

Description

@Crystark

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions