What's the right way to pass some configuration parameters to a module that I wrote for neo4j + GraphAware? I believe there should be a way that I can put some config entries in neo4j.conf and read them in my module's code but so far I could not find it.
There is definitely a possibility to pass configuration parameters to your module.
The best way is to look at other modules that use such configuration, GraphAware not being shy to open source modules (https://github.com/graphaware?utf8=%E2%9C%93&q=&type=&language=java) you can find plenty of it.
Let's take the uuid-module as an example :
In the bootstrapper class, you will find the logic for reading configuration parameters from the config file :
String uuidProperty = config.get(UUID_PROPERTY);
if (StringUtils.isNotBlank(uuidProperty)) {
configuration = configuration.withUuidProperty(uuidProperty);
LOG.info("uuidProperty set to %s", configuration.getUuidProperty());
}
The found parameters are used to create an immutable Configuration class :
The end of the module bootstrapping will then pass the configuration object to the constructor of the module :
return new UuidModule(moduleId, configuration, database);
You can then use this module with the configuration :
public UuidModule(String moduleId, UuidConfiguration configuration, GraphDatabaseService database) {
super(moduleId);
this.uuidConfiguration = configuration;
this.uuidGenerator = instantiateUuidGenerator(configuration, database);
this.uuidIndexer = new LegacyIndexer(database, configuration);
}