Deprecate outdated abstractions/delegates in core/util
Issue: SPR-15159
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -22,8 +22,6 @@ import java.lang.reflect.Method;
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.MethodMatcher;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.core.ControlFlow;
|
||||
import org.springframework.core.ControlFlowFactory;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -34,7 +32,7 @@ import org.springframework.util.ObjectUtils;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Rob Harrop
|
||||
* @see org.springframework.core.ControlFlow
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher, Serializable {
|
||||
@@ -43,7 +41,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||
|
||||
private String methodName;
|
||||
|
||||
private int evaluations;
|
||||
private volatile int evaluations;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,11 +53,11 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new pointcut that matches all calls below the
|
||||
* given method in the given class. If the method name is null,
|
||||
* matches all control flows below that class.
|
||||
* Construct a new pointcut that matches all calls below the given method
|
||||
* in the given class. If no method name is given, matches all control flows
|
||||
* below the given class.
|
||||
* @param clazz the clazz
|
||||
* @param methodName the name of the method
|
||||
* @param methodName the name of the method (may be {@code null})
|
||||
*/
|
||||
public ControlFlowPointcut(Class<?> clazz, String methodName) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
@@ -93,8 +91,14 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||
@Override
|
||||
public boolean matches(Method method, Class<?> targetClass, Object... args) {
|
||||
this.evaluations++;
|
||||
ControlFlow cflow = ControlFlowFactory.createControlFlow();
|
||||
return (this.methodName != null ? cflow.under(this.clazz, this.methodName) : cflow.under(this.clazz));
|
||||
|
||||
for (StackTraceElement element : new Throwable().getStackTrace()) {
|
||||
if (element.getClassName().equals(this.clazz.getName()) &&
|
||||
(this.methodName == null || element.getMethodName().equals(this.methodName))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,8 +134,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int code = 17;
|
||||
code = 37 * code + this.clazz.hashCode();
|
||||
int code = this.clazz.hashCode();
|
||||
if (this.methodName != null) {
|
||||
code = 37 * code + this.methodName.hashCode();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -18,8 +18,6 @@ package org.springframework.beans;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
import org.springframework.core.ErrorCoded;
|
||||
|
||||
/**
|
||||
* Superclass for exceptions related to a property access,
|
||||
* such as type mismatch or invocation target exception.
|
||||
@@ -27,8 +25,8 @@ import org.springframework.core.ErrorCoded;
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class PropertyAccessException extends BeansException implements ErrorCoded {
|
||||
@SuppressWarnings({"serial", "deprecation"})
|
||||
public abstract class PropertyAccessException extends BeansException implements org.springframework.core.ErrorCoded {
|
||||
|
||||
private transient PropertyChangeEvent propertyChangeEvent;
|
||||
|
||||
@@ -77,4 +75,10 @@ public abstract class PropertyAccessException extends BeansException implements
|
||||
return (this.propertyChangeEvent != null ? this.propertyChangeEvent.getNewValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a corresponding error code for this type of exception.
|
||||
*/
|
||||
@Override
|
||||
public abstract String getErrorCode();
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -23,7 +23,9 @@ package org.springframework.core;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @since 02.02.2004
|
||||
* @deprecated as of Spring Framework 4.3.6
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ControlFlow {
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -31,7 +31,9 @@ import org.springframework.util.Assert;
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @since 02.02.2004
|
||||
* @deprecated as of Spring Framework 4.3.6
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class ControlFlowFactory {
|
||||
|
||||
/**
|
||||
@@ -65,8 +67,8 @@ public abstract class ControlFlowFactory {
|
||||
public boolean under(Class<?> clazz) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
String className = clazz.getName();
|
||||
for (int i = 0; i < stack.length; i++) {
|
||||
if (this.stack[i].getClassName().equals(className)) {
|
||||
for (StackTraceElement element : this.stack) {
|
||||
if (element.getClassName().equals(className)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -82,9 +84,9 @@ public abstract class ControlFlowFactory {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
Assert.notNull(methodName, "Method name must not be null");
|
||||
String className = clazz.getName();
|
||||
for (int i = 0; i < this.stack.length; i++) {
|
||||
if (this.stack[i].getClassName().equals(className) &&
|
||||
this.stack[i].getMethodName().equals(methodName)) {
|
||||
for (StackTraceElement element : this.stack) {
|
||||
if (element.getClassName().equals(className) &&
|
||||
element.getMethodName().equals(methodName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -103,7 +105,7 @@ public abstract class ControlFlowFactory {
|
||||
StringWriter sw = new StringWriter();
|
||||
new Throwable().printStackTrace(new PrintWriter(sw));
|
||||
String stackTrace = sw.toString();
|
||||
return stackTrace.indexOf(token) != -1;
|
||||
return stackTrace.contains(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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.
|
||||
@@ -25,7 +25,9 @@ package org.springframework.core;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @see org.springframework.context.MessageSource
|
||||
* @deprecated as of Spring Framework 4.3.6
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ErrorCoded {
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
@@ -44,7 +44,9 @@ import org.apache.commons.logging.LogFactory;
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.2
|
||||
* @see #monitor
|
||||
* @deprecated as of Spring Framework 4.3.6
|
||||
*/
|
||||
@Deprecated
|
||||
public class WeakReferenceMonitor {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(WeakReferenceMonitor.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -24,6 +24,7 @@ import static org.junit.Assert.*;
|
||||
* @author Rod Johnson
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ControlFlowTests {
|
||||
|
||||
@Test
|
||||
@@ -33,6 +34,7 @@ public class ControlFlowTests {
|
||||
new Three().test();
|
||||
}
|
||||
|
||||
|
||||
static class One {
|
||||
|
||||
void test() {
|
||||
@@ -45,6 +47,7 @@ public class ControlFlowTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class Two {
|
||||
|
||||
void testing() {
|
||||
@@ -57,6 +60,7 @@ public class ControlFlowTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class Three {
|
||||
|
||||
void test() {
|
||||
|
||||
Reference in New Issue
Block a user