public void onApplicationStart() {
List<Class> classes = Play.classloader.getAnnotatedClasses(NoSqlEntity.class);
if (classes.isEmpty())
return;
else if (NoSql.getEntityManagerFactory() != null) {
NoSqlEntityManagerFactory factory = NoSql.getEntityManagerFactory();
factory.rescan(classes, Play.classloader);
return;
}
Map<String, Object> props = new HashMap<String, Object>();
props.put(Bootstrap.LIST_OF_EXTRA_CLASSES_TO_SCAN_KEY, classes);
props.put(Bootstrap.AUTO_CREATE_KEY, "create");
for(java.util.Map.Entry<Object, Object> entry : Play.configuration.entrySet()) {
props.put((String) entry.getKey(), entry.getValue());
}
if (log.isInfoEnabled())
log.info("Initializing PlayORM...");
NoSqlEntityManagerFactory factory = Bootstrap.create(props, Play.classloader);
NoSql.setEntityManagerFactory(factory);
CassandraAppender.setFactory(factory);
}