com.googlecode.objectify.ObjectifyFactory Java Examples

The following examples show how to use com.googlecode.objectify.ObjectifyFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ObjectifyService.java    From nomulus with Apache License 2.0 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
Source File: DeleteServletTest.java    From java-docs-samples with Apache License 2.0 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 #3
Source File: IfCounterDataIndexableTest.java    From appengine-counter with Apache License 2.0 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 #4
Source File: IfCounterDataIndexable.java    From appengine-counter with Apache License 2.0 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 #5
Source File: MoveServletTest.java    From java-docs-samples with Apache License 2.0 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
Source File: OpenedServletTest.java    From java-docs-samples with Apache License 2.0 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
Source File: TicTacToeServletTest.java    From java-docs-samples with Apache License 2.0 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
Source File: OfyFilterTest.java    From nomulus with Apache License 2.0 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 #9
Source File: OfyService.java    From watchpresenter with Apache License 2.0 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example #10
Source File: OfyService.java    From divide with Apache License 2.0 4 votes vote down vote up
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example #11
Source File: SessionKeyExposingObjectify.java    From nomulus with Apache License 2.0 4 votes vote down vote up
public SessionKeyExposingObjectify(ObjectifyFactory factory) {
  super(factory);
}
 
Example #12
Source File: Ofy.java    From nomulus with Apache License 2.0 4 votes vote down vote up
/** Returns the wrapped Objectify's ObjectifyFactory. */
public ObjectifyFactory factory() {
  return ofy().factory();
}
 
Example #13
Source File: OfyService.java    From tech-gallery with Apache License 2.0 2 votes vote down vote up
/**
 * Method that returns the objectify factory reference.
 *
 * @return Objectify.
 */
public static ObjectifyFactory factory() {
  return ObjectifyService.factory();
}
 
Example #14
Source File: OfyService.java    From MobileShoppingAssistant-sample with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the Objectify factory service.
 * @return The factory service.
 */
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example #15
Source File: OfyService.java    From AdSearch_Endpoints with Apache License 2.0 2 votes vote down vote up
/**
 * Use this static method for getting the Objectify service factory.
 * @return ObjectifyFactory.
 */
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example #16
Source File: OfyService.java    From ud859 with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Use this static method for getting the Objectify service factory.
 * @return ObjectifyFactory.
 */
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example #17
Source File: OfyService.java    From ud859 with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Use this static method for getting the Objectify service factory.
 * @return ObjectifyFactory.
 */
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example #18
Source File: OfyService.java    From ud859 with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Use this static method for getting the Objectify service factory.
 * @return ObjectifyFactory.
 */
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example #19
Source File: OfyService.java    From ud859 with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Use this static method for getting the Objectify service factory.
 * @return ObjectifyFactory.
 */
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example #20
Source File: OfyService.java    From ud859 with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Use this static method for getting the Objectify service factory.
 * @return ObjectifyFactory.
 */
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}
 
Example #21
Source File: OfyService.java    From ud859 with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Use this static method for getting the Objectify service factory.
 * @return ObjectifyFactory.
 */
public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
}