DATAGEODE-302 - Declare the GemfireCallback as a @FunctionalInterface.
Edit Javadoc. Formate source code; optimize imports.
This commit is contained in:
@@ -13,23 +13,22 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import org.apache.geode.GemFireCheckedException;
|
||||
import org.apache.geode.GemFireException;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* {@link GemfireAccessor} is a base class for {@link GemfireTemplate} defining common operations and properties,
|
||||
* such as {@link Region}.
|
||||
* {@link GemfireAccessor} is a base class for {@link GemfireTemplate} to encapsulate common operations and properties,
|
||||
* such as accessors to a {@link Region}.
|
||||
*
|
||||
* This class is not intended to be used directly.
|
||||
*
|
||||
@@ -42,6 +41,7 @@ public class GemfireAccessor implements InitializingBean {
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private Region region;
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ public class GemfireAccessor implements InitializingBean {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <K, V> Region<K, V> getRegion() {
|
||||
return region;
|
||||
return this.region;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,6 +67,9 @@ public class GemfireAccessor implements InitializingBean {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(getRegion(), "Region is required");
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import org.apache.geode.GemFireCheckedException;
|
||||
@@ -21,7 +20,9 @@ import org.apache.geode.GemFireException;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
/**
|
||||
* Callback interface for GemFire code. To be used with {@link GemfireTemplate}'s execution methods, often as anonymous
|
||||
* Callback interface for GemFire code.
|
||||
*
|
||||
* Implementations of this interface are to be used with {@link GemfireTemplate}'s execution methods, often as anonymous
|
||||
* classes within a method implementation. A typical implementation will call Region.get/put/query to perform some
|
||||
* operations on stored objects.
|
||||
*
|
||||
@@ -29,25 +30,27 @@ import org.apache.geode.cache.Region;
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface GemfireCallback<T> {
|
||||
|
||||
/**
|
||||
* Gets called by {@link GemfireTemplate#execute(GemfireCallback)}. Does not need to care about
|
||||
* handling transactions or exceptions.
|
||||
* This methods gets called by {@link GemfireTemplate#execute(GemfireCallback)}.
|
||||
*
|
||||
* Allows a result object created within the callback to be returned, i.e. a domain object
|
||||
* or a collection of domain objects.
|
||||
* The method implementation does not need to care about handling transactions or exceptions.
|
||||
*
|
||||
* A thrown custom RuntimeException is treated as an application exception: it gets propagated to
|
||||
* Allows a result {@link Object} created within this callback to be returned, i.e. an application domain object
|
||||
* or a collection of application domain objects.
|
||||
*
|
||||
* A custom thrown {@link RuntimeException} is treated as an application exception; the exception is propagated to
|
||||
* the caller of the template.
|
||||
*
|
||||
* @param region the GemFire Cache Region upon which the operation of this callback will be performed.
|
||||
* @return a result object, or <tt>null</tt> if no result.
|
||||
* @throws GemFireCheckedException for checked Exceptions occurring in GemFire.
|
||||
* @throws GemFireException for runtime Exceptions occurring in GemFire.
|
||||
* @param region {@link Region} on which the operation of this callback will be performed.
|
||||
* @return a result {@link Object}, or {@literal null} if no result.
|
||||
* @throws GemFireCheckedException for checked {@link Exception Exceptions} occurring in GemFire.
|
||||
* @throws GemFireException for {@link RuntimeException RuntimeExceptions} occurring in GemFire.
|
||||
* @see org.springframework.data.gemfire.GemfireTemplate
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
T doInGemfire(Region<?,?> region) throws GemFireCheckedException, GemFireException;
|
||||
T doInGemfire(Region<?, ?> region) throws GemFireCheckedException, GemFireException;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.support;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
|
||||
Reference in New Issue
Block a user