Skip to content

Commit ed40b1c

Browse files
committed
Remove outdated abstractions/delegates from core/util
Issue: SPR-15159
1 parent 6fe7e56 commit ed40b1c

File tree

10 files changed

+63
-544
lines changed

10 files changed

+63
-544
lines changed

spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,8 +22,6 @@
2222
import org.springframework.aop.ClassFilter;
2323
import org.springframework.aop.MethodMatcher;
2424
import org.springframework.aop.Pointcut;
25-
import org.springframework.core.ControlFlow;
26-
import org.springframework.core.ControlFlowFactory;
2725
import org.springframework.util.Assert;
2826
import org.springframework.util.ObjectUtils;
2927

@@ -34,7 +32,7 @@
3432
*
3533
* @author Rod Johnson
3634
* @author Rob Harrop
37-
* @see org.springframework.core.ControlFlow
35+
* @author Juergen Hoeller
3836
*/
3937
@SuppressWarnings("serial")
4038
public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher, Serializable {
@@ -43,7 +41,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
4341

4442
private String methodName;
4543

46-
private int evaluations;
44+
private volatile int evaluations;
4745

4846

4947
/**
@@ -55,11 +53,11 @@ public ControlFlowPointcut(Class<?> clazz) {
5553
}
5654

5755
/**
58-
* Construct a new pointcut that matches all calls below the
59-
* given method in the given class. If the method name is null,
60-
* matches all control flows below that class.
56+
* Construct a new pointcut that matches all calls below the given method
57+
* in the given class. If no method name is given, matches all control flows
58+
* below the given class.
6159
* @param clazz the clazz
62-
* @param methodName the name of the method
60+
* @param methodName the name of the method (may be {@code null})
6361
*/
6462
public ControlFlowPointcut(Class<?> clazz, String methodName) {
6563
Assert.notNull(clazz, "Class must not be null");
@@ -93,8 +91,14 @@ public boolean isRuntime() {
9391
@Override
9492
public boolean matches(Method method, Class<?> targetClass, Object... args) {
9593
this.evaluations++;
96-
ControlFlow cflow = ControlFlowFactory.createControlFlow();
97-
return (this.methodName != null ? cflow.under(this.clazz, this.methodName) : cflow.under(this.clazz));
94+
95+
for (StackTraceElement element : new Throwable().getStackTrace()) {
96+
if (element.getClassName().equals(this.clazz.getName()) &&
97+
(this.methodName == null || element.getMethodName().equals(this.methodName))) {
98+
return true;
99+
}
100+
}
101+
return false;
98102
}
99103

100104
/**
@@ -130,8 +134,7 @@ public boolean equals(Object other) {
130134

131135
@Override
132136
public int hashCode() {
133-
int code = 17;
134-
code = 37 * code + this.clazz.hashCode();
137+
int code = this.clazz.hashCode();
135138
if (this.methodName != null) {
136139
code = 37 * code + this.methodName.hashCode();
137140
}

spring-beans/src/main/java/org/springframework/beans/PropertyAccessException.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,8 +18,6 @@
1818

1919
import java.beans.PropertyChangeEvent;
2020

21-
import org.springframework.core.ErrorCoded;
22-
2321
/**
2422
* Superclass for exceptions related to a property access,
2523
* such as type mismatch or invocation target exception.
@@ -28,7 +26,7 @@
2826
* @author Juergen Hoeller
2927
*/
3028
@SuppressWarnings("serial")
31-
public abstract class PropertyAccessException extends BeansException implements ErrorCoded {
29+
public abstract class PropertyAccessException extends BeansException {
3230

3331
private transient PropertyChangeEvent propertyChangeEvent;
3432

@@ -77,4 +75,9 @@ public Object getValue() {
7775
return (this.propertyChangeEvent != null ? this.propertyChangeEvent.getNewValue() : null);
7876
}
7977

78+
/**
79+
* Return a corresponding error code for this type of exception.
80+
*/
81+
public abstract String getErrorCode();
82+
8083
}

spring-core/src/main/java/org/springframework/core/ConstantException.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

spring-core/src/main/java/org/springframework/core/Constants.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -333,4 +333,33 @@ public String propertyToConstantNamePrefix(String propertyName) {
333333
return parsedPrefix.toString();
334334
}
335335

336+
337+
/**
338+
* Exception thrown when the {@link Constants} class is asked for
339+
* an invalid constant name.
340+
*/
341+
@SuppressWarnings("serial")
342+
public static class ConstantException extends IllegalArgumentException {
343+
344+
/**
345+
* Thrown when an invalid constant name is requested.
346+
* @param className name of the class containing the constant definitions
347+
* @param field invalid constant name
348+
* @param message description of the problem
349+
*/
350+
public ConstantException(String className, String field, String message) {
351+
super("Field '" + field + "' " + message + " in class [" + className + "]");
352+
}
353+
354+
/**
355+
* Thrown when an invalid constant value is looked up.
356+
* @param className name of the class containing the constant definitions
357+
* @param namePrefix prefix of the searched constant names
358+
* @param value the looked up constant value
359+
*/
360+
public ConstantException(String className, String namePrefix, Object value) {
361+
super("No '" + namePrefix + "' field with value '" + value + "' found in class [" + className + "]");
362+
}
363+
}
364+
336365
}

spring-core/src/main/java/org/springframework/core/ControlFlow.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

spring-core/src/main/java/org/springframework/core/ControlFlowFactory.java

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)