Consistent use of ClassUtils.toClassArray (and related polishing)

This commit is contained in:
Juergen Hoeller
2018-02-22 14:27:57 +01:00
parent caed04473e
commit 8b071633d3
20 changed files with 110 additions and 104 deletions

View File

@@ -265,10 +265,8 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
if (target instanceof TopicSession) {
classes.add(TopicSession.class);
}
return (Session) Proxy.newProxyInstance(
SessionProxy.class.getClassLoader(),
classes.toArray(new Class<?>[classes.size()]),
new CachedSessionInvocationHandler(target, sessionList));
return (Session) Proxy.newProxyInstance(SessionProxy.class.getClassLoader(),
ClassUtils.toClassArray(classes), new CachedSessionInvocationHandler(target, sessionList));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -40,6 +40,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
* A JMS ConnectionFactory adapter that returns the same Connection
@@ -481,10 +482,8 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
if (target instanceof TopicConnection) {
classes.add(TopicConnection.class);
}
return (Connection) Proxy.newProxyInstance(
Connection.class.getClassLoader(),
classes.toArray(new Class<?>[classes.size()]),
new SharedConnectionInvocationHandler());
return (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(),
ClassUtils.toClassArray(classes), new SharedConnectionInvocationHandler());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -35,6 +35,7 @@ import javax.jms.TopicSession;
import javax.jms.TransactionInProgressException;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
* Proxy for a target JMS {@link javax.jms.ConnectionFactory}, adding awareness of
@@ -204,10 +205,8 @@ public class TransactionAwareConnectionFactoryProxy
if (target instanceof TopicConnection) {
classes.add(TopicConnection.class);
}
return (Connection) Proxy.newProxyInstance(
Connection.class.getClassLoader(),
classes.toArray(new Class<?>[classes.size()]),
new TransactionAwareConnectionInvocationHandler(target));
return (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(),
ClassUtils.toClassArray(classes), new TransactionAwareConnectionInvocationHandler(target));
}
@@ -276,10 +275,8 @@ public class TransactionAwareConnectionFactoryProxy
if (target instanceof TopicSession) {
classes.add(TopicSession.class);
}
return (Session) Proxy.newProxyInstance(
SessionProxy.class.getClassLoader(),
classes.toArray(new Class<?>[classes.size()]),
new CloseSuppressingSessionInvocationHandler(target));
return (Session) Proxy.newProxyInstance(SessionProxy.class.getClassLoader(),
ClassUtils.toClassArray(classes), new CloseSuppressingSessionInvocationHandler(target));
}
}