3.2.6.1. Configuration

API 文档

该接口有助于获取配置接口的引用。

例如:

  1. // field injection
  2. @Inject
  3. protected Configuration configuration;
  4. ...
  5. String tempDir = configuration.getConfig(GlobalConfig.class).getTempDir();
  1. // setter injection
  2. protected GlobalConfig globalConfig;
  3. @Inject
  4. public void setConfiguration(Configuration configuration) {
  5. this.globalConfig = configuration.getConfig(GlobalConfig.class);
  6. }
  1. // location
  2. String tempDir = AppBeans.get(Configuration.class).getConfig(GlobalConfig.class).getTempDir();