This library allows your GAE/Java application to selectively execute datastore operations against a remote service. At the moment this only works against Appscale applications or other remote API service providers which return keys that match the appid of the calling application.
Despite the name, this library does not depend on Objectify in any way. It is, however, convenient to use with Objectify.
https://github.com/stickfigure/objectify-remotely
When you install the remote API, all GAE service calls go to the remote server. Objectify-remotely limits this to only datastore operations; used in conjunction with Objectify (or other tools), your application can continue to use local memcache and other services while shunting only datastore operations to the remote service.
<dependencies>
<dependency>
<groupId>com.googlecode.objectify</groupId>
<artifactId>objectify-remotely</artifactId>
<version>${objectify-remotely.version}</version>
</dependency>
</dependencies>
You will need to implement the callback that Remotely will use to determine whether calls should be made remotely.
RemoteApiOptions options = new RemoteApiOptions()
.server("remote.example.com", 443)
.credentials("user", "password");
RemoteCheck check = new RemoteCheck() {
public boolean isRemote(String namespace) {
return namespace.equals("remotestuffnamespace");
}
};
Remotely remotely = new Remotely(options, check);
If you are using the low level API directly, wrap your AsyncDatastoreService
. Note that each instance of
the AsyncDatastoreService
is permanently either remote or not; you should create and intercept new AsyncDatastoreService
instances for every action.
AsyncDatastoreService raw = DatastoreServiceFactory.getAsyncDatastoreService();
AsyncDatastoreService myService = remotely.intercept(raw);
// myService will be a remote service or a local service depending on the check
If you are using Objectify, subclass ObjectifyFactory
and override this method:
@Override
protected AsyncDatastoreService createRawAsyncDatastoreService(DatastoreServiceConfig cfg) {
AsyncDatastoreService raw = super.createRawAsyncDatastoreService(cfg);
return remotely.intercept(raw);
}
If you have questions, ask on the Objectify Google Group:
http://groups.google.com/group/objectify-appengine
Released under the MIT License.
Huge thanks to BetterCloud (http://www.bettercloud.com/) for funding this project!