Created
August 2, 2011 20:28
-
-
Save bfuster/1121138 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
@ApplicationScoped | |
public class DataStoreTemplateImpl implements DataStoreTemplate { | |
private static final Class<?>[] models = new Class<?>[] { | |
User.class, | |
Item.class, | |
Car.class, | |
Another.class | |
}; | |
static { | |
for (Class<?> m : models) | |
ObjectifyService.register(m); | |
} | |
private final Objectify ofy; | |
private final AsyncObjectify ofyAsync; | |
public DataStoreTemplateImpl() { | |
this.ofy = ObjectifyService.begin(); | |
this.ofyAsync = this.ofy.async(); | |
} | |
@Override | |
public <T> Key<T> save(T obj) { | |
return ofy.put(obj); | |
} | |
@Override | |
public <T> void saveAsync(T obj) { | |
ofyAsync.put(obj); | |
} | |
/* ... */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment