Consistent use of ClassUtils.toClassArray (and related polishing)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -234,7 +234,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
|
||||
@Override
|
||||
public Class<?>[] getProxiedInterfaces() {
|
||||
return this.interfaces.toArray(new Class<?>[this.interfaces.size()]);
|
||||
return ClassUtils.toClassArray(this.interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -104,7 +104,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||
|
||||
@Override
|
||||
public Class<?>[] getInterfaces() {
|
||||
return this.interfaces.toArray(new Class<?>[this.interfaces.size()]);
|
||||
return ClassUtils.toClassArray(this.interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -53,15 +53,15 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable {
|
||||
* due to the delegate implementing it. Call this method to exclude
|
||||
* internal interfaces from being visible at the proxy level.
|
||||
* <p>Does nothing if the interface is not implemented by the delegate.
|
||||
* @param intf the interface to suppress
|
||||
* @param ifc the interface to suppress
|
||||
*/
|
||||
public void suppressInterface(Class<?> intf) {
|
||||
this.publishedInterfaces.remove(intf);
|
||||
public void suppressInterface(Class<?> ifc) {
|
||||
this.publishedInterfaces.remove(ifc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?>[] getInterfaces() {
|
||||
return this.publishedInterfaces.toArray(new Class<?>[this.publishedInterfaces.size()]);
|
||||
return ClassUtils.toClassArray(this.publishedInterfaces);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1742,7 +1742,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
if (targetType != null && targetType != obj.getClass()) {
|
||||
sources.add(targetType);
|
||||
}
|
||||
return sources.toArray(new Object[sources.size()]);
|
||||
return sources.toArray();
|
||||
}
|
||||
|
||||
private RootBeanDefinition getRootBeanDefinition(String beanName) {
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.cache.jcache.interceptor;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
@@ -13,10 +29,9 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Spring's {@link KeyGenerator} implementation that either delegates to a
|
||||
* standard JSR-107 {@link javax.cache.annotation.CacheKeyGenerator}, or
|
||||
* wrap a standard {@link KeyGenerator} so that only relevant parameters
|
||||
* are handled.
|
||||
* Spring's {@link KeyGenerator} implementation that either delegates to a standard JSR-107
|
||||
* {@link javax.cache.annotation.CacheKeyGenerator}, or wrap a standard {@link KeyGenerator}
|
||||
* so that only relevant parameters are handled.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.1
|
||||
@@ -29,12 +44,13 @@ class KeyGeneratorAdapter implements KeyGenerator {
|
||||
|
||||
private CacheKeyGenerator cacheKeyGenerator;
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance with the given {@link KeyGenerator} so that {@link javax.cache.annotation.CacheKey}
|
||||
* and {@link javax.cache.annotation.CacheValue} are handled according to the spec.
|
||||
*/
|
||||
public KeyGeneratorAdapter(JCacheOperationSource cacheOperationSource, KeyGenerator target) {
|
||||
Assert.notNull(cacheOperationSource, "cacheOperationSource must not be null.");
|
||||
Assert.notNull(cacheOperationSource, "JCacheOperationSource must not be null");
|
||||
Assert.notNull(target, "KeyGenerator must not be null");
|
||||
this.cacheOperationSource = cacheOperationSource;
|
||||
this.keyGenerator = target;
|
||||
@@ -44,12 +60,13 @@ class KeyGeneratorAdapter implements KeyGenerator {
|
||||
* Create an instance used to wrap the specified {@link javax.cache.annotation.CacheKeyGenerator}.
|
||||
*/
|
||||
public KeyGeneratorAdapter(JCacheOperationSource cacheOperationSource, CacheKeyGenerator target) {
|
||||
Assert.notNull(cacheOperationSource, "cacheOperationSource must not be null.");
|
||||
Assert.notNull(target, "KeyGenerator must not be null");
|
||||
Assert.notNull(cacheOperationSource, "JCacheOperationSource must not be null");
|
||||
Assert.notNull(target, "CacheKeyGenerator must not be null");
|
||||
this.cacheOperationSource = cacheOperationSource;
|
||||
this.cacheKeyGenerator = target;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the target key generator to use in the form of either a {@link KeyGenerator}
|
||||
* or a {@link CacheKeyGenerator}.
|
||||
@@ -58,7 +75,6 @@ class KeyGeneratorAdapter implements KeyGenerator {
|
||||
return (this.keyGenerator != null ? this.keyGenerator : this.cacheKeyGenerator);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object generate(Object target, Method method, Object... params) {
|
||||
JCacheOperation<?> operation = this.cacheOperationSource.getCacheOperation(method, target.getClass());
|
||||
@@ -88,15 +104,14 @@ class KeyGeneratorAdapter implements KeyGenerator {
|
||||
parameters.add(value);
|
||||
}
|
||||
}
|
||||
return keyGenerator.generate(context.getTarget(), context.getMethod(),
|
||||
parameters.toArray(new Object[parameters.size()]));
|
||||
|
||||
return keyGenerator.generate(context.getTarget(), context.getMethod(), parameters.toArray());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private CacheKeyInvocationContext<?> createCacheKeyInvocationContext(Object target,
|
||||
JCacheOperation<?> operation, Object[] params) {
|
||||
private CacheKeyInvocationContext<?> createCacheKeyInvocationContext(
|
||||
Object target, JCacheOperation<?> operation, Object[] params) {
|
||||
|
||||
AbstractJCacheKeyOperation<Annotation> keyCacheOperation = (AbstractJCacheKeyOperation<Annotation>) operation;
|
||||
return new DefaultCacheKeyInvocationContext<Annotation>(keyCacheOperation, target, params);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -330,7 +330,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
|
||||
resolvedArgs.add(arg);
|
||||
}
|
||||
}
|
||||
return resolvedArgs.toArray(new Object[resolvedArgs.size()]);
|
||||
return resolvedArgs.toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -17,9 +17,9 @@
|
||||
package org.springframework.validation.beanvalidation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -34,6 +34,7 @@ import org.springframework.beans.NotReadablePropertyException;
|
||||
import org.springframework.context.MessageSourceResolvable;
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.FieldError;
|
||||
@@ -115,7 +116,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
|
||||
}
|
||||
}
|
||||
processConstraintViolations(
|
||||
this.targetValidator.validate(target, groups.toArray(new Class<?>[groups.size()])), errors);
|
||||
this.targetValidator.validate(target, ClassUtils.toClassArray(groups)), errors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +216,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
|
||||
* @see org.springframework.validation.DefaultBindingErrorProcessor#getArgumentsForBindError
|
||||
*/
|
||||
protected Object[] getArgumentsForConstraint(String objectName, String field, ConstraintDescriptor<?> descriptor) {
|
||||
List<Object> arguments = new LinkedList<Object>();
|
||||
List<Object> arguments = new ArrayList<Object>();
|
||||
arguments.add(getResolvableField(objectName, field));
|
||||
// Using a TreeMap for alphabetical ordering of attribute names
|
||||
Map<String, Object> attributesToExpose = new TreeMap<String, Object>();
|
||||
@@ -230,7 +231,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
|
||||
}
|
||||
}
|
||||
arguments.addAll(attributesToExpose.values());
|
||||
return arguments.toArray(new Object[arguments.size()]);
|
||||
return arguments.toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -1064,11 +1064,12 @@ public abstract class ClassUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the given Collection into a Class array.
|
||||
* The Collection must contain Class elements only.
|
||||
* @param collection the Collection to copy
|
||||
* @return the Class array ({@code null} if the passed-in
|
||||
* Collection was {@code null})
|
||||
* Copy the given {@code Collection} into a {@code Class} array.
|
||||
* <p>The {@code Collection} must contain {@code Class} elements only.
|
||||
* @param collection the {@code Collection} to copy
|
||||
* @return the {@code Class} array
|
||||
* @since 3.1
|
||||
* @see StringUtils#toStringArray
|
||||
*/
|
||||
public static Class<?>[] toClassArray(Collection<Class<?>> collection) {
|
||||
if (collection == null) {
|
||||
@@ -1109,8 +1110,7 @@ public abstract class ClassUtils {
|
||||
* @return all interfaces that the given object implements as an array
|
||||
*/
|
||||
public static Class<?>[] getAllInterfacesForClass(Class<?> clazz, ClassLoader classLoader) {
|
||||
Set<Class<?>> ifcs = getAllInterfacesForClassAsSet(clazz, classLoader);
|
||||
return ifcs.toArray(new Class<?>[ifcs.size()]);
|
||||
return toClassArray(getAllInterfacesForClassAsSet(clazz, classLoader));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1150,12 +1150,13 @@ public abstract class ClassUtils {
|
||||
return Collections.<Class<?>>singleton(clazz);
|
||||
}
|
||||
Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
|
||||
while (clazz != null) {
|
||||
Class<?>[] ifcs = clazz.getInterfaces();
|
||||
Class<?> current = clazz;
|
||||
while (current != null) {
|
||||
Class<?>[] ifcs = current.getInterfaces();
|
||||
for (Class<?> ifc : ifcs) {
|
||||
interfaces.addAll(getAllInterfacesForClassAsSet(ifc, classLoader));
|
||||
}
|
||||
clazz = clazz.getSuperclass();
|
||||
current = current.getSuperclass();
|
||||
}
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -824,13 +824,9 @@ public abstract class StringUtils {
|
||||
return array1;
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<String>();
|
||||
Set<String> result = new LinkedHashSet<String>();
|
||||
result.addAll(Arrays.asList(array1));
|
||||
for (String str : array2) {
|
||||
if (!result.contains(str)) {
|
||||
result.add(str);
|
||||
}
|
||||
}
|
||||
result.addAll(Arrays.asList(array2));
|
||||
return toStringArray(result);
|
||||
}
|
||||
|
||||
@@ -858,7 +854,6 @@ public abstract class StringUtils {
|
||||
if (collection == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return collection.toArray(new String[collection.size()]);
|
||||
}
|
||||
|
||||
@@ -872,9 +867,7 @@ public abstract class StringUtils {
|
||||
if (enumeration == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> list = Collections.list(enumeration);
|
||||
return list.toArray(new String[list.size()]);
|
||||
return toStringArray(Collections.list(enumeration));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -939,10 +932,9 @@ public abstract class StringUtils {
|
||||
|
||||
/**
|
||||
* Take an array of strings and split each element based on the given delimiter.
|
||||
* A {@code Properties} instance is then generated, with the left of the
|
||||
* delimiter providing the key, and the right of the delimiter providing the value.
|
||||
* <p>Will trim both the key and value before adding them to the
|
||||
* {@code Properties} instance.
|
||||
* A {@code Properties} instance is then generated, with the left of the delimiter
|
||||
* providing the key, and the right of the delimiter providing the value.
|
||||
* <p>Will trim both the key and value before adding them to the {@code Properties}.
|
||||
* @param array the array to process
|
||||
* @param delimiter to split each element using (typically the equals symbol)
|
||||
* @return a {@code Properties} instance representing the array contents,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -458,15 +458,18 @@ public abstract class AbstractJdbcInsert {
|
||||
"Current database only supports retrieving the key for a single column. There are " +
|
||||
getGeneratedKeyNames().length + " columns specified: " + Arrays.asList(getGeneratedKeyNames()));
|
||||
}
|
||||
// This is a hack to be able to get the generated key from a database that doesn't support
|
||||
// get generated keys feature. HSQL is one, PostgreSQL is another. Postgres uses a RETURNING
|
||||
// clause while HSQL uses a second query that has to be executed with the same connection.
|
||||
|
||||
final String keyQuery = this.tableMetaDataContext.getSimulationQueryForGetGeneratedKey(
|
||||
this.tableMetaDataContext.getTableName(), getGeneratedKeyNames()[0]);
|
||||
Assert.notNull(keyQuery, "Query for simulating get generated keys can't be null");
|
||||
|
||||
// This is a hack to be able to get the generated key from a database that doesn't support
|
||||
// get generated keys feature. HSQL is one, PostgreSQL is another. Postgres uses a RETURNING
|
||||
// clause while HSQL uses a second query that has to be executed with the same connection.
|
||||
|
||||
if (keyQuery.toUpperCase().startsWith("RETURNING")) {
|
||||
Long key = getJdbcTemplate().queryForObject(getInsertString() + " " + keyQuery,
|
||||
values.toArray(new Object[values.size()]), Long.class);
|
||||
Long key = getJdbcTemplate().queryForObject(
|
||||
getInsertString() + " " + keyQuery, values.toArray(), Long.class);
|
||||
Map<String, Object> keys = new HashMap<String, Object>(1);
|
||||
keys.put(getGeneratedKeyNames()[0], key);
|
||||
keyHolder.getKeyList().add(keys);
|
||||
@@ -506,8 +509,8 @@ public abstract class AbstractJdbcInsert {
|
||||
}
|
||||
});
|
||||
}
|
||||
return keyHolder;
|
||||
}
|
||||
|
||||
return keyHolder;
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -395,11 +395,11 @@ public abstract class AbstractEntityManagerFactoryBean implements
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a proxy of the given EntityManagerFactory. We do this to be able
|
||||
* to return transaction-aware proxies for application-managed
|
||||
* EntityManagers, and to introduce the NamedEntityManagerFactory interface
|
||||
* @param emf EntityManagerFactory as returned by the persistence provider
|
||||
* @return proxy entity manager
|
||||
* Create a proxy for the given {@link EntityManagerFactory}. We do this to be able to
|
||||
* return a transaction-aware proxy for an application-managed {@link EntityManager}.
|
||||
* @param emf the EntityManagerFactory as returned by the persistence provider,
|
||||
* if initialized already
|
||||
* @return the EntityManagerFactory proxy
|
||||
*/
|
||||
protected EntityManagerFactory createEntityManagerFactoryProxy(EntityManagerFactory emf) {
|
||||
Set<Class<?>> ifcs = new LinkedHashSet<Class<?>>();
|
||||
@@ -415,9 +415,8 @@ public abstract class AbstractEntityManagerFactoryBean implements
|
||||
}
|
||||
ifcs.add(EntityManagerFactoryInfo.class);
|
||||
try {
|
||||
return (EntityManagerFactory) Proxy.newProxyInstance(
|
||||
this.beanClassLoader, ifcs.toArray(new Class<?>[ifcs.size()]),
|
||||
new ManagedEntityManagerFactoryInvocationHandler(this));
|
||||
return (EntityManagerFactory) Proxy.newProxyInstance(this.beanClassLoader,
|
||||
ClassUtils.toClassArray(ifcs), new ManagedEntityManagerFactoryInvocationHandler(this));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
if (entityManagerFactoryInterface != null) {
|
||||
@@ -608,9 +607,8 @@ public abstract class AbstractEntityManagerFactoryBean implements
|
||||
|
||||
|
||||
/**
|
||||
* Dynamic proxy invocation handler proxying an EntityManagerFactory to
|
||||
* return a proxy EntityManager if necessary from createEntityManager()
|
||||
* methods.
|
||||
* Dynamic proxy invocation handler for an {@link EntityManagerFactory}, returning a
|
||||
* proxy {@link EntityManager} (if necessary) from {@code createEntityManager} methods.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private static class ManagedEntityManagerFactoryInvocationHandler implements InvocationHandler, Serializable {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -231,7 +231,7 @@ public abstract class ExtendedEntityManagerCreator {
|
||||
ifcs.add(EntityManagerProxy.class);
|
||||
return (EntityManager) Proxy.newProxyInstance(
|
||||
(cl != null ? cl : ExtendedEntityManagerCreator.class.getClassLoader()),
|
||||
ifcs.toArray(new Class<?>[ifcs.size()]),
|
||||
ClassUtils.toClassArray(ifcs),
|
||||
new ExtendedEntityManagerInvocationHandler(
|
||||
rawEm, exceptionTranslator, jta, containerManaged, synchronizedWithTransaction));
|
||||
}
|
||||
@@ -427,6 +427,7 @@ public abstract class ExtendedEntityManagerCreator {
|
||||
|
||||
public ExtendedEntityManagerSynchronization(
|
||||
EntityManager em, PersistenceExceptionTranslator exceptionTranslator) {
|
||||
|
||||
super(new EntityManagerHolder(em), em);
|
||||
this.entityManager = em;
|
||||
this.exceptionTranslator = exceptionTranslator;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -92,7 +92,7 @@ class ClassPathJaxb2TypeScanner {
|
||||
}
|
||||
}
|
||||
}
|
||||
return jaxb2Classes.toArray(new Class<?>[jaxb2Classes.size()]);
|
||||
return ClassUtils.toClassArray(jaxb2Classes);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new UncategorizedMappingException("Failed to scan classpath for unlisted classes", ex);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -27,6 +27,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.test.context.SmartContextLoader;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Utility methods for {@link SmartContextLoader SmartContextLoaders} that deal
|
||||
@@ -84,7 +85,7 @@ public abstract class AnnotationConfigContextLoaderUtils {
|
||||
}
|
||||
}
|
||||
|
||||
return configClasses.toArray(new Class<?>[configClasses.size()]);
|
||||
return ClassUtils.toClassArray(configClasses);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.context.annotation.AnnotationConfigUtils;
|
||||
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
|
||||
import org.springframework.context.annotation.ScopeMetadataResolver;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
@@ -207,7 +208,7 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
|
||||
logger.info("Registering annotated classes: [" +
|
||||
StringUtils.collectionToCommaDelimitedString(this.annotatedClasses) + "]");
|
||||
}
|
||||
reader.register(this.annotatedClasses.toArray(new Class<?>[this.annotatedClasses.size()]));
|
||||
reader.register(ClassUtils.toClassArray(this.annotatedClasses));
|
||||
}
|
||||
|
||||
if (!this.basePackages.isEmpty()) {
|
||||
|
||||
@@ -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.
|
||||
@@ -329,7 +329,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
|
||||
* @return the array of {@link MappedInterceptor}s, or {@code null} if none
|
||||
*/
|
||||
protected final MappedInterceptor[] getMappedInterceptors() {
|
||||
List<MappedInterceptor> mappedInterceptors = new ArrayList<MappedInterceptor>();
|
||||
List<MappedInterceptor> mappedInterceptors = new ArrayList<MappedInterceptor>(this.adaptedInterceptors.size());
|
||||
for (HandlerInterceptor interceptor : this.adaptedInterceptors) {
|
||||
if (interceptor instanceof MappedInterceptor) {
|
||||
mappedInterceptors.add((MappedInterceptor) interceptor);
|
||||
|
||||
@@ -73,7 +73,6 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
|
||||
|
||||
@Override
|
||||
public StompWebSocketEndpointRegistration setHandshakeHandler(HandshakeHandler handshakeHandler) {
|
||||
Assert.notNull(handshakeHandler, "'handshakeHandler' must not be null");
|
||||
this.handshakeHandler = handshakeHandler;
|
||||
return this;
|
||||
}
|
||||
@@ -113,7 +112,7 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
|
||||
}
|
||||
|
||||
protected HandshakeInterceptor[] getInterceptors() {
|
||||
List<HandshakeInterceptor> interceptors = new ArrayList<HandshakeInterceptor>();
|
||||
List<HandshakeInterceptor> interceptors = new ArrayList<HandshakeInterceptor>(this.interceptors.size() + 1);
|
||||
interceptors.addAll(this.interceptors);
|
||||
interceptors.add(new OriginHandshakeInterceptor(this.allowedOrigins));
|
||||
return interceptors.toArray(new HandshakeInterceptor[interceptors.size()]);
|
||||
@@ -124,7 +123,7 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE
|
||||
if (this.registration != null) {
|
||||
SockJsService sockJsService = this.registration.getSockJsService();
|
||||
for (String path : this.paths) {
|
||||
String pattern = path.endsWith("/") ? path + "**" : path + "/**";
|
||||
String pattern = (path.endsWith("/") ? path + "**" : path + "/**");
|
||||
SockJsHttpRequestHandler handler = new SockJsHttpRequestHandler(sockJsService, this.webSocketHandler);
|
||||
mappings.add(handler, pattern);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user