All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.objectify.impl.ObjectifyImpl Maven / Gradle / Ivy

Go to download

*** THIS VERSION UPLOADED FOR USE WITH CEDAR-COMMON, TO AVOID DEPENDENCIES ON GOOGLE CODE-BASED MAVEN REPOSITORIES. *** The simplest convenient interface to the Google App Engine datastore

The newest version!
package com.googlecode.objectify.impl;

import java.util.Map;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.Transaction;
import com.googlecode.objectify.AsyncObjectify;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.NotFoundException;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.ObjectifyOpts;
import com.googlecode.objectify.Query;

/**
 * Implementation of the Objectify interface.  This actually just calls through to
 * the AsyncObjectify implementation and performs an immediate get().
 * 
 * @author Jeff Schnitzer 
 */
public class ObjectifyImpl implements Objectify
{
	/** Keep our original opts around so we can generate a DatastoreService when requested */
	protected ObjectifyOpts opts;
	
	/** This must be passed in */
	protected AsyncObjectifyImpl async;
	
	/**
	 * Note that this sets the pointer back to the synchronous version in AsyncObjectifyImpl.
	 */
	public ObjectifyImpl(ObjectifyOpts opts, AsyncObjectifyImpl async)
	{
		this.opts = opts;
		this.async = async;
		this.async.sync = this;
	}

	/* (non-Javadoc)
	 * @see com.google.code.objectify.Objectify#get(java.lang.Iterable)
	 */
	@Override
	public  Map, T> get(Iterable> keys)
	{
		return this.async.get(keys).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#get(com.googlecode.objectify.Key[])
	 */
	@Override
	public  Map, T> get(Key... keys)
	{
		return this.async.get(keys).get();
	}

	/* (non-Javadoc)
	 * @see com.google.code.objectify.Objectify#get(com.google.appengine.api.datastore.Key)
	 */
	@Override
	public  T get(Key key) throws NotFoundException
	{
		return this.async.get(key).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#get(java.lang.Class, long)
	 */
	@Override
	public  T get(Class clazz, long id) throws NotFoundException
	{
		return this.async.get(clazz, id).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#get(java.lang.Class, java.lang.String)
	 */
	@Override
	public  T get(Class clazz, String name) throws NotFoundException
	{
		return this.async.get(clazz, name).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#get(java.lang.Class, java.lang.Iterable)
	 */
	@Override
	public  Map get(Class clazz, Iterable ids)
	{
		return this.async.get(clazz, ids).get();
	}
	
	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#get(java.lang.Class, S[])
	 */
	@Override
	public  Map get(Class clazz, S... idsOrNames)
	{
		return this.async.get(clazz, idsOrNames).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#find(com.google.appengine.api.datastore.Key)
	 */
	@Override
	public  T find(Key key)
	{
		return this.async.find(key).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#find(java.lang.Class, long)
	 */
	@Override
	public  T find(Class clazz, long id)
	{
		return this.async.find(clazz, id).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#find(java.lang.Class, java.lang.String)
	 */
	@Override
	public  T find(Class clazz, String name)
	{
		return this.async.find(clazz, name).get();
	}

	/* (non-Javadoc)
	 * @see com.google.code.objectify.Objectify#put(java.lang.Object)
	 */
	@Override
	public  Key put(T obj)
	{
		return this.async.put(obj).get();
	}

	/* (non-Javadoc)
	 * @see com.google.code.objectify.Objectify#put(java.lang.Iterable)
	 */
	@Override
	public  Map, T> put(Iterable objs)
	{
		return this.async.put(objs).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#put(T[])
	 */
	@Override
	public  Map, T> put(T... objs)
	{
		return this.async.put(objs).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#delete(java.lang.Object[])
	 */
	@Override
	public void delete(Object... keysOrEntities)
	{
		this.async.delete(keysOrEntities).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#delete(java.lang.Class, long)
	 */
	@Override
	public  void delete(Class clazz, long id)
	{
		this.async.delete(clazz, id).get();
	}
	
	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#delete(Class, String)
	 */
	@Override
	public  void delete(Class clazz, String name)
	{
		this.async.delete(clazz, name).get();
	}

	/* (non-Javadoc)
	 * @see com.google.code.objectify.Objectify#delete(java.lang.Iterable)
	 */
	@Override
	public void delete(Iterable keysOrEntities)
	{
		this.async.delete(keysOrEntities).get();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#query()
	 */
	@Override
	public  Query query()
	{
		return this.async.query();
	}
	
	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#query(java.lang.Class)
	 */
	@Override
	public  Query query(Class clazz)
	{
		return this.async.query(clazz);
	}
	
	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#getTxn()
	 */
	@Override
	public Transaction getTxn()
	{
		return this.async.getTxn();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#getFactory()
	 */
	@Override
	public ObjectifyFactory getFactory()
	{
		return this.async.getFactory();
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#async()
	 */
	@Override
	public AsyncObjectify async()
	{
		return this.async;
	}

	/* (non-Javadoc)
	 * @see com.googlecode.objectify.Objectify#getDatastore()
	 */
	@Override
	public DatastoreService getDatastore()
	{
		return this.getFactory().getDatastoreService(this.opts);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy