Java 类org.hibernate.cache.spi.entry.StandardCacheEntryImpl 实例源码

项目:hazelcast-hibernate5    文件:HibernateSerializationHookAvailableTest.java   
@Test
public void testAutoregistrationOnHibernate5Available()
        throws Exception {

    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    HazelcastInstanceImpl impl = (HazelcastInstanceImpl) ORIGINAL.get(hz);
    SerializationService ss = impl.getSerializationService();
    @SuppressWarnings("unchecked")
    ConcurrentMap<Class, ?> typeMap = (ConcurrentMap) TYPE_MAP.get(ss);

    boolean cacheEntrySerializerFound = false;
    for (Class clazz : typeMap.keySet()) {
        if (StandardCacheEntryImpl.class.equals(clazz)
                || "com.hazelcast.hibernate.serialization.CacheEntryImpl".equals(clazz.getName())) {
            cacheEntrySerializerFound = true;
        }
    }

    assertTrue("CacheEntry serializer not found", cacheEntrySerializerFound);
}
项目:lams    文件:AbstractEntityPersister.java   
@Override
public CacheEntry buildCacheEntry(Object entity, Object[] state, Object version, SessionImplementor session) {
    return new StandardCacheEntryImpl(
            state,
            persister,
            persister.hasUninitializedLazyProperties( entity ),
            version,
            session,
            entity
    );
}
项目:lams    文件:AbstractEntityPersister.java   
@Override
public CacheEntry buildCacheEntry(Object entity, Object[] state, Object version, SessionImplementor session) {
    return new StandardCacheEntryImpl(
            state,
            persister,
            persister.hasUninitializedLazyProperties( entity ),
            version,
            session,
            entity
    );
}
项目:hazelcast-hibernate5    文件:HibernateSerializationHookNonAvailableTest.java   
@Test
public void testAutoregistrationOnHibernate5NonAvailable()
        throws Exception {

    Thread thread = Thread.currentThread();
    ClassLoader tccl = thread.getContextClassLoader();

    Object config = null;
    Method setClassLoader = null;
    try {
        thread.setContextClassLoader(FILTERING_CLASS_LOADER);

        Class<?> configClazz = FILTERING_CLASS_LOADER.loadClass("com.hazelcast.config.Config");
        config = configClazz.newInstance();
        setClassLoader = configClazz.getDeclaredMethod("setClassLoader", ClassLoader.class);

        setClassLoader.invoke(config, FILTERING_CLASS_LOADER);

        Class<?> hazelcastClazz = FILTERING_CLASS_LOADER.loadClass("com.hazelcast.core.Hazelcast");
        Method newHazelcastInstance = hazelcastClazz.getDeclaredMethod("newHazelcastInstance", configClazz);

        Object hz = newHazelcastInstance.invoke(hazelcastClazz, config);
        Object impl = ORIGINAL.get(hz);
        Object serializationService = GET_SERIALIZATION_SERVICE.invoke(impl);
        //noinspection unchecked
        ConcurrentMap<Class, ?> typeMap = (ConcurrentMap<Class, ?>) TYPE_MAP.get(serializationService);
        boolean cacheEntrySerializerFound = false;
        for (Class clazz : typeMap.keySet()) {
            if (StandardCacheEntryImpl.class.equals(clazz)
                    || "com.hazelcast.hibernate.serialization.CacheEntryImpl".equals(clazz.getName())) {
                cacheEntrySerializerFound = true;
            }
        }

        hazelcastClazz.getDeclaredMethod("shutdownAll").invoke(impl);

        assertFalse("CacheEntry serializer found", cacheEntrySerializerFound);
    } finally {
        if (config != null && setClassLoader != null) {
            setClassLoader.invoke(config, tccl);
        }

        thread.setContextClassLoader(tccl);
    }
}