Search in sources :

Example 1 with RegionAccessStrategy

use of org.hibernate.cache.spi.access.RegionAccessStrategy in project hibernate-orm by hibernate.

the class CorrectnessTestCase method getPutFromLoadValidator.

private PutFromLoadValidator getPutFromLoadValidator(SessionFactoryImplementor sfi, String regionName) throws NoSuchFieldException, IllegalAccessException {
    RegionAccessStrategy strategy = sfi.getSecondLevelCacheRegionAccessStrategy(regionName);
    if (strategy == null) {
        return null;
    }
    Field delegateField = getField(strategy.getClass(), "delegate");
    Object delegate = delegateField.get(strategy);
    if (delegate == null) {
        return null;
    }
    if (InvalidationCacheAccessDelegate.class.isInstance(delegate)) {
        Field validatorField = InvalidationCacheAccessDelegate.class.getDeclaredField("putValidator");
        validatorField.setAccessible(true);
        return (PutFromLoadValidator) validatorField.get(delegate);
    } else {
        return null;
    }
}
Also used : Field(java.lang.reflect.Field) PutFromLoadValidator(org.hibernate.cache.infinispan.access.PutFromLoadValidator) RegionAccessStrategy(org.hibernate.cache.spi.access.RegionAccessStrategy)

Aggregations

Field (java.lang.reflect.Field)1 PutFromLoadValidator (org.hibernate.cache.infinispan.access.PutFromLoadValidator)1 RegionAccessStrategy (org.hibernate.cache.spi.access.RegionAccessStrategy)1