本文整理汇总了Java中com.googlecode.objectify.ObjectifyService.run方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectifyService.run方法的具体用法?Java ObjectifyService.run怎么用?Java ObjectifyService.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.objectify.ObjectifyService
的用法示例。
在下文中一共展示了ObjectifyService.run方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bootstrapLocal
import com.googlecode.objectify.ObjectifyService; //导入方法依赖的package包/类
public void bootstrapLocal() {
Assert.isTrue(Environment.is(Environment.DEV), "This can only be run in a local dev environment");
logStart();
ObjectifyService.run(new VoidWork() {
@Override
public void vrun() {
// Your bootstrap methods go here. Tips: do a check and only bootstrap if data not there; and add logging so you know what happened.
createSuperUser();
}
});
logEnd();
}
示例2: run
import com.googlecode.objectify.ObjectifyService; //导入方法依赖的package包/类
@Override
public void run(String... args) throws Exception {
ObjectifyService.run(new VoidWork(){
@Override
public void vrun() {
for (int i=1; i<5; i++){
customerRepository.save(new Customer("Customer " + i, 25));
}
}
});
}
示例3: getIdType
import com.googlecode.objectify.ObjectifyService; //导入方法依赖的package包/类
@Override
public Class<ID> getIdType() {
return ObjectifyService.run(new Work<Class<ID>>(){
@Override
public Class<ID> run() {
EntityMetadata<T> entityMetadata = ofy().factory().getMetadata(getJavaType());
KeyMetadata<T> keyMetadata = entityMetadata.getKeyMetadata();
return (Class<ID>)keyMetadata.getIdFieldType();
}
});
}
示例4: run
import com.googlecode.objectify.ObjectifyService; //导入方法依赖的package包/类
/**
* Runs one unit of work, making the root Objectify context available.
* This does not start a transaction, but it makes the static ofy() method return an appropriate object.
* Equivalent to calling {@link ObjectifyService#run(Work)}.
*
* @param work Unit of work.
* @param <R> Result type.
* @return Result of running unit of work.
*/
default <R> R run(Work<R> work) {
return ObjectifyService.run(work);
}