@Development and @Production for stage
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
When I want to have different configuration settings for development and for production I use the currentStage()
``` java
class MyModule extends AbstractModule {
@Override
protected void configure() {
if (currentStage() == Stage.DEVELOPMENT) {
bind(DataSource.class).toProvider(DevDataSourceProvider.class).in(Singleton.class);
} else {
bind(DataSource.class).toProvider(DataSourceProvider.class).in(Singleton.class);
}
}
}
```
But sometimes my providers are so simple that I write it directly on the module. Here I wish there was an annotation `@Development` to represent the `DEVELOPMENT` stage and a `@Production` for the `PRODUCTION` stage
``` java
class MyModule extends AbstractModule {
@Override
protected void configure() {
}
@Development
@Provides
DataSource provideDevDataSource() {}
@Production
@Provides
DataSource provideDataSource() {}
}
```
Or something like this
``` java
@Provides(Stage.DEVELOPMENT)
DataSource provideDevDataSource() {}
@Provides(Stage.PRODUCTION)
DataSource provideDataSource() {}
```
Thank you.
Contributor guide
Assessment
This issue has not been assessed yet.