use of com.blazebit.persistence.view.impl.proxy.ProxyFactory in project blaze-persistence by Blazebit.
the class AbstractEntityViewTest method build.
public EntityViewManager build(EntityViewConfiguration cfg, Class<?>... classes) {
for (Class<?> c : classes) {
cfg.addEntityView(c);
}
EntityViewManagerFactoryCacheKey cacheKey = new EntityViewManagerFactoryCacheKey(cbf, cfg);
EntityViewManager evm;
if ((evm = evmCache.get(cacheKey)) == null) {
evm = build0(cfg, classes);
evmCache.put(cacheKey, evm);
}
AbstractEntityViewTest.evm = evm;
PackageOpener packageOpener = cbf.getService(PackageOpener.class);
boolean unsafeDisabled = !Boolean.valueOf(String.valueOf(cfg.getProperty(ConfigurationProperties.PROXY_UNSAFE_ALLOWED)));
boolean strictCascadingCheck = Boolean.valueOf(String.valueOf(cfg.getProperty(ConfigurationProperties.UPDATER_STRICT_CASCADING_CHECK)));
ProxyFactoryCacheKey proxyFactoryCacheKey = new ProxyFactoryCacheKey(unsafeDisabled, strictCascadingCheck, packageOpener);
ProxyFactory proxyFactory;
if ((proxyFactory = proxyFactoryCache.get(proxyFactoryCacheKey)) == null) {
proxyFactoryCache.put(proxyFactoryCacheKey, ((EntityViewManagerImpl) evm).getProxyFactory());
} else {
try {
Field proxyFactoryField = EntityViewManagerImpl.class.getDeclaredField("proxyFactory");
proxyFactoryField.setAccessible(true);
proxyFactoryField.set(evm, proxyFactory);
boolean scanStaticImplementations = !Boolean.valueOf(String.valueOf(cfg.getProperty(ConfigurationProperties.STATIC_IMPLEMENTATION_SCANNING_DISABLED)));
for (ManagedViewType<?> managedView : evm.getMetamodel().getManagedViews()) {
Class<?> javaType = managedView.getJavaType();
if (!javaType.isInterface() && !Modifier.isAbstract(javaType.getModifiers())) {
proxyFactory.setImplementation(javaType);
} else if (scanStaticImplementations) {
proxyFactory.loadImplementation(new HashSet<>(), managedView, evm);
}
}
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return evm;
}
Aggregations