Parse startup parameters
Features
- supported types: int, String, File, boolean
- thread safe
- small library size, dependencies only on slf4j-api for logging
Setup with dependency managers
Maven
<dependency>
<groupId>com.payneteasy</groupId>
<artifactId>startup-parameters</artifactId>
<version>1.0-6</version>
</dependency>
Gradle
compile 'com.payneteasy:startup-parameters:1.0-6'
How to use
❶ Create an interface with parameters, see example
public interface IStartupConfig {
@AStartupParameter(name = "WEB_SERVER_PORT", value = "8083")
int webServerPort();
@AStartupParameter(name = "WEB_SERVER_CONTEXT", value = "/api")
String webServerContext();
@AStartupParameter(name = "REQUEST_LOG_DIR", value = "./logs")
File getRequestLogDir();
}
❷ Create an instance, see example
IStartupConfig startupConfig = StartupParametersFactory.getStartupParameters(IStartupConfig.class);
int port = startupConfig.webServerPort();
License
The Startup Parameters library is licensed under the Apache License 2.0