Search in sources :

Example 1 with Store

use of org.infinispan.commons.persistence.Store in project infinispan by infinispan.

the class NonBlockingStoreAdapter method determineCharacteristics.

private static Set<Characteristic> determineCharacteristics(Object storeImpl) {
    EnumSet<Characteristic> characteristics;
    if (storeImpl instanceof SegmentedAdvancedLoadWriteStore) {
        characteristics = EnumSet.of(Characteristic.SEGMENTABLE, Characteristic.EXPIRATION, Characteristic.BULK_READ);
    } else {
        characteristics = EnumSet.noneOf(Characteristic.class);
        if (storeImpl instanceof AdvancedCacheLoader) {
            characteristics.add(Characteristic.BULK_READ);
        } else if (!(storeImpl instanceof CacheLoader)) {
            characteristics.add(Characteristic.WRITE_ONLY);
        }
        if (storeImpl instanceof AdvancedCacheWriter) {
            characteristics.add(Characteristic.EXPIRATION);
        } else if (!(storeImpl instanceof CacheWriter)) {
            characteristics.add(Characteristic.READ_ONLY);
        }
    }
    Store storeAnnotation = storeImpl.getClass().getAnnotation(Store.class);
    if (storeAnnotation != null && storeAnnotation.shared()) {
        characteristics.add(Characteristic.SHAREABLE);
    }
    // Transactional is a special interface that could be true on a segment or not segmented store both
    if (storeImpl instanceof TransactionalCacheWriter) {
        characteristics.add(Characteristic.TRANSACTIONAL);
    }
    return characteristics;
}
Also used : AdvancedCacheLoader(org.infinispan.persistence.spi.AdvancedCacheLoader) AdvancedCacheWriter(org.infinispan.persistence.spi.AdvancedCacheWriter) TransactionalCacheWriter(org.infinispan.persistence.spi.TransactionalCacheWriter) CacheWriter(org.infinispan.persistence.spi.CacheWriter) AdvancedCacheWriter(org.infinispan.persistence.spi.AdvancedCacheWriter) SegmentedAdvancedLoadWriteStore(org.infinispan.persistence.spi.SegmentedAdvancedLoadWriteStore) SegmentedAdvancedLoadWriteStore(org.infinispan.persistence.spi.SegmentedAdvancedLoadWriteStore) FlagAffectedStore(org.infinispan.persistence.spi.FlagAffectedStore) ExternalStore(org.infinispan.persistence.spi.ExternalStore) NonBlockingStore(org.infinispan.persistence.spi.NonBlockingStore) Store(org.infinispan.commons.persistence.Store) AdvancedCacheLoader(org.infinispan.persistence.spi.AdvancedCacheLoader) CacheLoader(org.infinispan.persistence.spi.CacheLoader) TransactionalCacheWriter(org.infinispan.persistence.spi.TransactionalCacheWriter)

Example 2 with Store

use of org.infinispan.commons.persistence.Store in project infinispan by infinispan.

the class AbstractStoreConfigurationBuilder method validateStoreWithAnnotations.

private void validateStoreWithAnnotations() {
    Class configKlass = attributes.getKlass();
    if (configKlass != null && configKlass.isAnnotationPresent(ConfigurationFor.class)) {
        Class storeKlass = ((ConfigurationFor) configKlass.getAnnotation(ConfigurationFor.class)).value();
        if (storeKlass.isAnnotationPresent(Store.class)) {
            Store storeProps = (Store) storeKlass.getAnnotation(Store.class);
            boolean segmented = attributes.attribute(SEGMENTED).get();
            if (segmented && !AbstractSegmentedStoreConfiguration.class.isAssignableFrom(configKlass) && !(SegmentedAdvancedLoadWriteStore.class.isAssignableFrom(storeKlass) || NonBlockingStore.class.isAssignableFrom(storeKlass))) {
                throw CONFIG.storeNotSegmented(storeKlass);
            }
            if (!storeProps.shared() && attributes.attribute(SHARED).get()) {
                throw CONFIG.nonSharedStoreConfiguredAsShared(storeKlass.getSimpleName());
            }
        }
    } else {
        CONFIG.warnConfigurationForAnnotationMissing(attributes.getName());
    }
}
Also used : NonBlockingStore(org.infinispan.persistence.spi.NonBlockingStore) SegmentedAdvancedLoadWriteStore(org.infinispan.persistence.spi.SegmentedAdvancedLoadWriteStore) Store(org.infinispan.commons.persistence.Store) ConfigurationFor(org.infinispan.commons.configuration.ConfigurationFor)

Aggregations

Store (org.infinispan.commons.persistence.Store)2 NonBlockingStore (org.infinispan.persistence.spi.NonBlockingStore)2 SegmentedAdvancedLoadWriteStore (org.infinispan.persistence.spi.SegmentedAdvancedLoadWriteStore)2 ConfigurationFor (org.infinispan.commons.configuration.ConfigurationFor)1 AdvancedCacheLoader (org.infinispan.persistence.spi.AdvancedCacheLoader)1 AdvancedCacheWriter (org.infinispan.persistence.spi.AdvancedCacheWriter)1 CacheLoader (org.infinispan.persistence.spi.CacheLoader)1 CacheWriter (org.infinispan.persistence.spi.CacheWriter)1 ExternalStore (org.infinispan.persistence.spi.ExternalStore)1 FlagAffectedStore (org.infinispan.persistence.spi.FlagAffectedStore)1 TransactionalCacheWriter (org.infinispan.persistence.spi.TransactionalCacheWriter)1