Remove Gemfire support in Spring Batch
Based on the decision to discontinue the support of Spring Data for Apache Geode [1], this commit removes the support for Geode in Spring Batch. The code will be moved to the spring-batch-extensions repository as a community-driven effort. [1]: https://github.com/spring-projects/spring-data-geode#notice Resolves #4214
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.item.data;
|
||||
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.item.KeyValueItemWriter;
|
||||
import org.springframework.data.gemfire.GemfireOperations;
|
||||
import org.springframework.data.gemfire.GemfireTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* An {@link ItemWriter} that stores items in GemFire
|
||||
*
|
||||
* @author David Turanski
|
||||
* @since 2.2
|
||||
*
|
||||
*/
|
||||
public class GemfireItemWriter<K, V> extends KeyValueItemWriter<K, V> {
|
||||
|
||||
private GemfireOperations gemfireTemplate;
|
||||
|
||||
/**
|
||||
* @param gemfireTemplate the {@link GemfireTemplate} to set
|
||||
*/
|
||||
public void setTemplate(GemfireTemplate gemfireTemplate) {
|
||||
this.gemfireTemplate = gemfireTemplate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.batch.item.KeyValueItemWriter#writeKeyValue(java.lang.Object,
|
||||
* java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
protected void writeKeyValue(K key, V value) {
|
||||
if (delete) {
|
||||
gemfireTemplate.remove(key);
|
||||
}
|
||||
else {
|
||||
gemfireTemplate.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.item.KeyValueItemWriter#init()
|
||||
*/
|
||||
@Override
|
||||
protected void init() {
|
||||
Assert.notNull(gemfireTemplate, "A GemfireTemplate is required.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.item.data;
|
||||
|
||||
import org.springframework.batch.item.SpELItemKeyMapper;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A convenient {@link GemfireItemWriter} implementation that uses a
|
||||
* {@link SpELItemKeyMapper}
|
||||
*
|
||||
* @author David Turanski
|
||||
* @since 2.2
|
||||
*/
|
||||
public class SpELMappingGemfireItemWriter<K, V> extends GemfireItemWriter<K, V> {
|
||||
|
||||
/**
|
||||
* A constructor that accepts a SpEL expression used to derive the key
|
||||
* @param keyExpression
|
||||
*/
|
||||
SpELMappingGemfireItemWriter(String keyExpression) {
|
||||
super();
|
||||
Assert.hasText(keyExpression, "a valid keyExpression is required.");
|
||||
setItemKeyMapper(new SpELItemKeyMapper<>(keyExpression));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.item.data.builder;
|
||||
|
||||
import org.springframework.batch.item.data.GemfireItemWriter;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.gemfire.GemfireTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A builder implementation for the {@link GemfireItemWriter}
|
||||
*
|
||||
* @author Glenn Renfro
|
||||
* @since 4.0
|
||||
* @see GemfireItemWriterBuilder
|
||||
*/
|
||||
public class GemfireItemWriterBuilder<K, V> {
|
||||
|
||||
private GemfireTemplate template;
|
||||
|
||||
private Converter<V, K> itemKeyMapper;
|
||||
|
||||
private boolean delete;
|
||||
|
||||
/**
|
||||
* Establishes the GemfireTemplate the writer should use.
|
||||
* @param template the {@link GemfireTemplate} to set.
|
||||
* @return The current instance of the builder.
|
||||
* @see GemfireItemWriter#setTemplate(GemfireTemplate)
|
||||
*/
|
||||
public GemfireItemWriterBuilder<K, V> template(GemfireTemplate template) {
|
||||
this.template = template;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link Converter} to use to derive the key from the item.
|
||||
* @param itemKeyMapper the Converter to use.
|
||||
* @return The current instance of the builder.
|
||||
* @see GemfireItemWriter#setItemKeyMapper(Converter)
|
||||
*/
|
||||
public GemfireItemWriterBuilder<K, V> itemKeyMapper(Converter<V, K> itemKeyMapper) {
|
||||
this.itemKeyMapper = itemKeyMapper;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the items being passed to the writer are to be saved or removed from
|
||||
* the data store. If set to false (default), the items will be saved. If set to true,
|
||||
* the items will be removed.
|
||||
* @param delete removal indicator.
|
||||
* @return The current instance of the builder.
|
||||
* @see GemfireItemWriter#setDelete(boolean)
|
||||
*/
|
||||
public GemfireItemWriterBuilder<K, V> delete(boolean delete) {
|
||||
this.delete = delete;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and builds a {@link GemfireItemWriter}.
|
||||
* @return a {@link GemfireItemWriter}
|
||||
*/
|
||||
public GemfireItemWriter<K, V> build() {
|
||||
Assert.notNull(this.template, "template is required.");
|
||||
Assert.notNull(this.itemKeyMapper, "itemKeyMapper is required.");
|
||||
|
||||
GemfireItemWriter<K, V> writer = new GemfireItemWriter<>();
|
||||
writer.setTemplate(this.template);
|
||||
writer.setItemKeyMapper(this.itemKeyMapper);
|
||||
writer.setDelete(this.delete);
|
||||
return writer;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user