Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load initial data in Play 2.0+

I'm creating a Play framework application, and I need to load in some data. The framework (I've done some work with it when it was at 1.2.4, and now I've been trying out 2.0.3) used to support the creation of a data.yaml file, which could be loaded in on runtime.

Support for this appears to have been dropped. What is the best practice for going about this now?

like image 384
chuuk Avatar asked Aug 17 '12 20:08

chuuk


1 Answers

Nope, it wasn't dropped, just refactored. The main weight was moved to the the Global object and its onStart() method.

Using it you can perform common DB operations as well you can also load and traverse any YAML file. Check the Zentasks sample to see how to use it in your own app (especially: app/Global.java, conf/initial-data.yml); for instance, from the sample:

Map<String,List<Object>> all = (Map<String,List<Object>>)Yaml.load("initial-data.yml");

It's just beginning! Using Global object depends only on your imaginary!

like image 71
biesior Avatar answered Nov 16 '22 08:11

biesior