List<Class> classEmbeddables = Play.classloader.getAnnotatedClasses(NoSqlEmbeddable.class);
classes.addAll(classEmbeddables);
if (classes.isEmpty())
return;
else if (NoSql.getEntityManagerFactory() != null) {
NoSqlEntityManagerFactory factory = NoSql.getEntityManagerFactory();
factory.rescan(classes, Play.classloader);
return;
}
Class<?> clazz = null;
try {
clazz = Play.classloader.loadClass("nosql.NoSqlConfigImpl");
if(NoSqlConfig.class.isAssignableFrom(clazz)) {
NoSqlConfig config = (NoSqlConfig) clazz.newInstance();
config.configure(PROPS);
} else {
log.warn("We found a class="+clazz+" to use to configure playorm but it did not implement NoSqlConfig interface so we can't use it");
}
} catch (ClassNotFoundException e) {
log.info("nosql.NoSqlConfigImpl not found so not instantiating and calling configure to do custom configuration of playorm");
//ignore then
} catch (InstantiationException e) {
log.warn("Exception, could not instantiate="+clazz, e);
} catch (IllegalAccessException e) {
log.warn("Exception, could not instantiate="+clazz, e);
}
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);
}