Skip to content

Instantly share code, notes, and snippets.

@bfuster
Created August 2, 2011 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bfuster/1121138 to your computer and use it in GitHub Desktop.
Save bfuster/1121138 to your computer and use it in GitHub Desktop.
@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