Skip to content

Commit

Permalink
fix: remove @Autowired in favor of constructor injection (resolved gh…
Browse files Browse the repository at this point in the history
  • Loading branch information
bsbodden committed Nov 15, 2022
1 parent 4a84f30 commit 249daac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.PropertyAccessor;
import org.springframework.beans.PropertyAccessorFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.redis.core.RedisCallback;
Expand All @@ -29,6 +28,7 @@
import org.springframework.util.StringUtils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.redis.om.spring.convert.RedisOMCustomConversions;
import com.redis.om.spring.ops.RedisModulesOperations;
import com.redis.om.spring.ops.json.JSONOperations;
Expand All @@ -48,8 +48,6 @@ public class RedisJSONKeyValueAdapter extends RedisKeyValueAdapter {
private @Nullable String keyspaceNotificationsConfigParameter = null;
private RedisModulesOperations<String> modulesOperations;
private RediSearchIndexer indexer;

@Autowired
private Gson gson;

/**
Expand All @@ -63,13 +61,14 @@ public class RedisJSONKeyValueAdapter extends RedisKeyValueAdapter {
*/
@SuppressWarnings("unchecked")
public RedisJSONKeyValueAdapter(RedisOperations<?, ?> redisOps, RedisModulesOperations<?> rmo,
RedisMappingContext mappingContext, RediSearchIndexer keyspaceToIndexMap) {
RedisMappingContext mappingContext, RediSearchIndexer keyspaceToIndexMap, GsonBuilder gsonBuilder) {
super(redisOps, mappingContext, new RedisOMCustomConversions());
this.modulesOperations = (RedisModulesOperations<String>) rmo;
this.redisJSONOperations = modulesOperations.opsForJSON();
this.redisOperations = redisOps;
this.mappingContext = mappingContext;
this.indexer = keyspaceToIndexMap;
this.gson = gsonBuilder.create();
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,18 @@ public RediSearchIndexer redisearchIndexer(ApplicationContext ac) {
@Bean(name = "redisJSONKeyValueAdapter")
RedisJSONKeyValueAdapter getRedisJSONKeyValueAdapter(RedisOperations<?, ?> redisOps,
RedisModulesOperations<?> redisModulesOperations, RedisMappingContext mappingContext,
RediSearchIndexer keyspaceToIndexMap) {
return new RedisJSONKeyValueAdapter(redisOps, redisModulesOperations, mappingContext, keyspaceToIndexMap);
RediSearchIndexer keyspaceToIndexMap,
GsonBuilder gsonBuilder) {
return new RedisJSONKeyValueAdapter(redisOps, redisModulesOperations, mappingContext, keyspaceToIndexMap, gsonBuilder);
}

@Bean(name = "redisJSONKeyValueTemplate")
public CustomRedisKeyValueTemplate getRedisJSONKeyValueTemplate(RedisOperations<?, ?> redisOps,
RedisModulesOperations<?> redisModulesOperations, RedisMappingContext mappingContext,
RediSearchIndexer keyspaceToIndexMap) {
RediSearchIndexer keyspaceToIndexMap,
GsonBuilder gsonBuilder) {
return new CustomRedisKeyValueTemplate(
getRedisJSONKeyValueAdapter(redisOps, redisModulesOperations, mappingContext, keyspaceToIndexMap),
getRedisJSONKeyValueAdapter(redisOps, redisModulesOperations, mappingContext, keyspaceToIndexMap, gsonBuilder),
mappingContext);
}

Expand Down

0 comments on commit 249daac

Please sign in to comment.