/** * A shortcut for {@code factory().register()} * * @see ObjectifyFactory#register(Class) */ public static void register(Class<?> clazz) { factory().register(clazz); }
/** @see ObjectifyFactory#register(Class) */ public static void register(Class<?> clazz) { factory().register(clazz); } }
public void afterPropertiesSet() throws Exception { if (this.logger.isInfoEnabled()) { this.logger.info("Initialization started"); } long startTime = System.currentTimeMillis(); if (classes == null) { classes = new ArrayList<Class<?>>(); } if (basePackage != null && basePackage.length() > 0) { classes.addAll(doScan()); } this.objectifyFactory = new ObjectifyFactory(); for (Class<?> clazz : classes) { this.objectifyFactory.register(clazz); if (this.logger.isInfoEnabled()) { this.logger.info("Registered entity class [" + clazz.getName() + "]"); } } if (this.logger.isInfoEnabled()) { long elapsedTime = System.currentTimeMillis() - startTime; this.logger.info("Initialization completed in " + elapsedTime + " ms"); } }
for (final Class<?> cls : this.entities) of.register(cls); L.debug("Registered {} with Objectify", cls.getName());
public void testBoolQuery() { ObjectifyFactory objectifyFactory = ObjectifyService.factory(); objectifyFactory.register(FakeEntity.class); Objectify objectify = objectifyFactory.begin(); FakeEntity entityFalse = new FakeEntity();
@Before public void setUp() throws Exception { // Don't call super.setUp because we initialize slightly differently // here... countdownLatch = new LocalTaskQueueTestConfig.TaskCountDownLatch(1); // See // http://www.ensor.cc/2010/11/unit-testing-named-queues-spring.html // NOTE: THE QUEUE XML PATH RELATIVE TO WEB APP ROOT, More info // below // http://stackoverflow.com/questions/11197058/testing-non-default-app-engine-task-queues final LocalTaskQueueTestConfig localTaskQueueConfig = new LocalTaskQueueTestConfig() .setDisableAutoTaskExecution(false).setQueueXmlPath("src/test/resources/queue.xml") .setTaskExecutionLatch(countdownLatch).setCallbackClass(DeleteShardedCounterDeferredCallback.class); // Use a different queue.xml for testing purposes helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig().setApplyAllHighRepJobPolicy(), new LocalMemcacheServiceTestConfig(), new LocalCapabilitiesServiceTestConfig(), localTaskQueueConfig); helper.setUp(); memcache = MemcacheServiceFactory.getMemcacheService(); capabilitiesService = CapabilitiesServiceFactory.getCapabilitiesService(); // New Objectify 5.1 Way. See https://groups.google.com/forum/#!topic/objectify-appengine/O4FHC_i7EGk this.session = ObjectifyService.begin(); // Enable Joda Translators JodaTimeTranslators.add(ObjectifyService.factory()); ObjectifyService.factory().register(CounterData.class); ObjectifyService.factory().register(CounterShardData.class); ObjectifyService.factory().register(CounterShardOperationData.class); shardedCounterServiceImpl = new ShardedCounterServiceImpl(); this.shardedCounterService = shardedCounterServiceImpl; }