Polishing

This commit is contained in:
Juergen Hoeller 2017-02-15 18:05:38 +01:00
parent 5f531a7a7d
commit 599c1ba73e
3 changed files with 22 additions and 27 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@ -18,10 +18,7 @@ package org.springframework.validation.beanvalidation;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@ -51,7 +48,6 @@ import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ReflectionUtils;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 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.
@ -95,12 +95,12 @@ public class WebSphereDataSourceAdapter extends IsolationLevelDataSourceAdapter
Class<?> wsrraFactoryClass = getClass().getClassLoader().loadClass("com.ibm.websphere.rsadapter.WSRRAFactory");
this.newJdbcConnSpecMethod = wsrraFactoryClass.getMethod("createJDBCConnectionSpec", (Class<?>[]) null);
this.wsDataSourceGetConnectionMethod =
this.wsDataSourceClass.getMethod("getConnection", new Class<?>[] {jdbcConnSpecClass});
this.wsDataSourceClass.getMethod("getConnection", jdbcConnSpecClass);
this.setTransactionIsolationMethod =
jdbcConnSpecClass.getMethod("setTransactionIsolation", new Class<?>[] {int.class});
this.setReadOnlyMethod = jdbcConnSpecClass.getMethod("setReadOnly", new Class<?>[] {Boolean.class});
this.setUserNameMethod = jdbcConnSpecClass.getMethod("setUserName", new Class<?>[] {String.class});
this.setPasswordMethod = jdbcConnSpecClass.getMethod("setPassword", new Class<?>[] {String.class});
jdbcConnSpecClass.getMethod("setTransactionIsolation", int.class);
this.setReadOnlyMethod = jdbcConnSpecClass.getMethod("setReadOnly", Boolean.class);
this.setUserNameMethod = jdbcConnSpecClass.getMethod("setUserName", String.class);
this.setPasswordMethod = jdbcConnSpecClass.getMethod("setPassword", String.class);
}
catch (Exception ex) {
throw new IllegalStateException(
@ -144,7 +144,7 @@ public class WebSphereDataSourceAdapter extends IsolationLevelDataSourceAdapter
}
/**
* Create a WebSphere {@code JDBCConnectionSpec} object for the given charateristics.
* Create a WebSphere {@code JDBCConnectionSpec} object for the given characteristics.
* <p>The default implementation uses reflection to apply the given settings.
* Can be overridden in subclasses to customize the JDBCConnectionSpec object
* (<a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/topic/com.ibm.websphere.javadoc.doc/public_html/api/com/ibm/websphere/rsadapter/JDBCConnectionSpec.html">JDBCConnectionSpec javadoc</a>;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@ -34,7 +34,7 @@ import org.springframework.util.Assert;
* @see org.springframework.aop.framework.AopProxyUtils
* @see ReflectionTestUtils
*/
public class AopTestUtils {
public abstract class AopTestUtils {
/**
* Get the <em>target</em> object of the supplied {@code candidate} object.
@ -42,22 +42,22 @@ public class AopTestUtils {
* {@linkplain AopUtils#isAopProxy proxy}, the target of the proxy will
* be returned; otherwise, the {@code candidate} will be returned
* <em>as is</em>.
* @param candidate the instance to check (potentially a Spring AOP proxy);
* never {@code null}
* @return the target object or the {@code candidate}; never {@code null}
* @param candidate the instance to check (potentially a Spring AOP proxy;
* never {@code null})
* @return the target object or the {@code candidate} (never {@code null})
* @throws IllegalStateException if an error occurs while unwrapping a proxy
* @see Advised#getTargetSource()
* @see #getUltimateTargetObject
*/
@SuppressWarnings("unchecked")
public static <T> T getTargetObject(Object candidate) {
Assert.notNull(candidate, "candidate must not be null");
Assert.notNull(candidate, "Candidate must not be null");
try {
if (AopUtils.isAopProxy(candidate) && (candidate instanceof Advised)) {
if (AopUtils.isAopProxy(candidate) && candidate instanceof Advised) {
return (T) ((Advised) candidate).getTargetSource().getTarget();
}
}
catch (Exception ex) {
catch (Throwable ex) {
throw new IllegalStateException("Failed to unwrap proxied object", ex);
}
return (T) candidate;
@ -71,23 +71,22 @@ public class AopTestUtils {
* {@linkplain AopUtils#isAopProxy proxy}, the ultimate target of all
* nested proxies will be returned; otherwise, the {@code candidate}
* will be returned <em>as is</em>.
* @param candidate the instance to check (potentially a Spring AOP proxy);
* never {@code null}
* @return the ultimate target object or the {@code candidate}; never
* {@code null}
* @param candidate the instance to check (potentially a Spring AOP proxy;
* never {@code null})
* @return the target object or the {@code candidate} (never {@code null})
* @throws IllegalStateException if an error occurs while unwrapping a proxy
* @see Advised#getTargetSource()
* @see org.springframework.aop.framework.AopProxyUtils#ultimateTargetClass
*/
@SuppressWarnings("unchecked")
public static <T> T getUltimateTargetObject(Object candidate) {
Assert.notNull(candidate, "candidate must not be null");
Assert.notNull(candidate, "Candidate must not be null");
try {
if (AopUtils.isAopProxy(candidate) && (candidate instanceof Advised)) {
if (AopUtils.isAopProxy(candidate) && candidate instanceof Advised) {
return (T) getUltimateTargetObject(((Advised) candidate).getTargetSource().getTarget());
}
}
catch (Exception ex) {
catch (Throwable ex) {
throw new IllegalStateException("Failed to unwrap proxied object", ex);
}
return (T) candidate;