本文整理匯總了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);
}