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;
}
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());
}
}
Aggregations