org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery Java Examples

The following examples show how to use org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeyValueRepositoryFactory.java    From spring-data-keyvalue with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
		NamedQueries namedQueries) {

	QueryMethod queryMethod = new QueryMethod(method, metadata, factory);

	Constructor<? extends KeyValuePartTreeQuery> constructor = (Constructor<? extends KeyValuePartTreeQuery>) ClassUtils
			.getConstructorIfAvailable(this.repositoryQueryType, QueryMethod.class,
					QueryMethodEvaluationContextProvider.class, KeyValueOperations.class, Class.class);

	Assert.state(constructor != null,
			String.format(
					"Constructor %s(QueryMethod, EvaluationContextProvider, KeyValueOperations, Class) not available!",
					ClassUtils.getShortName(this.repositoryQueryType)));

	return BeanUtils.instantiateClass(constructor, queryMethod, evaluationContextProvider, this.keyValueOperations,
			this.queryCreator);
}
 
Example #2
Source File: KeyValueRepositoryConfigurationExtension.java    From spring-data-keyvalue with Apache License 2.0 5 votes vote down vote up
/**
 * Detects the query creator type to be used for the factory to set. Will lookup a {@link QueryCreatorType} annotation
 * on the {@code @Enable}-annotation or use {@link SpelQueryCreator} if not found.
 *
 * @param config
 * @return
 */
private static Class<?> getQueryType(AnnotationRepositoryConfigurationSource config) {

	AnnotationMetadata metadata = config.getEnableAnnotationMetadata();

	Map<String, Object> queryCreatorAnnotationAttributes = metadata
			.getAnnotationAttributes(QueryCreatorType.class.getName());

	if (queryCreatorAnnotationAttributes == null) {
		return KeyValuePartTreeQuery.class;
	}

	AnnotationAttributes queryCreatorAttributes = new AnnotationAttributes(queryCreatorAnnotationAttributes);
	return queryCreatorAttributes.getClass("repositoryQueryType");
}
 
Example #3
Source File: KeyValueRepositoryFactoryBeanUnitTests.java    From spring-data-keyvalue with Apache License 2.0 5 votes vote down vote up
@Test // DATAKV-123
@SuppressWarnings("unchecked")
public void createsRepositoryFactory() {

	Class<? extends AbstractQueryCreator<?, ?>> creatorType = (Class<? extends AbstractQueryCreator<?, ?>>) mock(
			AbstractQueryCreator.class).getClass();
	Class<? extends RepositoryQuery> queryType = mock(KeyValuePartTreeQuery.class).getClass();

	factoryBean.setQueryCreator(creatorType);
	factoryBean.setKeyValueOperations(mock(KeyValueOperations.class));
	factoryBean.setQueryType(queryType);

	assertThat(factoryBean.createRepositoryFactory()).isNotNull();
}
 
Example #4
Source File: VaultRepositoryFactory.java    From spring-vault with Apache License 2.0 4 votes vote down vote up
public VaultRepositoryFactory(KeyValueOperations keyValueOperations,
		Class<? extends AbstractQueryCreator<?, ?>> queryCreator) {
	this(keyValueOperations, queryCreator, KeyValuePartTreeQuery.class);
}
 
Example #5
Source File: KeyValueRepositoryFactory.java    From spring-data-keyvalue with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link KeyValueRepositoryFactory} for the given {@link KeyValueOperations} and
 * {@link AbstractQueryCreator}-type.
 *
 * @param keyValueOperations must not be {@literal null}.
 * @param queryCreator must not be {@literal null}.
 */
public KeyValueRepositoryFactory(KeyValueOperations keyValueOperations,
		Class<? extends AbstractQueryCreator<?, ?>> queryCreator) {

	this(keyValueOperations, queryCreator, KeyValuePartTreeQuery.class);
}