CGLibLazyProxyFactory implements LazyProxyFactory { public <T> T createProxy(final Class<T> targetClass, final Key<T> key, final DatastoreProvider p) { SerializableEntityObjectReference objectReference = new SerializableEntityObjectReference( targetClass, p, key); T backend = (T) new NonFinalizingHotSwappingInvoker(new Class[] { targetClass, Serializable.class }, factory, objectReference, DelegationMode.SIGNATURE).proxy(); T proxy = Dispatching.proxy(targetClass, new Class[] { ProxiedEntityReference.class, targetClass, Serializable.class }).with(objectReference, backend).build(factory); return proxy; } CGLibLazyProxyFactory(); T createProxy(final Class<T> targetClass, final Key<T> key,
			final DatastoreProvider p); T createListProxy(final T listToProxy,
			final Class referenceObjClass, final boolean ignoreMissing,
			final DatastoreProvider p); T createMapProxy(final T mapToProxy,
			final Class referenceObjClass, final boolean ignoreMissing,
			final DatastoreProvider p);  }
@Test public final void testCreateProxy() { if (!LazyFeatureDependencies.testDependencyFullFilled()) { return; } final E e = new E(); e.setFoo("bar"); final Key<E> key = ds.save(e); E eProxy = new CGLibLazyProxyFactory().createProxy(E.class, key, new DefaultDatastoreProvider()); assertNotFetched(eProxy); Assert.assertEquals("bar", eProxy.getFoo()); assertFetched(eProxy); eProxy = deserialize(eProxy); assertNotFetched(eProxy); Assert.assertEquals("bar", eProxy.getFoo()); assertFetched(eProxy); }