/**
* Registers the given model and controller with a database persister, getting the bucket name
* from the @Table annotation on the model.
*
* @param model
* @param controller
* @param stash
* @return
*/
public ModelController registerDbModel(Class<? extends Model> model, Class<? extends ModelController> controller, Class<? extends Stash> stash, String bucket) {
Table anno = model.getAnnotation(Table.class);
if (anno == null) {
throw new UsageException("A @Table annotation is required on the model " + model.getCanonicalName() + " in order to register it.");
}
bucket = or(bucket, anno.name());
String table = anno.name();
DataAccessRegistration registration = new DataAccessRegistration()
.setDatabaseBacked(true)
.setPersisterClass(DbPersister.class)
.setBucket(bucket)
.setTableName(table)
.setControllerClass(controller)
.setStashClass(stash)
.setModelClass(model);
return register(registration);
}
DataAccessRegistry.java 文件源码
java
阅读 40
收藏 0
点赞 0
评论 0
项目:stallion-core
作者:
评论列表
文章目录