Search in sources :

Example 1 with ConfigurationFor

use of org.infinispan.commons.configuration.ConfigurationFor in project infinispan by infinispan.

the class PersistenceUtil method getClassBasedOnConfigurationAnnotation.

private static Class<?> getClassBasedOnConfigurationAnnotation(StoreConfiguration cfg) {
    ConfigurationFor annotation = cfg.getClass().getAnnotation(ConfigurationFor.class);
    Class<?> classAnnotation = null;
    if (annotation == null) {
        if (cfg instanceof CustomStoreConfiguration) {
            classAnnotation = ((CustomStoreConfiguration) cfg).customStoreClass();
        }
    } else {
        classAnnotation = annotation.value();
    }
    if (classAnnotation == null) {
        throw CONFIG.loaderConfigurationDoesNotSpecifyLoaderClass(cfg.getClass().getName());
    }
    return classAnnotation;
}
Also used : ConfigurationFor(org.infinispan.commons.configuration.ConfigurationFor) CustomStoreConfiguration(org.infinispan.configuration.cache.CustomStoreConfiguration)

Example 2 with ConfigurationFor

use of org.infinispan.commons.configuration.ConfigurationFor 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

ConfigurationFor (org.infinispan.commons.configuration.ConfigurationFor)2 Store (org.infinispan.commons.persistence.Store)1 CustomStoreConfiguration (org.infinispan.configuration.cache.CustomStoreConfiguration)1 NonBlockingStore (org.infinispan.persistence.spi.NonBlockingStore)1 SegmentedAdvancedLoadWriteStore (org.infinispan.persistence.spi.SegmentedAdvancedLoadWriteStore)1