Update to Spring 4 Build Snapshot
- IdGenerator package change - Generics added to CollectionUtils.arrayToList()
This commit is contained in:
@@ -25,7 +25,7 @@ allprojects {
|
||||
group = 'org.springframework.integration'
|
||||
|
||||
repositories {
|
||||
maven { url 'http://repo.springsource.org/libs-milestone' }
|
||||
maven { url 'http://repo.springsource.org/libs-snapshot' }
|
||||
maven { url 'http://repo.springsource.org/plugins-release' }
|
||||
mavenCentral()
|
||||
}
|
||||
@@ -59,7 +59,7 @@ subprojects { subproject ->
|
||||
ftpServerVersion = '1.0.6'
|
||||
|
||||
|
||||
springVersionDefault = '4.0.0.RC1'
|
||||
springVersionDefault = '4.0.0.BUILD-SNAPSHOT'
|
||||
springVersion = project.hasProperty('springVersion') ? getProperty('springVersion') : springVersionDefault
|
||||
|
||||
springAmqpVersion = '1.2.0.RELEASE'
|
||||
|
||||
@@ -20,22 +20,21 @@ import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.AlternativeJdkIdGenerator;
|
||||
import org.springframework.util.IdGenerator;
|
||||
|
||||
/**
|
||||
* The headers for a {@link Message}.<br>
|
||||
* IMPORTANT: MessageHeaders are immutable. Any mutating operation (e.g., put(..), putAll(..) etc.)
|
||||
@@ -271,66 +270,4 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
|
||||
in.defaultReadObject();
|
||||
}
|
||||
|
||||
public static interface IdGenerator {
|
||||
UUID generateId();
|
||||
}
|
||||
|
||||
public static class JdkIdGenerator implements IdGenerator {
|
||||
|
||||
@Override
|
||||
public UUID generateId() {
|
||||
return UUID.randomUUID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A variation of {@link UUID#randomUUID()} that uses {@link SecureRandom} only for
|
||||
* the initial seed and {@link Random} thereafter, which provides better performance
|
||||
* in exchange for less securely random id's.
|
||||
*/
|
||||
public static class AlternativeJdkIdGenerator implements IdGenerator {
|
||||
|
||||
private final Random random;
|
||||
|
||||
public AlternativeJdkIdGenerator() {
|
||||
byte[] seed = new SecureRandom().generateSeed(8);
|
||||
this.random = new Random(new BigInteger(seed).longValue());
|
||||
}
|
||||
|
||||
public UUID generateId() {
|
||||
|
||||
byte[] randomBytes = new byte[16];
|
||||
this.random.nextBytes(randomBytes);
|
||||
|
||||
long mostSigBits = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mostSigBits = (mostSigBits << 8) | (randomBytes[i] & 0xff);
|
||||
}
|
||||
long leastSigBits = 0;
|
||||
for (int i = 8; i < 16; i++) {
|
||||
leastSigBits = (leastSigBits << 8) | (randomBytes[i] & 0xff);
|
||||
}
|
||||
|
||||
return new UUID(mostSigBits, leastSigBits);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SimpleIncrementingIdGenerator implements IdGenerator {
|
||||
|
||||
private final AtomicLong topBits = new AtomicLong();
|
||||
|
||||
private final AtomicLong bottomBits = new AtomicLong();
|
||||
|
||||
@Override
|
||||
public UUID generateId() {
|
||||
long bottomBits = this.bottomBits.incrementAndGet();
|
||||
if (bottomBits == 0) {
|
||||
this.topBits.incrementAndGet();
|
||||
}
|
||||
return new UUID(this.topBits.get(), bottomBits);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.context.event.ApplicationContextEvent;
|
||||
import org.springframework.context.event.ContextClosedEvent;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.MessageHeaders.IdGenerator;
|
||||
import org.springframework.util.IdGenerator;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,8 @@ package org.springframework.integration.support;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.springframework.messaging.MessageHeaders.IdGenerator;
|
||||
import org.springframework.util.IdGenerator;
|
||||
|
||||
|
||||
// TODO Discuss and agree where these should go. In SI or in Spring 4?
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
@@ -32,7 +33,7 @@ import org.springframework.integration.support.IdGenerators.JdkIdGenerator;
|
||||
import org.springframework.integration.support.IdGenerators.SimpleIncrementingIdGenerator;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.MessageHeaders.IdGenerator;
|
||||
import org.springframework.util.IdGenerator;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.context.support.GenericXmlApplicationContext;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.MessageHeaders.IdGenerator;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.util.IdGenerator;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ import org.springframework.context.event.ContextStoppedEvent;
|
||||
import org.springframework.context.event.SmartApplicationListener;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.endpoint.ExpressionMessageProducerSupport;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -69,9 +69,9 @@ public class ApplicationEventListeningMessageProducer extends ExpressionMessageP
|
||||
* @see ApplicationEventMulticaster#addApplicationListener
|
||||
* @see #supportsEventType
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setEventTypes(Class<? extends ApplicationEvent>... eventTypes) {
|
||||
Set<Class<? extends ApplicationEvent>> eventSet = new HashSet<Class<? extends ApplicationEvent>>(CollectionUtils.arrayToList(eventTypes));
|
||||
Set<Class<? extends ApplicationEvent>> eventSet = new HashSet<Class<? extends ApplicationEvent>>(
|
||||
CollectionUtils.<Class<? extends ApplicationEvent>> arrayToList(eventTypes));
|
||||
eventSet.remove(null);
|
||||
this.eventTypes = (eventSet.size() > 0 ? eventSet : null);
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.core.MessageProducer;
|
||||
import org.springframework.integration.endpoint.MessageProducerSupport;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -44,11 +44,10 @@ public class TcpConnectionEventListeningMessageProducer extends MessageProducerS
|
||||
* this adapter should send to the message channel. By default, all event
|
||||
* types will be sent.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setEventTypes(Class<? extends TcpConnectionEvent>[] eventTypes) {
|
||||
Assert.notEmpty(eventTypes, "at least one event type is required");
|
||||
Set<Class<? extends TcpConnectionEvent>> eventTypeSet = new HashSet<Class<? extends TcpConnectionEvent>>();
|
||||
eventTypeSet.addAll(CollectionUtils.arrayToList(eventTypes));
|
||||
eventTypeSet.addAll(CollectionUtils.<Class<TcpConnectionEvent>> arrayToList(eventTypes));
|
||||
this.eventTypes = eventTypeSet;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* 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.
|
||||
@@ -26,10 +26,10 @@ import org.springframework.util.CollectionUtils;
|
||||
/**
|
||||
* @author Jonas Partner
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class SecurityTestUtils {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static SecurityContext createContext(String username, String password, String... roles) {
|
||||
SecurityContextImpl ctxImpl = new SecurityContextImpl();
|
||||
UsernamePasswordAuthenticationToken authToken;
|
||||
@@ -38,7 +38,8 @@ public class SecurityTestUtils {
|
||||
for (int i = 0; i < roles.length; i++) {
|
||||
authorities[i] = new SimpleGrantedAuthority(roles[i]);
|
||||
}
|
||||
authToken = new UsernamePasswordAuthenticationToken(username, password, CollectionUtils.arrayToList(authorities));
|
||||
authToken = new UsernamePasswordAuthenticationToken(username, password,
|
||||
CollectionUtils.<GrantedAuthority> arrayToList(authorities));
|
||||
}
|
||||
else {
|
||||
authToken = new UsernamePasswordAuthenticationToken(username, password);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* 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.
|
||||
@@ -23,13 +23,13 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.MessageHandlingException;
|
||||
import org.springframework.integration.MessageRejectedException;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.xml.AggregatedXmlMessageValidationException;
|
||||
import org.springframework.integration.xml.DefaultXmlPayloadConverter;
|
||||
import org.springframework.integration.xml.XmlPayloadConverter;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -39,6 +39,7 @@ import org.springframework.xml.validation.XmlValidatorFactory;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
public class XmlValidatingMessageSelector implements MessageSelector {
|
||||
@@ -62,7 +63,7 @@ public class XmlValidatingMessageSelector implements MessageSelector {
|
||||
* the provided 'schema' location {@link Resource} and 'schemaType'. The valid options for schema
|
||||
* type are {@link XmlValidatorFactory#SCHEMA_W3C_XML} or {@link XmlValidatorFactory#SCHEMA_RELAX_NG}.
|
||||
* If no 'schemaType' is provided it will default to {@link XmlValidatorFactory#SCHEMA_W3C_XML};
|
||||
*
|
||||
*
|
||||
* @throws IOException if the XmlValidatorFactory fails to create a validator
|
||||
*/
|
||||
public XmlValidatingMessageSelector(Resource schema, String schemaType) throws IOException {
|
||||
@@ -86,7 +87,6 @@ public class XmlValidatingMessageSelector implements MessageSelector {
|
||||
this.converter = converter;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean accept(Message<?> message) {
|
||||
SAXParseException[] validationExceptions = null;
|
||||
try {
|
||||
@@ -98,8 +98,9 @@ public class XmlValidatingMessageSelector implements MessageSelector {
|
||||
boolean validationSuccess = ObjectUtils.isEmpty(validationExceptions);
|
||||
if (!validationSuccess) {
|
||||
if (this.throwExceptionOnRejection) {
|
||||
throw new MessageRejectedException(message, "Message was rejected due to XML Validation errors",
|
||||
new AggregatedXmlMessageValidationException(CollectionUtils.arrayToList(validationExceptions)));
|
||||
throw new MessageRejectedException(message, "Message was rejected due to XML Validation errors",
|
||||
new AggregatedXmlMessageValidationException(
|
||||
CollectionUtils.<Throwable> arrayToList(validationExceptions)));
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Message was rejected due to XML Validation errors");
|
||||
|
||||
Reference in New Issue
Block a user