diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java index eb2ec2bbe2..f7e2da1f21 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.util; import java.beans.PropertyEditor; @@ -28,22 +29,23 @@ import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.support.ConversionServiceFactory; import org.springframework.expression.TypeConverter; import org.springframework.util.CollectionUtils; + /** - * * @author Dave Syer * @author Oleg Zhurakousky - * */ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware { - private SimpleTypeConverter delegate = new SimpleTypeConverter(); - private static ConversionService defaultConversionService; - private ConversionService conversionService; + + private volatile SimpleTypeConverter delegate = new SimpleTypeConverter(); + + private volatile ConversionService conversionService; + public BeanFactoryTypeConverter() { - synchronized (this) { + synchronized (BeanFactoryTypeConverter.class) { if (defaultConversionService == null) { defaultConversionService = ConversionServiceFactory.createDefaultConversionService(); } @@ -55,6 +57,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware this.conversionService = conversionService; } + public void setConversionService(ConversionService conversionService) { this.conversionService = conversionService; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/ClassUtils.java b/spring-integration-core/src/main/java/org/springframework/integration/util/ClassUtils.java index 86dbe0131c..5f2140e975 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/ClassUtils.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/ClassUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 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. diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java index 55dd816c7a..4cef507bb9 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java @@ -67,7 +67,6 @@ import org.springframework.util.StringUtils; * @author Mark Fisher * @author Oleg Zhurakousky * @author Dave Syer - * * @since 2.0 */ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator { @@ -86,6 +85,7 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator private final boolean canProcessMessageList; + public MessagingMethodInvokerHelper(Object targetObject, Method method, Class expectedType, boolean canProcessMessageList) { this(targetObject, null, method, expectedType, canProcessMessageList); @@ -114,6 +114,7 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator this(targetObject, annotationType, (String) null, expectedType, canProcessMessageList); } + public T process(Message message) throws Exception { ParametersWrapper parameters = new ParametersWrapper(message); return processInternal(parameters); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/UUIDConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/util/UUIDConverter.java index 2012d4ac0d..26690c29f6 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/UUIDConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/UUIDConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.util; import java.io.ByteArrayOutputStream; @@ -28,12 +29,12 @@ import org.springframework.util.ClassUtils; * Utility to help generate UUID instances from generic objects. * * @author Dave Syer - * */ public class UUIDConverter implements Converter { public static final String DEFAULT_CHARSET = "UTF-8"; + /** * Convert the input to a UUID using the convenience method * {@link #getUUID(Object)}. @@ -64,15 +65,12 @@ public class UUIDConverter implements Converter { * @return a UUID constructed from the input */ public static UUID getUUID(Object input) { - if (input == null) { return null; } - if (input instanceof UUID) { return (UUID) input; } - if (input instanceof String) { try { return UUID.fromString((String) input); @@ -86,7 +84,6 @@ public class UUIDConverter implements Converter { } } } - if (ClassUtils.isPrimitiveOrWrapper(input.getClass())) { try { return UUID.nameUUIDFromBytes(input.toString().getBytes(DEFAULT_CHARSET)); @@ -95,18 +92,14 @@ public class UUIDConverter implements Converter { throw new IllegalStateException("Cannot convert primitive using charset=" + DEFAULT_CHARSET, e); } } - byte[] bytes = serialize(input); return UUID.nameUUIDFromBytes(bytes); - } private static byte[] serialize(Object object) { - if (object == null) { return null; } - ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { new ObjectOutputStream(stream).writeObject(object); @@ -114,9 +107,7 @@ public class UUIDConverter implements Converter { catch (IOException e) { throw new IllegalArgumentException("Could not serialize object of type: " + object.getClass(), e); } - return stream.toByteArray(); - } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/UniqueMethodFilter.java b/spring-integration-core/src/main/java/org/springframework/integration/util/UniqueMethodFilter.java index 86248e7281..8fd37cec0e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/UniqueMethodFilter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/UniqueMethodFilter.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2010 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 + * + * 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. + */ + package org.springframework.integration.util; import java.lang.reflect.Method; @@ -13,16 +29,18 @@ import org.springframework.util.ReflectionUtils.MethodFilter; */ public class UniqueMethodFilter implements MethodFilter { - private List uniqueMethods = new ArrayList(); + private final List uniqueMethods = new ArrayList(); + public UniqueMethodFilter(Class targetClass) { ArrayList allMethods = new ArrayList(Arrays.asList(targetClass.getMethods())); for (Method method : allMethods) { - uniqueMethods.add(org.springframework.util.ClassUtils.getMostSpecificMethod(method, targetClass)); + this.uniqueMethods.add(org.springframework.util.ClassUtils.getMostSpecificMethod(method, targetClass)); } } public boolean matches(Method method) { - return uniqueMethods.contains(method); + return this.uniqueMethods.contains(method); } + } \ No newline at end of file diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/UpperBound.java b/spring-integration-core/src/main/java/org/springframework/integration/util/UpperBound.java index f8e286eb51..eb637b4aa5 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/UpperBound.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/UpperBound.java @@ -31,6 +31,7 @@ public final class UpperBound { public final Semaphore semaphore; + /** * Create an UpperBound with the given capacity. If the given capacity is less than 1 * an infinite UpperBound is created. @@ -39,6 +40,7 @@ public final class UpperBound { this.semaphore = (capacity > 0) ? new Semaphore(capacity, true) : null; } + /** * Acquires a permit from the underlying semaphore if this UpperBound is bounded and returns * true if it succeeds within the given timeout. If the timeout is less than 0, it will block