Skip to content

Commit

Permalink
SGF-588 - Reorganize and repackage additional classes in the SDG API.
Browse files Browse the repository at this point in the history
  • Loading branch information
jxblum committed Jan 21, 2017
1 parent 3fb3e6c commit 2dbc608
Show file tree
Hide file tree
Showing 29 changed files with 302 additions and 230 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012 the original author or authors.
* Copyright 2016 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.
Expand All @@ -15,7 +15,7 @@
*
*/

package org.springframework.data.gemfire.support;
package org.springframework.data.gemfire.cache;

import java.util.concurrent.Callable;

Expand All @@ -27,17 +27,17 @@
import org.springframework.util.Assert;

/**
* The CallableCacheLoaderAdapter class is a {@link Callable} and GemFire {@link CacheLoader} implementation that
* adapts the {@link Callable} interface into an instance of the {@link CacheLoader} interface. This class is useful
* in situations where GemFire developers have several {@link CacheLoader} implementations that they wish to use
* with Spring's Cache Abstraction.
* The {@link CallableCacheLoaderAdapter} class is a {@link Callable} and GemFire {@link CacheLoader} implementation
* that adapts the {@link Callable} interface into an instance of the {@link CacheLoader} interface. This class is
* useful in situations where GemFire developers have several {@link CacheLoader} implementations that they wish to
* use with Spring's Cache Abstraction.
*
* @author John Blum
* @see java.util.concurrent.Callable
* @see org.apache.geode.cache.CacheLoader
* @see org.apache.geode.cache.LoaderHelper
* @see org.apache.geode.cache.Region
* @since 1.0.0
* @since 1.9.0
*/
@SuppressWarnings("unused")
public class CallableCacheLoaderAdapter<K, V> implements Callable<V>, CacheLoader<K, V> {
Expand Down Expand Up @@ -196,5 +196,4 @@ public void close() {
public V load(LoaderHelper<K, V> loaderHelper) throws CacheLoaderException {
return getCacheLoader().load(loaderHelper);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.data.gemfire.function.execution.GemfireOnServersFunctionTemplate;
import org.springframework.data.gemfire.support.ListRegionsOnServerFunction;
import org.springframework.data.gemfire.client.function.ListRegionsOnServerFunction;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;

Expand All @@ -42,7 +42,7 @@
* @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
* @see org.springframework.data.gemfire.function.execution.GemfireOnServersFunctionTemplate
* @see org.springframework.data.gemfire.support.ListRegionsOnServerFunction
* @see ListRegionsOnServerFunction
* @see org.apache.geode.cache.Region
* @see org.apache.geode.cache.client.ClientCache
* @see org.apache.geode.cache.client.ClientRegionFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2016 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
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://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.
*
* 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.data.gemfire.support;
package org.springframework.data.gemfire.client.function;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -32,7 +36,7 @@
@SuppressWarnings("serial")
public class ListRegionsOnServerFunction implements Function {

private static final long serialVersionUID = 867530169l;
private static final long serialVersionUID = 867530169L;

public static final String ID = ListRegionsOnServerFunction.class.getName();

Expand Down Expand Up @@ -91,5 +95,4 @@ public boolean isHA() {
public boolean optimizeForWrite() {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.data.gemfire.support.JSONRegionAdvice;
import org.springframework.data.gemfire.serialization.json.JSONRegionAdvice;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;

Expand All @@ -32,7 +32,7 @@
* @author David Turanski
* @author John Blum
* @see org.springframework.beans.factory.xml.BeanDefinitionParser
* @see org.springframework.data.gemfire.support.JSONRegionAdvice
* @see JSONRegionAdvice
*/
class GemfireRegionAutoProxyParser implements BeanDefinitionParser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.data.gemfire.GemfireTransactionManager;
import org.springframework.data.gemfire.transaction.GemfireTransactionManager;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;

Expand All @@ -31,7 +31,7 @@
* @author Costin Leau
* @author John Blum
* @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
* @see org.springframework.data.gemfire.GemfireTransactionManager
* @see GemfireTransactionManager
*/
class TransactionManagerParser extends AbstractSingleBeanDefinitionParser {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011-2013 the original author or authors.
* Copyright 2016 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.
Expand All @@ -12,9 +12,10 @@
* 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.data.gemfire.support;
package org.springframework.data.gemfire.dao;

import org.apache.geode.cache.Region;
import org.springframework.dao.support.DaoSupport;
Expand All @@ -23,36 +24,25 @@
import org.springframework.util.Assert;

/**
* Convenient super class for GemFire data access objects. Intended for
* GemfireTemplate usage.
* Convenient super class for GemFire Data Access Objects (DAO) implementing the Spring
* {@link DaoSupport} abstract class. Intended for use with {@link GemfireTemplate}.
*
* <p>Requires a Region to be set, providing a GemfireTemplate based on it to subclasses.
* Can alternatively be initialized directly via a GemfireTemplate, to reuse the latter's
* settings.
* Requires a GemFire {@link Region} to be set, providing a {@link GemfireTemplate} based on it to subclasses.
* Can alternatively be initialized directly via a {@link GemfireTemplate} reusing the template's settings.
*
* <p>This class will create its own GemfireTemplate if an Region reference is passed in.
* A custom GemfireTemplate instance can be used through overriding <code>createGemfireTemplate</code>.
* This class will create its own {@link GemfireTemplate} if a GemFire {@link Region} reference is passed in.
* A custom {@link GemfireTemplate} instance can be used through overriding <code>createGemfireTemplate</code>.
*
* @author Costin Leau
* @author John Blum
* @see org.apache.geode.cache.Region
* @see org.springframework.dao.support.DaoSupport
* @see org.springframework.data.gemfire.GemfireTemplate
*/
public class GemfireDaoSupport extends DaoSupport {
public abstract class GemfireDaoSupport extends DaoSupport {

private GemfireOperations gemfireTemplate;

/**
* Sets the GemFire Cache Region to be used by this DAO. Will automatically create
* an instance of the GemfireTemplate for the given Region.
*
* @param region the GemFire Cache Region upon which this DAO operates.
* @see org.apache.geode.cache.Region
* @see #createGemfireTemplate(org.apache.geode.cache.Region)
*/
public void setRegion(Region<?, ?> region) {
this.gemfireTemplate = createGemfireTemplate(region);
}

/**
* Set the GemfireTemplate for this DAO explicitly as an alternative to specifying a GemFire Cache {@link Region}.
*
Expand All @@ -73,7 +63,19 @@ public final void setGemfireTemplate(GemfireOperations gemfireTemplate) {
* @see org.springframework.data.gemfire.GemfireTemplate
*/
public final GemfireOperations getGemfireTemplate() {
return gemfireTemplate;
return this.gemfireTemplate;
}

/**
* Sets the GemFire Cache Region to be used by this DAO. Will automatically create
* an instance of the GemfireTemplate for the given Region.
*
* @param region the GemFire Cache Region upon which this DAO operates.
* @see org.apache.geode.cache.Region
* @see #createGemfireTemplate(org.apache.geode.cache.Region)
*/
public void setRegion(Region<?, ?> region) {
this.gemfireTemplate = createGemfireTemplate(region);
}

/**
Expand All @@ -86,7 +88,7 @@ public final GemfireOperations getGemfireTemplate() {
* @see org.apache.geode.cache.Region
* @see #setRegion
*/
protected GemfireOperations createGemfireTemplate(Region<?, ?> region) {
protected GemfireTemplate createGemfireTemplate(Region<?, ?> region) {
return new GemfireTemplate(region);
}

Expand All @@ -95,7 +97,6 @@ protected GemfireOperations createGemfireTemplate(Region<?, ?> region) {
*/
@Override
protected final void checkDaoConfig() {
Assert.state(gemfireTemplate != null, "A GemFire Cache Region or an instance of the GemfireTemplate is required.");
Assert.state(gemfireTemplate != null, "A GemFire Cache Region or instance of GemfireTemplate is required");
}

}
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2016 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
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://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.
*
* 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.data.gemfire.support;
package org.springframework.data.gemfire.serialization.json;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -37,7 +41,15 @@
import org.springframework.util.CollectionUtils;

/**
* Spring/AspectJ AOP Aspect to adapt a GemFire {@link Region} to handle JSON data.
*
* @author David Turanski
* @author John Blum
* @see org.apache.geode.cache.Region
* @see org.apache.geode.pdx.JSONFormatter
* @see org.apache.geode.pdx.PdxInstance
* @see org.aspectj.lang.annotation.Aspect
* @see org.aspectj.lang.annotation.Around
*/
@Aspect
@SuppressWarnings("unused")
Expand Down Expand Up @@ -320,5 +332,4 @@ private void handleThrowable(Throwable t) {
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public void destroy() {
* the {@link #setBeanName(String)} beanName} property.
*
* @return the single Spring {@link BeanFactory} from the registry.
* @throws IllegalArgumentException if more than Spring {@link BeanFactory} is registered.
* @throws IllegalStateException if the {@link BeanFactory} with the associated
* {@link #setBeanName(String) beanName} is not found.
* @see org.springframework.beans.factory.BeanFactory
Expand All @@ -259,9 +260,16 @@ public BeanFactory useBeanFactory() {
}

/**
* Attempts to use the Spring {@link BeanFactory} idenified by the given {@code beanFactoryKey}.
*
* @param beanFactoryKey
* @return
* @param beanFactoryKey {@link String} containing the key used to lookup the Spring {@link BeanFactory}.
* @return the Spring {@link BeanFactory} for the given {@code beanFactoryKey}.
* @throws IllegalArgumentException if a Spring {@link BeanFactory} could not be found for {@code beanFactoryKey}.
* @throws IllegalStateException if {@literal useBeanFactoryLocator} was not configured.
* @see org.springframework.beans.factory.BeanFactory
* @see BeanFactoryReference#newBeanFactoryReference(BeanFactory)
* @see #resolveBeanFactory(String)
* @see #resolveSingleBeanFactory()
*/
public BeanFactory useBeanFactory(String beanFactoryKey) {
return newBeanFactoryReference(StringUtils.hasText(beanFactoryKey) ? resolveBeanFactory(beanFactoryKey)
Expand Down Expand Up @@ -349,9 +357,9 @@ protected static class BeanFactoryReference {
* @param beanFactory {@link BeanFactory} reference to store.
* @return a new instance of {@link BeanFactoryReference} initialized with the given {@link BeanFactory}.
* @see org.springframework.beans.factory.BeanFactory
* @see #BeanFactoryReference(BeanFactory)
* @see #GemfireBeanFactoryLocator.BeanFactoryReference(BeanFactory)
*/
public static BeanFactoryReference newBeanFactoryReference(BeanFactory beanFactory) {
protected static BeanFactoryReference newBeanFactoryReference(BeanFactory beanFactory) {
return new BeanFactoryReference(beanFactory);
}

Expand All @@ -361,7 +369,7 @@ public static BeanFactoryReference newBeanFactoryReference(BeanFactory beanFacto
* @param beanFactory {@link BeanFactory} reference to store; may be {@literal null}.
* @see org.springframework.beans.factory.BeanFactory
*/
public BeanFactoryReference(BeanFactory beanFactory) {
protected BeanFactoryReference(BeanFactory beanFactory) {
this.beanFactory.set(beanFactory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected void assertUninitialized() {
*
* @return a boolean value indicating whether this {@link Declarable} object has been properly configured
* and initialized by the Spring container.
* @see #doInit(Properties)
* @see #doInit(BeanFactory, Properties)
* @see #assertInitialized()
*/
protected boolean isInitialized() {
Expand All @@ -130,7 +130,7 @@ protected boolean isInitialized() {
*
* @return a boolean value indicating whether this {@link Declarable} object has been properly configured
* and initialized by the Spring container.
* @see #doInit(Properties)
* @see #doInit(BeanFactory, Properties)
* @see #isInitialized()
*/
protected boolean isNotInitialized() {
Expand All @@ -144,7 +144,7 @@ protected boolean isNotInitialized() {
*
* @param parameters {@link Properties} containing the configured parameters parsed from GemFire's
* configuration meta-data (e.g. {@literal cache.xml}) and passed to this {@link Declarable} object.
* @see #doInit(Properties)
* @see #doInit(BeanFactory, Properties)
* @see java.util.Properties
*/
@Override
Expand Down Expand Up @@ -188,7 +188,7 @@ synchronized void doInit(BeanFactory beanFactory, Properties parameters) {
*
* @param parameters {@link Properties} containing the configured parameters parsed from GemFire's
* configuration meta-data (e.g. {@literal cache.xml}) and passed to this {@link Declarable} object.
* @see #doInit(Properties)
* @see #doInit(BeanFactory, Properties)
* @see java.util.Properties
*/
protected void doPostInit(Properties parameters) {
Expand Down
Loading

0 comments on commit 2dbc608

Please sign in to comment.