use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class SelectByIdTest method testSerializabilityWithHessian.
@Test
public void testSerializabilityWithHessian() throws Exception {
SelectById<Artist> o = SelectById.query(Artist.class, 5);
Object clone = HessianUtil.cloneViaClientServerSerialization(o, new EntityResolver());
assertTrue(clone instanceof SelectById);
SelectById<?> c1 = (SelectById<?>) clone;
assertNotSame(o, c1);
assertEquals(o.entityType, c1.entityType);
assertEquals(o.singleId, c1.singleId);
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class LifecycleCallbackEventHandlerTest method testDefaultListeners.
@Test
public void testDefaultListeners() {
LifecycleCallbackEventHandler map = new LifecycleCallbackEventHandler(new EntityResolver());
L1 l1 = new L1();
map.addDefaultListener(l1, "callback");
C1 c1 = new C1();
c1.setObjectId(new ObjectId("bogus"));
assertEquals(0, l1.entities.size());
map.performCallbacks(c1);
assertEquals(1, l1.entities.size());
assertTrue(l1.entities.contains(c1));
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class DefaultDbImportAction method existingTargetMap.
protected DataMap existingTargetMap(DbImportConfiguration configuration) throws IOException {
File file = configuration.getTargetDataMap();
if (file != null && file.exists() && file.canRead()) {
URLResource configurationResource = new URLResource(file.toURI().toURL());
DataMap dataMap = mapLoader.load(configurationResource);
dataMap.setNamespace(new EntityResolver(Collections.singleton(dataMap)));
dataMap.setConfigurationSource(configurationResource);
return dataMap;
}
return null;
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class OsgiDataDomainProvider method get.
@Override
public DataDomain get() throws ConfigurationException {
// here goes the class loading hack, temporarily setting application
// bundle ClassLoader to be a thread ClassLoader for runtime to start.
Thread thread = Thread.currentThread();
ClassLoader activeCl = thread.getContextClassLoader();
try {
// using fake package name... as long as it is not
// org.apache.cayenne, this do the right trick
thread.setContextClassLoader(classLoaderManager.getClassLoader("com/"));
DataDomain domain = super.get();
EntityResolver entityResolver = domain.getEntityResolver();
for (ObjEntity e : entityResolver.getObjEntities()) {
// it is not enough to just call 'getObjectClass()' on
// ClassDescriptor - there's an optimization that prevents full
// descriptor resolving... so calling some other method...
entityResolver.getClassDescriptor(e.getName()).getProperty("__dummy__");
entityResolver.getCallbackRegistry();
}
// this triggers callbacks initialization using thread class loader
entityResolver.getCallbackRegistry();
return domain;
} finally {
thread.setContextClassLoader(activeCl);
}
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class DefaultUpgradeService method loadProject.
protected ConfigurationTree<DataChannelDescriptor> loadProject(Resource resource) {
// Load Model back from the update XML
ConfigurationTree<DataChannelDescriptor> configurationTree = loader.load(resource);
// link all datamaps, or else we will lose cross-datamaps relationships
EntityResolver resolver = new EntityResolver();
for (DataMap dataMap : configurationTree.getRootNode().getDataMaps()) {
resolver.addDataMap(dataMap);
dataMap.setNamespace(resolver);
}
return configurationTree;
}
Aggregations