Java Code Examples for com.googlecode.objectify.ObjectifyFactory

The following are top voted examples for showing how to use com.googlecode.objectify.ObjectifyFactory. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: nomulus   File: ObjectifyService.java   View source code 6 votes vote down vote up
/**
 * Performs static initialization for Objectify to register types and do other setup.
 *
 * <p>This method is non-idempotent, so it should only be called exactly once, which is achieved
 * by calling it from this class's static initializer block.
 */
private static void initOfyOnce() {
  // Set an ObjectifyFactory that uses our extended ObjectifyImpl.
  // The "false" argument means that we are not using the v5-style Objectify embedded entities.
  com.googlecode.objectify.ObjectifyService.setFactory(new ObjectifyFactory(false) {
    @Override
    public Objectify begin() {
      return new SessionKeyExposingObjectify(this);
    }

    @Override
    protected AsyncDatastoreService createRawAsyncDatastoreService(DatastoreServiceConfig cfg) {
      // In the unit test environment, wrap the Datastore service in a proxy that can be used to
      // examine the number of requests sent to Datastore.
      AsyncDatastoreService service = super.createRawAsyncDatastoreService(cfg);
      return RegistryEnvironment.get().equals(RegistryEnvironment.UNITTEST)
          ? new RequestCapturingAsyncDatastoreService(service)
          : service;
    }});

  // Translators must be registered before any entities can be registered.
  registerTranslators();
  registerEntityClasses(EntityClasses.ALL_CLASSES);
}
 
Example 2
Project: nomulus   File: OfyFilterTest.java   View source code 5 votes vote down vote up
@Before
public void before() {
  helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()).setUp();
  // Clear out the factory so that it requires re-registration on each test method.
  // Otherwise, static registration of types in one method would persist across methods.
  initOfy();
  factory = ObjectifyService.factory();
  ObjectifyService.setFactory(new ObjectifyFactory(false));
}
 
Example 3
Project: java-docs-samples   File: TicTacToeServletTest.java   View source code 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream = new ByteArrayInputStream(
      String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 4
Project: java-docs-samples   File: OpenedServletTest.java   View source code 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream = new ByteArrayInputStream(
      String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 5
Project: java-docs-samples   File: DeleteServletTest.java   View source code 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream = new ByteArrayInputStream(
      String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 6
Project: java-docs-samples   File: MoveServletTest.java   View source code 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream = new ByteArrayInputStream(
      String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 7
Project: java-docs-samples   File: TicTacToeServletTest.java   View source code 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream =
      new ByteArrayInputStream(String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 8
Project: java-docs-samples   File: OpenedServletTest.java   View source code 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream =
      new ByteArrayInputStream(String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 9
Project: java-docs-samples   File: DeleteServletTest.java   View source code 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream =
      new ByteArrayInputStream(String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 10
Project: java-docs-samples   File: MoveServletTest.java   View source code 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream =
      new ByteArrayInputStream(String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 11
Project: appengine-counter   File: IfCounterDataIndexable.java   View source code 5 votes vote down vote up
@Override
public void init(final ObjectifyFactory fact, final Field field)
{
	Preconditions.checkNotNull(fact);
	Preconditions.checkNotNull(field);

	// Store off the field for use in the matches method.
	this.field = field;
}
 
Example 12
Project: appengine-counter   File: IfCounterDataIndexableTest.java   View source code 5 votes vote down vote up
@Before
public void before() throws NoSuchFieldException
{
	this.fact = new ObjectifyFactory();

	this.numShardsField = CounterData.class.getDeclaredField("numShards");
	this.counterStatusField = CounterData.class.getDeclaredField("counterStatus");
	this.counterDescriptionField = CounterData.class.getDeclaredField("description");
	this.counterCountField = CounterGroupData.class.getDeclaredField("eventuallyConsistentCount");

	this.counterData = new CounterData("testCounterName", 3);
}
 
Example 13
Project: generator-thundr-gae-react   File: TestObjectify.java   View source code 4 votes vote down vote up
@Override
protected void addTranslators(ObjectifyFactory factory) {
    for (TranslatorFactory translatorFactory : ApplicationModule.objectifyTranslatorFactories()) {
        factory.getTranslators().add(translatorFactory);
    }
}
 
Example 14
Project: springboot-spwa-gae-demo   File: ObjectifyModule.java   View source code 4 votes vote down vote up
public static void addDefaultTranslators() {
    // register Objectify converter to convert between java.uil.Date and org.joda.time.DateTime
    ObjectifyFactory objectifyFactory = ObjectifyService.factory();
    JodaTimeTranslators.add(objectifyFactory);
    objectifyFactory.getTranslators().add(new UUIDTranslatorFactory());
}
 
Example 15
Project: springboot-spwa-gae-demo   File: SetupObjectify.java   View source code 4 votes vote down vote up
protected void addTranslators(ObjectifyFactory factory) {
}
 
Example 16
Project: springboot-spwa-gae-demo   File: SetupObjectify.java   View source code 4 votes vote down vote up
protected ObjectifyFactory newObjectifyFactory() {
    return new ObjectifyFactory();
}
 
Example 17
Project: googlecloud-techtalk   File: ObjectifyModule.java   View source code 4 votes vote down vote up
public static void addDefaultTranslators() {
    // register Objectify converter to convert between java.uil.Date and org.joda.time.DateTime
    ObjectifyFactory objectifyFactory = ObjectifyService.factory();
    JodaTimeTranslators.add(objectifyFactory);
    objectifyFactory.getTranslators().add(new UUIDTranslatorFactory());
}
 
Example 18
Project: googlecloud-techtalk   File: SetupObjectify.java   View source code 4 votes vote down vote up
protected void addTranslators(ObjectifyFactory factory) {
}
 
Example 19
Project: googlecloud-techtalk   File: SetupObjectify.java   View source code 4 votes vote down vote up
protected ObjectifyFactory newObjectifyFactory() {
    return new ObjectifyFactory();
}
 
Example 20
Project: AppleSeed   File: ObjectifyModule.java   View source code 4 votes vote down vote up
public static void addDefaultTranslators() {
    // register Objectify converter to convert between java.uil.Date and org.joda.time.DateTime
    ObjectifyFactory objectifyFactory = ObjectifyService.factory();
    JodaTimeTranslators.add(objectifyFactory);
    objectifyFactory.getTranslators().add(new UUIDTranslatorFactory());
}
 
Example 21
Project: AppleSeed   File: SetupObjectify.java   View source code 4 votes vote down vote up
protected void addTranslators(ObjectifyFactory factory) {
}
 
Example 22
Project: AppleSeed   File: SetupObjectify.java   View source code 4 votes vote down vote up
protected ObjectifyFactory newObjectifyFactory() {
    return new ObjectifyFactory();
}
 
Example 23
Project: iosched-reader   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 24
Project: smconf-android   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 25
Project: Capstone-Project   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 26
Project: sync   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 27
Project: 2015-Google-I-O-app   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 28
Project: cryptonomica   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 29
Project: MapatonAPI   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
	return ObjectifyService.factory();
}
 
Example 30
Project: nomulus   File: Ofy.java   View source code 4 votes vote down vote up
/** Returns the wrapped Objectify's ObjectifyFactory. */
public ObjectifyFactory factory() {
  return ofy().factory();
}
 
Example 31
Project: nomulus   File: SessionKeyExposingObjectify.java   View source code 4 votes vote down vote up
public SessionKeyExposingObjectify(ObjectifyFactory factory) {
  super(factory);
}
 
Example 32
Project: googleplayAPI   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 33
Project: android-push-manager   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 34
Project: moment-for-android-wear   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 35
Project: op_return   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 36
Project: listmaker   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 37
Project: triethocduongpho   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 38
Project: playtogether   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 39
Project: watchpresenter   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example 40
Project: saarang-iosched   File: OfyService.java   View source code 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}