All Downloads are FREE. Search and download functionalities are using the official Maven repository.

play.db.ebean.orm.ModelsConfigLoader Maven / Gradle / Ivy

The newest version!
package play.db.ebean.orm;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * Given a classloader, load the models configuration.
 * 

* This is used by the ebean sbt plugin to get the same * models configuration that will be loaded by the app. *

* * @since 15.04.30 */ public class ModelsConfigLoader implements Function>> { @Override public Map> apply(final ClassLoader classLoader) { final Map> datasourceModels = new HashMap<>(); final Config config = ConfigFactory.load(classLoader); if (config.hasPathOrNull("ebean.servers")) { final Config ebeanServersConfig = config.getConfig("ebean.servers"); ebeanServersConfig.root().keySet().forEach(serverName -> { final Config ebeanServerConfig = ebeanServersConfig.getConfig(serverName); if (ebeanServerConfig.hasPath("enhancement")) { datasourceModels.put( serverName, ebeanServerConfig.getStringList("enhancement") ); } }); } return datasourceModels; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy