Fix new Sonar smells
Upgrade dependencies for upcoming release
This commit is contained in:
10
build.gradle
10
build.gradle
@@ -135,11 +135,11 @@ subprojects { subproject ->
|
||||
servletApiVersion = '4.0.1'
|
||||
smackVersion = '4.3.1'
|
||||
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.2.0.M1'
|
||||
springDataJpaVersion = '2.2.0.BUILD-SNAPSHOT'
|
||||
springDataMongoVersion = '2.2.0.BUILD-SNAPSHOT'
|
||||
springDataRedisVersion = '2.2.0.BUILD-SNAPSHOT'
|
||||
springGemfireVersion = '2.2.0.BUILD-SNAPSHOT'
|
||||
springSecurityVersion = '5.2.0.BUILD-SNAPSHOT'
|
||||
springDataJpaVersion = '2.2.0.M3'
|
||||
springDataMongoVersion = '2.2.0.M3'
|
||||
springDataRedisVersion = '2.2.0.M3'
|
||||
springGemfireVersion = '2.2.0.M3'
|
||||
springSecurityVersion = '5.2.0.M1'
|
||||
springRetryVersion = '1.2.4.RELEASE'
|
||||
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.2.0.M1'
|
||||
springWsVersion = '3.0.7.RELEASE'
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.integration.channel;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.support.channel.ChannelResolverUtils;
|
||||
import org.springframework.messaging.core.DestinationResolver;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
@@ -27,6 +26,7 @@ import org.springframework.util.ErrorHandler;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 5.2
|
||||
*
|
||||
*/
|
||||
@@ -42,7 +42,8 @@ public final class ChannelUtils {
|
||||
* Obtain an {@link ErrorHandler} registered with the
|
||||
* {@value MESSAGE_PUBLISHING_ERROR_HANDLER_BEAN_NAME} bean name.
|
||||
* By default resolves to the {@link org.springframework.integration.channel.MessagePublishingErrorHandler}
|
||||
* with the {@value ChannelResolverUtils#CHANNEL_RESOLVER_BEAN_NAME} {@link DestinationResolver} bean.
|
||||
* with the {@value ChannelResolverUtils#CHANNEL_RESOLVER_BEAN_NAME}
|
||||
* {@link org.springframework.messaging.core.DestinationResolver} bean.
|
||||
* @param beanFactory BeanFactory for lookup, must not be null.
|
||||
* @return the instance of {@link ErrorHandler} bean whose name is
|
||||
* {@value MESSAGE_PUBLISHING_ERROR_HANDLER_BEAN_NAME}.
|
||||
|
||||
@@ -61,23 +61,23 @@ import org.springframework.util.StringUtils;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class IntegrationManagementConfigurer
|
||||
implements SmartInitializingSingleton, ApplicationContextAware, BeanNameAware,
|
||||
DestructionAwareBeanPostProcessor {
|
||||
DestructionAwareBeanPostProcessor {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(IntegrationManagementConfigurer.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(IntegrationManagementConfigurer.class);
|
||||
|
||||
public static final String MANAGEMENT_CONFIGURER_NAME = "integrationManagementConfigurer";
|
||||
|
||||
private final Map<String, org.springframework.integration.support.management.MessageChannelMetrics>
|
||||
channelsByName = new HashMap<>();
|
||||
channelsByName = new HashMap<>();
|
||||
|
||||
private final Map<String, org.springframework.integration.support.management.MessageHandlerMetrics>
|
||||
handlersByName = new HashMap<>();
|
||||
handlersByName = new HashMap<>();
|
||||
|
||||
private final Map<String, org.springframework.integration.support.management.MessageSourceMetrics>
|
||||
sourcesByName = new HashMap<>();
|
||||
sourcesByName = new HashMap<>();
|
||||
|
||||
private final Map<String,
|
||||
org.springframework.integration.support.management.MessageSourceMetricsConfigurer>
|
||||
org.springframework.integration.support.management.MessageSourceMetricsConfigurer>
|
||||
sourceConfigurers = new HashMap<>();
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
@@ -229,7 +229,7 @@ public class IntegrationManagementConfigurer
|
||||
* Exception logging (debug or otherwise) is not affected by this setting.
|
||||
* <p>
|
||||
* It has been found that in high-volume messaging environments, calls to methods such as
|
||||
* {@code logger.isDebuggingEnabled()} can be quite expensive and account for an inordinate amount of CPU
|
||||
* {@link Log#isDebugEnabled()} can be quite expensive and account for an inordinate amount of CPU
|
||||
* time.
|
||||
* <p>
|
||||
* Set this to false to disable logging by default in all framework components that implement
|
||||
@@ -263,7 +263,7 @@ public class IntegrationManagementConfigurer
|
||||
}
|
||||
if (this.metricsFactory == null) {
|
||||
Map<String, org.springframework.integration.support.management.MetricsFactory>
|
||||
factories = this.applicationContext
|
||||
factories = this.applicationContext
|
||||
.getBeansOfType(org.springframework.integration.support.management.MetricsFactory.class);
|
||||
if (factories.size() == 1) {
|
||||
this.metricsFactory = factories.values().iterator().next();
|
||||
@@ -327,22 +327,25 @@ public class IntegrationManagementConfigurer
|
||||
this.handlersByName.remove(nameOfBean + ".handler");
|
||||
}
|
||||
}
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics) {
|
||||
if (this.sourcesByName.remove(nameOfBean) == null) {
|
||||
this.sourcesByName.remove(nameOfBean + ".source");
|
||||
}
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics &&
|
||||
this.sourcesByName.remove(nameOfBean) == null) {
|
||||
|
||||
this.sourcesByName.remove(nameOfBean + ".source");
|
||||
}
|
||||
}
|
||||
|
||||
private Object doConfigureMetrics(Object bean, String name) {
|
||||
if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) {
|
||||
configureChannelMetrics(name, (org.springframework.integration.support.management.MessageChannelMetrics) bean);
|
||||
configureChannelMetrics(name,
|
||||
(org.springframework.integration.support.management.MessageChannelMetrics) bean);
|
||||
}
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics) {
|
||||
configureHandlerMetrics(name, (org.springframework.integration.support.management.MessageHandlerMetrics) bean);
|
||||
configureHandlerMetrics(name,
|
||||
(org.springframework.integration.support.management.MessageHandlerMetrics) bean);
|
||||
}
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics) {
|
||||
configureSourceMetrics(name, (org.springframework.integration.support.management.MessageSourceMetrics) bean);
|
||||
configureSourceMetrics(name,
|
||||
(org.springframework.integration.support.management.MessageSourceMetrics) bean);
|
||||
this.sourceConfigurers.values().forEach(c -> c
|
||||
.configure((org.springframework.integration.support.management.MessageSourceMetrics) bean, name));
|
||||
}
|
||||
@@ -469,8 +472,8 @@ public class IntegrationManagementConfigurer
|
||||
if (this.channelsByName.containsKey(name)) {
|
||||
return this.channelsByName.get(name);
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No channel found for (" + name + ")");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("No channel found for (" + name + ")");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -483,8 +486,8 @@ public class IntegrationManagementConfigurer
|
||||
return this.handlersByName.get(name + ".handler");
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No handler found for (" + name + ")");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("No handler found for (" + name + ")");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -497,8 +500,8 @@ public class IntegrationManagementConfigurer
|
||||
return this.sourcesByName.get(name + ".source");
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("No source found for (" + name + ")");
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("No source found for (" + name + ")");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -29,9 +29,11 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public abstract class AbstractMessageChannelMetrics implements ConfigurableMetrics {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
private static final String DEPRECATION = "deprecation";
|
||||
|
||||
protected final String name;
|
||||
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR - final
|
||||
|
||||
protected final String name; // NOSONAR - final
|
||||
|
||||
private volatile boolean fullStatsEnabled;
|
||||
|
||||
@@ -61,7 +63,7 @@ public abstract class AbstractMessageChannelMetrics implements ConfigurableMetri
|
||||
* @return the context to be used in a subsequent {@link #afterSend(MetricsContext, boolean)}
|
||||
* call.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings(DEPRECATION)
|
||||
public abstract MetricsContext beforeSend();
|
||||
|
||||
/**
|
||||
@@ -71,7 +73,7 @@ public abstract class AbstractMessageChannelMetrics implements ConfigurableMetri
|
||||
* @param context the context.
|
||||
* @param result true for success, false otherwise.
|
||||
*/
|
||||
public abstract void afterSend(@SuppressWarnings("deprecation") MetricsContext context, boolean result);
|
||||
public abstract void afterSend(@SuppressWarnings(DEPRECATION) MetricsContext context, boolean result);
|
||||
|
||||
/**
|
||||
* Reset all counters/statistics.
|
||||
@@ -102,13 +104,13 @@ public abstract class AbstractMessageChannelMetrics implements ConfigurableMetri
|
||||
|
||||
public abstract double getStandardDeviationSendDuration();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings(DEPRECATION)
|
||||
public abstract Statistics getSendDuration();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings(DEPRECATION)
|
||||
public abstract Statistics getSendRate();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings(DEPRECATION)
|
||||
public abstract Statistics getErrorRate();
|
||||
|
||||
public abstract void afterReceive();
|
||||
|
||||
@@ -27,7 +27,6 @@ package org.springframework.integration.support.management;
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AggregatingMetricsFactory implements MetricsFactory {
|
||||
|
||||
private final int sampleSize;
|
||||
|
||||
@@ -30,7 +30,6 @@ package org.springframework.integration.support.management;
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultMetricsFactory implements MetricsFactory {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.util.List;
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverage {
|
||||
|
||||
private volatile long count;
|
||||
@@ -50,7 +49,7 @@ public class ExponentialMovingAverage {
|
||||
|
||||
private volatile double max;
|
||||
|
||||
private final Deque<Double> samples = new ArrayDeque<Double>();
|
||||
private final Deque<Double> samples = new ArrayDeque<>();
|
||||
|
||||
private final int retention;
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ import java.util.List;
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverageRate {
|
||||
|
||||
private volatile double min = Double.MAX_VALUE;
|
||||
@@ -61,7 +60,7 @@ public class ExponentialMovingAverageRate {
|
||||
|
||||
private final double period;
|
||||
|
||||
private final Deque<Long> times = new ArrayDeque<Long>();
|
||||
private final Deque<Long> times = new ArrayDeque<>();
|
||||
|
||||
private final int retention;
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ import java.util.List;
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverageRatio {
|
||||
|
||||
private volatile double t0;
|
||||
@@ -60,9 +59,9 @@ public class ExponentialMovingAverageRatio {
|
||||
|
||||
private final double lapse;
|
||||
|
||||
private final Deque<Long> times = new ArrayDeque<Long>();
|
||||
private final Deque<Long> times = new ArrayDeque<>();
|
||||
|
||||
private final Deque<Integer> values = new ArrayDeque<Integer>();
|
||||
private final Deque<Integer> values = new ArrayDeque<>();
|
||||
|
||||
private final int retention;
|
||||
|
||||
|
||||
@@ -34,14 +34,13 @@ import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
*/
|
||||
@Deprecated
|
||||
@IntegrationManagedResource
|
||||
@SuppressWarnings("deprecation")
|
||||
public class LifecycleMessageHandlerMetrics implements
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics, Lifecycle,
|
||||
ConfigurableMetricsAware<AbstractMessageHandlerMetrics> {
|
||||
|
||||
private final Lifecycle lifecycle;
|
||||
|
||||
protected final org.springframework.integration.support.management.MessageHandlerMetrics delegate;
|
||||
protected final org.springframework.integration.support.management.MessageHandlerMetrics delegate; // NOSONAR
|
||||
|
||||
|
||||
public LifecycleMessageHandlerMetrics(Lifecycle lifecycle,
|
||||
|
||||
@@ -28,7 +28,6 @@ package org.springframework.integration.support.management;
|
||||
*/
|
||||
@Deprecated
|
||||
@FunctionalInterface
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface MessageSourceMetricsConfigurer {
|
||||
|
||||
void configure(MessageSourceMetrics metrics, String beanName);
|
||||
|
||||
@@ -47,7 +47,6 @@ import org.springframework.data.mongodb.core.query.Update;
|
||||
import org.springframework.integration.mongodb.support.BinaryToMessageConverter;
|
||||
import org.springframework.integration.mongodb.support.MessageToBinaryConverter;
|
||||
import org.springframework.integration.store.AbstractMessageGroupStore;
|
||||
import org.springframework.integration.store.BasicMessageGroupStore;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.MessageMetadata;
|
||||
import org.springframework.integration.support.DefaultMessageBuilderFactory;
|
||||
@@ -57,7 +56,7 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The abstract MongoDB {@link BasicMessageGroupStore} implementation to provide configuration for common options
|
||||
* The abstract MongoDB {@link AbstractMessageGroupStore} implementation to provide configuration for common options
|
||||
* for implementations of this class.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
@@ -85,19 +84,22 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe
|
||||
@Deprecated
|
||||
public static final String CREATED_DATE_KEY = "MongoDbMessageStore.CREATED_DATE";
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR - final
|
||||
|
||||
protected final String collectionName;
|
||||
private RuntimeException NOT_IMPLEMENTED =
|
||||
new UnsupportedOperationException("The operation isn't implemented for this class.");
|
||||
|
||||
protected final MongoDbFactory mongoDbFactory;
|
||||
protected final String collectionName; // NOSONAR - final
|
||||
|
||||
protected final MongoDbFactory mongoDbFactory; // NOSONAR - final
|
||||
|
||||
protected MongoTemplate mongoTemplate;
|
||||
|
||||
protected MappingMongoConverter mappingMongoConverter;
|
||||
private MappingMongoConverter mappingMongoConverter;
|
||||
|
||||
protected ApplicationContext applicationContext;
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
protected MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();
|
||||
private MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();
|
||||
|
||||
public AbstractConfigurableMongoDbMessageStore(MongoTemplate mongoTemplate, String collectionName) {
|
||||
Assert.notNull(mongoTemplate, "'mongoTemplate' must not be null");
|
||||
@@ -125,6 +127,22 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
protected MongoTemplate getMongoTemplate() {
|
||||
return this.mongoTemplate;
|
||||
}
|
||||
|
||||
protected MappingMongoConverter getMappingMongoConverter() {
|
||||
return this.mappingMongoConverter;
|
||||
}
|
||||
|
||||
protected ApplicationContext getApplicationContext() {
|
||||
return this.applicationContext;
|
||||
}
|
||||
|
||||
protected MessageBuilderFactory getMessageBuilderFactory() {
|
||||
return this.messageBuilderFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (this.mongoTemplate == null) {
|
||||
@@ -132,7 +150,7 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe
|
||||
this.mappingMongoConverter = new MappingMongoConverter(new DefaultDbRefResolver(this.mongoDbFactory),
|
||||
new MongoMappingContext());
|
||||
this.mappingMongoConverter.setApplicationContext(this.applicationContext);
|
||||
List<Object> customConverters = new ArrayList<Object>();
|
||||
List<Object> customConverters = new ArrayList<>();
|
||||
customConverters.add(new MessageToBinaryConverter());
|
||||
customConverters.add(new BinaryToMessageConverter());
|
||||
this.mappingMongoConverter.setCustomConversions(new MongoCustomConversions(customConverters));
|
||||
@@ -202,7 +220,7 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe
|
||||
new Update().inc(MessageDocumentFields.SEQUENCE, 1),
|
||||
FindAndModifyOptions.options().returnNew(true).upsert(true),
|
||||
Map.class, this.collectionName)
|
||||
.get(MessageDocumentFields.SEQUENCE); // NOSONAR - never returns null
|
||||
.get(MessageDocumentFields.SEQUENCE); // NOSONAR - never returns null
|
||||
}
|
||||
|
||||
protected void addMessageDocument(final MessageDocument document) {
|
||||
@@ -227,37 +245,37 @@ public abstract class AbstractConfigurableMongoDbMessageStore extends AbstractMe
|
||||
|
||||
@Override
|
||||
public void removeMessagesFromGroup(Object key, Collection<Message<?>> messages) {
|
||||
throw new UnsupportedOperationException("The operation isn't implemented for this class.");
|
||||
throw NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber) {
|
||||
throw new UnsupportedOperationException("The operation isn't implemented for this class.");
|
||||
throw NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<MessageGroup> iterator() {
|
||||
throw new UnsupportedOperationException("The operation isn't implemented for this class.");
|
||||
throw NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeGroup(Object groupId) {
|
||||
throw new UnsupportedOperationException("The operation isn't implemented for this class.");
|
||||
throw NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message<?> getOneMessageFromGroup(Object groupId) {
|
||||
throw new UnsupportedOperationException("The operation isn't implemented for this class.");
|
||||
throw NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessagesToGroup(Object groupId, Message<?>... messages) {
|
||||
throw new UnsupportedOperationException("The operation isn't implemented for this class.");
|
||||
throw NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Message<?>> getMessagesForGroup(Object groupId) {
|
||||
throw new UnsupportedOperationException("The operation isn't implemented for this class.");
|
||||
throw NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
public Message<?> removeMessage(UUID id) {
|
||||
Assert.notNull(id, "'id' must not be null");
|
||||
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).is(id));
|
||||
MessageDocument document = this.mongoTemplate.findAndRemove(query, MessageDocument.class, this.collectionName);
|
||||
MessageDocument document = getMongoTemplate().findAndRemove(query, MessageDocument.class, this.collectionName);
|
||||
return (document != null) ? document.getMessage() : null;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
public long getMessageCount() {
|
||||
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
|
||||
.and(MessageDocumentFields.GROUP_ID).exists(false));
|
||||
return this.mongoTemplate.getCollection(this.collectionName).countDocuments(query.getQueryObject());
|
||||
return getMongoTemplate().getCollection(this.collectionName).countDocuments(query.getQueryObject());
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
Assert.notNull(groupId, "'groupId' must not be null");
|
||||
|
||||
Query query = groupOrderQuery(groupId);
|
||||
MessageDocument messageDocument = this.mongoTemplate.findOne(query, MessageDocument.class, this.collectionName);
|
||||
MessageDocument messageDocument = getMongoTemplate().findOne(query, MessageDocument.class, this.collectionName);
|
||||
|
||||
if (messageDocument != null) {
|
||||
long createdTime = messageDocument.getGroupCreatedTime();
|
||||
@@ -144,7 +144,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
Assert.notNull(messages, "'message' must not be null");
|
||||
|
||||
Query query = groupOrderQuery(groupId);
|
||||
MessageDocument messageDocument = this.mongoTemplate.findOne(query, MessageDocument.class, this.collectionName);
|
||||
MessageDocument messageDocument = getMongoTemplate().findOne(query, MessageDocument.class, this.collectionName);
|
||||
|
||||
long createdTime = System.currentTimeMillis();
|
||||
int lastReleasedSequence = 0;
|
||||
@@ -191,7 +191,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
private void removeMessages(Object groupId, Collection<UUID> ids) {
|
||||
Query query = groupIdQuery(groupId)
|
||||
.addCriteria(Criteria.where(MessageDocumentFields.MESSAGE_ID).in(ids.toArray()));
|
||||
this.mongoTemplate.remove(query, this.collectionName);
|
||||
getMongoTemplate().remove(query, this.collectionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,7 +236,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
public int getMessageCountForAllMessageGroups() {
|
||||
Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true)
|
||||
.and(MessageDocumentFields.GROUP_ID).exists(true));
|
||||
long count = this.mongoTemplate.count(query, this.collectionName);
|
||||
long count = getMongoTemplate().count(query, this.collectionName);
|
||||
Assert.isTrue(count <= Integer.MAX_VALUE, "Message count is out of Integer's range");
|
||||
return (int) count;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
@ManagedAttribute
|
||||
public int getMessageGroupCount() {
|
||||
Query query = Query.query(Criteria.where(MessageDocumentFields.GROUP_ID).exists(true));
|
||||
return this.mongoTemplate.getCollection(this.collectionName)
|
||||
return getMongoTemplate().getCollection(this.collectionName)
|
||||
.distinct(MessageDocumentFields.GROUP_ID, query.getQueryObject(), Object.class)
|
||||
.into(new ArrayList<>())
|
||||
.size();
|
||||
@@ -255,7 +255,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
public Message<?> getOneMessageFromGroup(Object groupId) {
|
||||
Assert.notNull(groupId, "'groupId' must not be null");
|
||||
Query query = groupOrderQuery(groupId);
|
||||
MessageDocument messageDocument = this.mongoTemplate.findOne(query, MessageDocument.class, this.collectionName);
|
||||
MessageDocument messageDocument = getMongoTemplate().findOne(query, MessageDocument.class, this.collectionName);
|
||||
if (messageDocument != null) {
|
||||
return messageDocument.getMessage();
|
||||
}
|
||||
@@ -268,7 +268,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
public Collection<Message<?>> getMessagesForGroup(Object groupId) {
|
||||
Assert.notNull(groupId, "'groupId' must not be null");
|
||||
Query query = groupOrderQuery(groupId);
|
||||
List<MessageDocument> documents = this.mongoTemplate.find(query, MessageDocument.class, this.collectionName);
|
||||
List<MessageDocument> documents = getMongoTemplate().find(query, MessageDocument.class, this.collectionName);
|
||||
|
||||
return documents.stream()
|
||||
.map(MessageDocument::getMessage)
|
||||
@@ -276,7 +276,7 @@ public class ConfigurableMongoDbMessageStore extends AbstractConfigurableMongoDb
|
||||
}
|
||||
|
||||
private void updateGroup(Object groupId, Update update) {
|
||||
this.mongoTemplate.updateFirst(groupOrderQuery(groupId), update, this.collectionName);
|
||||
getMongoTemplate().updateFirst(groupOrderQuery(groupId), update, this.collectionName);
|
||||
}
|
||||
|
||||
private static Update lastModifiedUpdate() {
|
||||
|
||||
@@ -90,7 +90,7 @@ public class MongoDbChannelMessageStore extends AbstractConfigurableMongoDbMessa
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
super.afterPropertiesSet();
|
||||
this.mongoTemplate.indexOps(this.collectionName)
|
||||
getMongoTemplate().indexOps(this.collectionName)
|
||||
.ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC)
|
||||
.on(MessageDocumentFields.PRIORITY, Sort.Direction.DESC)
|
||||
.on(MessageDocumentFields.LAST_MODIFIED_TIME, Sort.Direction.ASC)
|
||||
@@ -132,7 +132,7 @@ public class MongoDbChannelMessageStore extends AbstractConfigurableMongoDbMessa
|
||||
sort = Sort.by(Sort.Direction.DESC, MessageDocumentFields.PRIORITY).and(sort);
|
||||
}
|
||||
Query query = groupIdQuery(groupId).with(sort);
|
||||
MessageDocument document = this.mongoTemplate.findAndRemove(query, MessageDocument.class, this.collectionName);
|
||||
MessageDocument document = getMongoTemplate().findAndRemove(query, MessageDocument.class, this.collectionName);
|
||||
Message<?> message = null;
|
||||
if (document != null) {
|
||||
message = document.getMessage();
|
||||
|
||||
Reference in New Issue
Block a user