org.springframework.data.keyvalue.core.KeyValueTemplate Java Examples

The following examples show how to use org.springframework.data.keyvalue.core.KeyValueTemplate. 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: HazelcastRepositoryConfigurationExtension.java    From spring-data-hazelcast with Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(RepositoryConfigurationSource configurationSource) {
    RootBeanDefinition keyValueTemplateDefinition = new RootBeanDefinition(KeyValueTemplate.class);
    ConstructorArgumentValues constructorArgumentValuesForKeyValueTemplate = new ConstructorArgumentValues();
    constructorArgumentValuesForKeyValueTemplate
            .addIndexedArgumentValue(0, new RuntimeBeanReference(HAZELCAST_ADAPTER_BEAN_NAME));
    constructorArgumentValuesForKeyValueTemplate
            .addIndexedArgumentValue(1, new RuntimeBeanReference(MAPPING_CONTEXT_BEAN_NAME));

    keyValueTemplateDefinition.setConstructorArgumentValues(constructorArgumentValuesForKeyValueTemplate);

    return keyValueTemplateDefinition;
}
 
Example #2
Source File: MapRepositoryConfigurationExtension.java    From spring-data-keyvalue with Apache License 2.0 5 votes vote down vote up
@Override
protected AbstractBeanDefinition getDefaultKeyValueTemplateBeanDefinition(
		RepositoryConfigurationSource configurationSource) {

	BeanDefinitionBuilder adapterBuilder = BeanDefinitionBuilder.rootBeanDefinition(MapKeyValueAdapter.class);
	adapterBuilder.addConstructorArgValue(getMapTypeToUse(configurationSource));

	BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(KeyValueTemplate.class);
	builder
			.addConstructorArgValue(ParsingUtils.getSourceBeanDefinition(adapterBuilder, configurationSource.getSource()));
	builder.setRole(BeanDefinition.ROLE_SUPPORT);

	return ParsingUtils.getSourceBeanDefinition(builder, configurationSource.getSource());
}
 
Example #3
Source File: MapRepositoriesConfigurationExtensionIntegrationTests.java    From spring-data-keyvalue with Apache License 2.0 5 votes vote down vote up
private static void assertKeyValueTemplateWithAdapterFor(Class<?> mapType, ApplicationContext context) {

		KeyValueTemplate template = context.getBean(KeyValueTemplate.class);
		Object adapter = ReflectionTestUtils.getField(template, "adapter");

		assertThat(adapter).isInstanceOf(MapKeyValueAdapter.class);
		assertThat(ReflectionTestUtils.getField(adapter, "store")).isInstanceOf(mapType);
	}
 
Example #4
Source File: AbstractRepositoryUnitTests.java    From spring-data-keyvalue with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {

	KeyValueOperations operations = new KeyValueTemplate(new MapKeyValueAdapter());
	KeyValueRepositoryFactory keyValueRepositoryFactory = createKeyValueRepositoryFactory(operations);

	this.repository = getRepository(keyValueRepositoryFactory);
}
 
Example #5
Source File: KeyValueTemplateTestsUsingHazelcastTest.java    From spring-data-hazelcast with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp()
        throws InstantiationException, IllegalAccessException {
    this.operations = new KeyValueTemplate(HazelcastUtils.preconfiguredHazelcastKeyValueAdapter());
}
 
Example #6
Source File: HazelcastEntityInformationTest.java    From spring-data-hazelcast with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    this.operations = new KeyValueTemplate(HazelcastUtils.preconfiguredHazelcastKeyValueAdapter());
}
 
Example #7
Source File: MapRepositoryRegistrarWithTemplateDefinitionIntegrationTests.java    From spring-data-keyvalue with Apache License 2.0 4 votes vote down vote up
@Bean
public KeyValueOperations keyValueTemplate() {
	return new KeyValueTemplate(new MapKeyValueAdapter());
}
 
Example #8
Source File: MapRepositoriesConfigurationExtensionIntegrationTests.java    From spring-data-keyvalue with Apache License 2.0 4 votes vote down vote up
@Bean
public KeyValueTemplate mapKeyValueTemplate() {
	return new KeyValueTemplate(new MapKeyValueAdapter());
}
 
Example #9
Source File: Configurations.java    From tutorials with MIT License 4 votes vote down vote up
@Bean("keyValueTemplate")
public KeyValueOperations keyValueTemplate() {
    return new KeyValueTemplate(keyValueAdapter());

}