Skip to content

Conversation

@gmethvin
Copy link
Member

@gmethvin gmethvin commented Apr 7, 2016

  • Deprecate Java play.Configuration and prefer raw com.typesafe.config.Config.
  • Deprecate several methods in play.api.Configuration and prefer several methods currently on play.api.PlayConfig, including get[T: ConfigLoader] and getOptional[T: ConfigLoader] that use the ConfigLoader typeclass to load arbitrary types.
  • Replace several config uses in the codebase with the new versions and deprecate old methods using play.Configuration.

This fixes several API issues with the current classes:

  • The methods in the Configuration APIs don't promote the use of reference.conf to declare default values. This is not idiomatic Config usage.
  • play.api.Configuration has many apparently unnecessary that return Java types. Now there is one method that can be used with a typeclass to load any type you want.
  • play.Configuration provides little in terms of functionality over raw Config and is an unnecessary level of indirection.

* @param environment the database environment
* @return a data source backed by a connection pool
*/
public DataSource create(String name, Configuration configuration, Environment environment);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For binary compatibility reasons, we should keep a deprecated version of this create method. Default implementation can be used here to enable a easier transition:

@Deprecated
public DataSource create(String name, Configuration configuration, Environment environment);

default DataSource create(String name, Config config, Environment environment) {
    return create(name, new Configuration(config), environment);
}

Or the opposite use between the two methods using Configuration.underlying().

@marcospereira
Copy link
Member

@gmethvin I've had the impression that you are trying to keep compatibility here, so I made some comments regarding compatibility issues.

@gmethvin gmethvin added this to the 2.6.0 milestone Apr 7, 2016
@gmethvin
Copy link
Member Author

gmethvin commented Apr 7, 2016

@marcospereira This doesn't need to be binary compatible (it's going into 2.6.0) but the goal is that most code would just work upon upgrade, just with deprecation warnings.

@gmethvin gmethvin force-pushed the config branch 2 times, most recently from 7ae1244 to 0076b9f Compare April 7, 2016 23:10
@gmethvin
Copy link
Member Author

gmethvin commented Apr 8, 2016

The build is failing most likely because play-slick is using PlayConfig (it is private[play] so anything in the play namespace can use it). We should probably just update play-slick to not use PlayConfig anymore.

@gmethvin
Copy link
Member Author

gmethvin commented Apr 8, 2016

There was one error in the template build likely related to the fact that play-slick still uses PlayConfig. Since technically it is legal for anything in the play namespace to use PlayConfig I deprecated it for now and made all its methods delegate to Configuration. This way we can keep the templates working and decide later how we want to handle it.

@gmethvin
Copy link
Member Author

@marcospereira I think I managed to handle all significant migration issues. I've had to use different method names in GuiceApplicationBuilder but I think the new ones withModuleLoader and withConfigLoader are clearer anyway.

@marcospereira
Copy link
Member

@gmethvin LGTM. Please, rebase so I can merge it. :-)

@gmethvin gmethvin deleted the config branch May 2, 2016 08:21
@gmethvin gmethvin mentioned this pull request May 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants