From 60f4f2bfd20fb50050aec344a760224f7c5b780d Mon Sep 17 00:00:00 2001 From: dallogliog Date: Wed, 7 Mar 2012 15:34:25 +0100 Subject: [PATCH 1/3] Added BigDecimal capabilities to SpEl numeric operators * gt * ge * lt * le * eq * ne * plus * minus * divide * multiply * power * modulus This should cover the issue https://jira.springsource.org/browse/SPR-8716 --- .../expression/spel/ast/OpDivide.java | 13 +- .../expression/spel/ast/OpEQ.java | 15 +- .../expression/spel/ast/OpGE.java | 14 +- .../expression/spel/ast/OpGT.java | 14 +- .../expression/spel/ast/OpLE.java | 14 +- .../expression/spel/ast/OpLT.java | 14 +- .../expression/spel/ast/OpMinus.java | 14 +- .../expression/spel/ast/OpModulus.java | 9 +- .../expression/spel/ast/OpMultiply.java | 9 +- .../expression/spel/ast/OpNE.java | 14 +- .../expression/spel/ast/OpPlus.java | 12 +- .../expression/spel/ast/OperatorPower.java | 10 +- .../expression/spel/OperatorTests.java | 183 ++++++++++++++++++ 13 files changed, 322 insertions(+), 13 deletions(-) diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpDivide.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpDivide.java index 19bd86cce822..f750bdd856f5 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpDivide.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpDivide.java @@ -16,10 +16,13 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.Operation; import org.springframework.expression.TypedValue; import org.springframework.expression.spel.ExpressionState; +import org.springframework.util.NumberUtils; /** * Implements division operator. @@ -40,7 +43,15 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep if (operandOne instanceof Number && operandTwo instanceof Number) { Number op1 = (Number) operandOne; Number op2 = (Number) operandTwo; - if (op1 instanceof Double || op2 instanceof Double) { + + if ( op1 instanceof BigDecimal || op2 instanceof BigDecimal ) { + BigDecimal op1BD = NumberUtils.convertNumberToTargetClass(op1, BigDecimal.class); + BigDecimal op2BD = NumberUtils.convertNumberToTargetClass(op2, BigDecimal.class); + int scale = Math.max(op1BD.scale(), op2BD.scale()); + scale = scale > 2 ? scale : 3; + // set scale of the max of the two operands in case zero set default 2 + return new TypedValue(op1BD.divide(op2BD, scale, BigDecimal.ROUND_HALF_UP)); + } else if (op1 instanceof Double || op2 instanceof Double) { return new TypedValue(op1.doubleValue() / op2.doubleValue()); } else if (op1 instanceof Long || op2 instanceof Long) { return new TypedValue(op1.longValue() / op2.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java index 936f651cafc4..6eee15b52dd1 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java @@ -16,9 +16,14 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.spel.ExpressionState; +import org.springframework.expression.spel.SpelEvaluationException; +import org.springframework.expression.spel.SpelMessage; import org.springframework.expression.spel.support.BooleanTypedValue; +import org.springframework.util.NumberUtils; /** * Implements equality operator. @@ -39,7 +44,15 @@ public BooleanTypedValue getValueInternal(ExpressionState state) throws Evaluati if (left instanceof Number && right instanceof Number) { Number op1 = (Number) left; Number op2 = (Number) right; - if (op1 instanceof Double || op2 instanceof Double) { + if ( op1 instanceof BigDecimal || op2 instanceof BigDecimal ) + { + BigDecimal bd1 = NumberUtils.convertNumberToTargetClass(op1, BigDecimal.class); + BigDecimal bd2 = NumberUtils.convertNumberToTargetClass(op2, BigDecimal.class); + if ( bd1 == null || bd2 == null ) { + throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass()); + } + return BooleanTypedValue.forValue(bd1.compareTo(bd2) == 0); + } else if (op1 instanceof Double || op2 instanceof Double) { return BooleanTypedValue.forValue(op1.doubleValue() == op2.doubleValue()); } else if (op1 instanceof Long || op2 instanceof Long) { return BooleanTypedValue.forValue(op1.longValue() == op2.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpGE.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpGE.java index d3cd0c9df7c7..955d2407ab8c 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpGE.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpGE.java @@ -15,9 +15,14 @@ */ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.spel.ExpressionState; +import org.springframework.expression.spel.SpelEvaluationException; +import org.springframework.expression.spel.SpelMessage; import org.springframework.expression.spel.support.BooleanTypedValue; +import org.springframework.util.NumberUtils; /** * Implements greater-than-or-equal operator. @@ -38,7 +43,14 @@ public BooleanTypedValue getValueInternal(ExpressionState state) throws Evaluati if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; - if (leftNumber instanceof Double || rightNumber instanceof Double) { + if ( leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal ) { + BigDecimal bdLeft = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); + BigDecimal bdRight = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); + if ( bdLeft == null || bdRight == null ) { + throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass()); + } + return BooleanTypedValue.forValue(bdLeft.compareTo(bdRight) >= 0); + } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() >= rightNumber.doubleValue()); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue( leftNumber.longValue() >= rightNumber.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpGT.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpGT.java index e2b088a2f512..f85dc643f873 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpGT.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpGT.java @@ -16,9 +16,14 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.spel.ExpressionState; +import org.springframework.expression.spel.SpelEvaluationException; +import org.springframework.expression.spel.SpelMessage; import org.springframework.expression.spel.support.BooleanTypedValue; +import org.springframework.util.NumberUtils; /** * Implements greater-than operator. @@ -39,7 +44,14 @@ public BooleanTypedValue getValueInternal(ExpressionState state) throws Evaluati if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; - if (leftNumber instanceof Double || rightNumber instanceof Double) { + if ( leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal ) { + BigDecimal bdLeft = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); + BigDecimal bdRight = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); + if ( bdLeft == null || bdRight == null ) { + throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass()); + } + return BooleanTypedValue.forValue(bdLeft.compareTo(bdRight) > 0); + } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() > rightNumber.doubleValue()); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() > rightNumber.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpLE.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpLE.java index 559cd7ea4404..5bc7276c0d2a 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpLE.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpLE.java @@ -16,9 +16,14 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.spel.ExpressionState; +import org.springframework.expression.spel.SpelEvaluationException; +import org.springframework.expression.spel.SpelMessage; import org.springframework.expression.spel.support.BooleanTypedValue; +import org.springframework.util.NumberUtils; /** * Implements the less-than-or-equal operator. @@ -39,7 +44,14 @@ public BooleanTypedValue getValueInternal(ExpressionState state) throws Evaluati if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; - if (leftNumber instanceof Double || rightNumber instanceof Double) { + if ( leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal ) { + BigDecimal bdLeft = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); + BigDecimal bdRight = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); + if ( bdLeft == null || bdRight == null ) { + throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass()); + } + return BooleanTypedValue.forValue(bdLeft.compareTo(bdRight) <= 0); + } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() <= rightNumber.doubleValue()); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() <= rightNumber.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpLT.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpLT.java index 4b708fbeeddc..8110fe4ffc46 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpLT.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpLT.java @@ -16,9 +16,14 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.spel.ExpressionState; +import org.springframework.expression.spel.SpelEvaluationException; +import org.springframework.expression.spel.SpelMessage; import org.springframework.expression.spel.support.BooleanTypedValue; +import org.springframework.util.NumberUtils; /** * Implements the less-than operator. @@ -40,7 +45,14 @@ public BooleanTypedValue getValueInternal(ExpressionState state) throws Evaluati if (left instanceof Number && right instanceof Number) { Number leftNumber = (Number) left; Number rightNumber = (Number) right; - if (leftNumber instanceof Double || rightNumber instanceof Double) { + if ( leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal ) { + BigDecimal bdLeft = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); + BigDecimal bdRight = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); + if ( bdLeft == null || bdRight == null ) { + throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass()); + } + return BooleanTypedValue.forValue(bdLeft.compareTo(bdRight) < 0); + } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return BooleanTypedValue.forValue(leftNumber.doubleValue() < rightNumber.doubleValue()); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return BooleanTypedValue.forValue(leftNumber.longValue() < rightNumber.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java index 0843575cac66..06bba7fe8976 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMinus.java @@ -16,10 +16,13 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.Operation; import org.springframework.expression.TypedValue; import org.springframework.expression.spel.ExpressionState; +import org.springframework.util.NumberUtils; /** * The minus operator supports: @@ -50,7 +53,10 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep Object operand = leftOp.getValueInternal(state).getValue(); if (operand instanceof Number) { Number n = (Number) operand; - if (operand instanceof Double) { + if ( operand instanceof BigDecimal ) { + BigDecimal bdn = NumberUtils.convertNumberToTargetClass(n, BigDecimal.class); + return new TypedValue(BigDecimal.ZERO.subtract(bdn)); + } else if (operand instanceof Double) { return new TypedValue(0 - n.doubleValue()); } else if (operand instanceof Long) { return new TypedValue(0 - n.longValue()); @@ -65,7 +71,11 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep if (left instanceof Number && right instanceof Number) { Number op1 = (Number) left; Number op2 = (Number) right; - if (op1 instanceof Double || op2 instanceof Double) { + if ( op1 instanceof BigDecimal || op2 instanceof BigDecimal ) { + BigDecimal bd1 = NumberUtils.convertNumberToTargetClass(op1, BigDecimal.class); + BigDecimal bd2 = NumberUtils.convertNumberToTargetClass(op2, BigDecimal.class); + return new TypedValue(bd1.subtract(bd2)); + } else if (op1 instanceof Double || op2 instanceof Double) { return new TypedValue(op1.doubleValue() - op2.doubleValue()); } else if (op1 instanceof Long || op2 instanceof Long) { return new TypedValue(op1.longValue() - op2.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpModulus.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpModulus.java index 04ef2ffaef32..cb8340a6d1c5 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpModulus.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpModulus.java @@ -16,10 +16,13 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.Operation; import org.springframework.expression.TypedValue; import org.springframework.expression.spel.ExpressionState; +import org.springframework.util.NumberUtils; /** * Implements the modulus operator. @@ -40,7 +43,11 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep if (operandOne instanceof Number && operandTwo instanceof Number) { Number op1 = (Number) operandOne; Number op2 = (Number) operandTwo; - if (op1 instanceof Double || op2 instanceof Double) { + if ( op1 instanceof BigDecimal || op2 instanceof BigDecimal ) { + BigDecimal bd1 = NumberUtils.convertNumberToTargetClass(op1, BigDecimal.class); + BigDecimal bd2 = NumberUtils.convertNumberToTargetClass(op2, BigDecimal.class); + return new TypedValue(bd1.remainder(bd2)); + } else if (op1 instanceof Double || op2 instanceof Double) { return new TypedValue(op1.doubleValue() % op2.doubleValue()); } else if (op1 instanceof Long || op2 instanceof Long) { return new TypedValue(op1.longValue() % op2.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMultiply.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMultiply.java index e4565e211adf..b9b8e9a8fb21 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMultiply.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpMultiply.java @@ -16,10 +16,13 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.Operation; import org.springframework.expression.TypedValue; import org.springframework.expression.spel.ExpressionState; +import org.springframework.util.NumberUtils; /** * Implements the multiply operator. Conversions and promotions: @@ -59,7 +62,11 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep if (operandOne instanceof Number && operandTwo instanceof Number) { Number leftNumber = (Number) operandOne; Number rightNumber = (Number) operandTwo; - if (leftNumber instanceof Double || rightNumber instanceof Double) { + if ( leftNumber instanceof BigDecimal || rightNumber instanceof BigDecimal ) { + BigDecimal bdLeft = NumberUtils.convertNumberToTargetClass(leftNumber, BigDecimal.class); + BigDecimal bdRight = NumberUtils.convertNumberToTargetClass(rightNumber, BigDecimal.class); + return new TypedValue(bdLeft.multiply(bdRight)); + } else if (leftNumber instanceof Double || rightNumber instanceof Double) { return new TypedValue(leftNumber.doubleValue() * rightNumber.doubleValue()); } else if (leftNumber instanceof Long || rightNumber instanceof Long) { return new TypedValue(leftNumber.longValue() * rightNumber.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java index aebcb852777b..08a6edf4389c 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpNE.java @@ -16,9 +16,14 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.spel.ExpressionState; +import org.springframework.expression.spel.SpelEvaluationException; +import org.springframework.expression.spel.SpelMessage; import org.springframework.expression.spel.support.BooleanTypedValue; +import org.springframework.util.NumberUtils; /** * Implements the not-equal operator. @@ -39,7 +44,14 @@ public BooleanTypedValue getValueInternal(ExpressionState state) throws Evaluati if (left instanceof Number && right instanceof Number) { Number op1 = (Number) left; Number op2 = (Number) right; - if (op1 instanceof Double || op2 instanceof Double) { + if ( op1 instanceof BigDecimal || op2 instanceof BigDecimal ) { + BigDecimal bd1 = NumberUtils.convertNumberToTargetClass(op1, BigDecimal.class); + BigDecimal bd2 = NumberUtils.convertNumberToTargetClass(op2, BigDecimal.class); + if ( bd1 == null || bd2 == null ) { + throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass()); + } + return BooleanTypedValue.forValue(bd1.compareTo(bd2) != 0); + } else if (op1 instanceof Double || op2 instanceof Double) { return BooleanTypedValue.forValue(op1.doubleValue() != op2.doubleValue()); } else if (op1 instanceof Long || op2 instanceof Long) { return BooleanTypedValue.forValue(op1.longValue() != op2.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java index eb1f55c82ae9..69d6813615e7 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java @@ -16,10 +16,13 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.Operation; import org.springframework.expression.TypedValue; import org.springframework.expression.spel.ExpressionState; +import org.springframework.util.NumberUtils; /** * The plus operator will: @@ -48,6 +51,9 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep if (rightOp == null) { // If only one operand, then this is unary plus Object operandOne = leftOp.getValueInternal(state).getValue(); if (operandOne instanceof Number) { + if ( operandOne instanceof BigDecimal ) { + return new TypedValue((BigDecimal) operandOne); + } if (operandOne instanceof Double) { return new TypedValue(((Double) operandOne).doubleValue()); } else if (operandOne instanceof Long) { @@ -64,7 +70,11 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep if (operandOne instanceof Number && operandTwo instanceof Number) { Number op1 = (Number) operandOne; Number op2 = (Number) operandTwo; - if (op1 instanceof Double || op2 instanceof Double) { + if ( op1 instanceof BigDecimal || op2 instanceof BigDecimal ) { + BigDecimal bd1 = NumberUtils.convertNumberToTargetClass(op1, BigDecimal.class); + BigDecimal bd2 = NumberUtils.convertNumberToTargetClass(op2, BigDecimal.class); + return new TypedValue(bd1.add(bd2)); + } else if (op1 instanceof Double || op2 instanceof Double) { return new TypedValue(op1.doubleValue() + op2.doubleValue()); } else if (op1 instanceof Long || op2 instanceof Long) { return new TypedValue(op1.longValue() + op2.longValue()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorPower.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorPower.java index f15e7d043104..4935b2d76c05 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorPower.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorPower.java @@ -16,10 +16,13 @@ package org.springframework.expression.spel.ast; +import java.math.BigDecimal; + import org.springframework.expression.EvaluationException; import org.springframework.expression.Operation; import org.springframework.expression.TypedValue; import org.springframework.expression.spel.ExpressionState; +import org.springframework.util.NumberUtils; /** * The power operator. @@ -43,7 +46,12 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep if (operandOne instanceof Number && operandTwo instanceof Number) { Number op1 = (Number) operandOne; Number op2 = (Number) operandTwo; - if (op1 instanceof Double || op2 instanceof Double) { + if ( op1 instanceof BigDecimal ) { + // BigDecimal.pow has a limit in the range. + // is it correct to use the power function this way? + BigDecimal bd1 = NumberUtils.convertNumberToTargetClass(op1, BigDecimal.class); + return new TypedValue(bd1.pow(op2.intValue())); + } else if (op1 instanceof Double || op2 instanceof Double) { return new TypedValue(Math.pow(op1.doubleValue(),op2.doubleValue())); } else if (op1 instanceof Long || op2 instanceof Long) { double d= Math.pow(op1.longValue(), op2.longValue()); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/OperatorTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/OperatorTests.java index a174023fd4de..2f2c26cb0da1 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/OperatorTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/OperatorTests.java @@ -16,6 +16,8 @@ package org.springframework.expression.spel; +import java.math.BigDecimal; + import junit.framework.Assert; import org.junit.Test; @@ -41,6 +43,9 @@ public void testRealLiteral() { @Test public void testLessThan() { + + evaluate("5 < 5", false, Boolean.class); + evaluate("3 < 5", true, Boolean.class); evaluate("5 < 3", false, Boolean.class); evaluate("3L < 5L", true, Boolean.class); @@ -49,6 +54,15 @@ public void testLessThan() { evaluate("5.0d < 3.0d", false, Boolean.class); evaluate("'abc' < 'def'",true,Boolean.class); evaluate("'def' < 'abc'",false,Boolean.class); + evaluate("new java.math.BigDecimal('3') < new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('5') < new java.math.BigDecimal('3')", false, Boolean.class); + evaluate("3 < new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') < 5", true, Boolean.class); + evaluate("3L < new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3.0d < new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3L < new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d < new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d < new java.math.BigDecimal('3.0')", false, Boolean.class); evaluate("3 lt 5", true, Boolean.class); evaluate("5 lt 3", false, Boolean.class); @@ -58,6 +72,15 @@ public void testLessThan() { evaluate("5.0d Lt 3.0d", false, Boolean.class); evaluate("'abc' LT 'def'",true,Boolean.class); evaluate("'def' lt 'abc'",false,Boolean.class); + evaluate("new java.math.BigDecimal('3') lt new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('5') lt new java.math.BigDecimal('3')", false, Boolean.class); + evaluate("3 lt new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') lt 5", true, Boolean.class); + evaluate("3L lt new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3.0d lt new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3L lt new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d lt new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d lt new java.math.BigDecimal('3.0')", false, Boolean.class); } @Test @@ -74,7 +97,19 @@ public void testLessThanOrEqual() { evaluate("'abc' <= 'def'",true,Boolean.class); evaluate("'def' <= 'abc'",false,Boolean.class); evaluate("'abc' <= 'abc'",true,Boolean.class); + evaluate("new java.math.BigDecimal('5') <= new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') <= new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('5') <= new java.math.BigDecimal('3')", false, Boolean.class); + evaluate("3 <= new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') <= 5", true, Boolean.class); + evaluate("3L <= new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3.0d <= new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3L <= new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d <= new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d <= new java.math.BigDecimal('3.0')", true, Boolean.class); + evaluate("3 le 5", true, Boolean.class); + evaluate("5 le 3", false, Boolean.class); evaluate("3 le 5", true, Boolean.class); evaluate("5 le 3", false, Boolean.class); evaluate("6 Le 6", true, Boolean.class); @@ -87,42 +122,102 @@ public void testLessThanOrEqual() { evaluate("'abc' Le 'def'",true,Boolean.class); evaluate("'def' LE 'abc'",false,Boolean.class); evaluate("'abc' le 'abc'",true,Boolean.class); + evaluate("new java.math.BigDecimal('5') le new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') le new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('5') le new java.math.BigDecimal('3')", false, Boolean.class); + evaluate("3 le new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') le 5", true, Boolean.class); + evaluate("3L le new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3.0d le new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3L le new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d le new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d le new java.math.BigDecimal('3.0')", true, Boolean.class); } @Test public void testEqual() { + evaluate("3 == 5", false, Boolean.class); + evaluate("5 == 3", false, Boolean.class); evaluate("3 == 5", false, Boolean.class); evaluate("5 == 3", false, Boolean.class); evaluate("6 == 6", true, Boolean.class); evaluate("3.0f == 5.0f", false, Boolean.class); evaluate("3.0f == 3.0f", true, Boolean.class); evaluate("'abc' == null", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') == new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') == new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') == new java.math.BigDecimal('3')", false, Boolean.class); + evaluate("3 == new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('3') == 5", false, Boolean.class); + evaluate("3L == new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3.0d == new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3L == new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d == new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d == new java.math.BigDecimal('3.0')", true, Boolean.class); + evaluate("3 eq 5", false, Boolean.class); + evaluate("5 eQ 3", false, Boolean.class); evaluate("3 eq 5", false, Boolean.class); evaluate("5 eQ 3", false, Boolean.class); evaluate("6 Eq 6", true, Boolean.class); evaluate("3.0f eq 5.0f", false, Boolean.class); evaluate("3.0f EQ 3.0f", true, Boolean.class); evaluate("'abc' EQ null", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') eq new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') eq new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') eq new java.math.BigDecimal('3')", false, Boolean.class); + evaluate("3 eq new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('3') eq 5", false, Boolean.class); + evaluate("3L eq new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3.0d eq new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3L eq new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d eq new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d eq new java.math.BigDecimal('3.0')", true, Boolean.class); } @Test public void testNotEqual() { + evaluate("3 != 5", true, Boolean.class); + evaluate("5 != 3", true, Boolean.class); evaluate("3 != 5", true, Boolean.class); evaluate("5 != 3", true, Boolean.class); evaluate("6 != 6", false, Boolean.class); evaluate("3.0f != 5.0f", true, Boolean.class); evaluate("3.0f != 3.0f", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') != new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('3') != new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('5') != new java.math.BigDecimal('3')", true, Boolean.class); + evaluate("3 != new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') != 5", true, Boolean.class); + evaluate("3L != new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3.0d != new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3L != new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d != new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d != new java.math.BigDecimal('3.0')", false, Boolean.class); + evaluate("3 ne 5", true, Boolean.class); + evaluate("5 nE 3", true, Boolean.class); evaluate("3 ne 5", true, Boolean.class); evaluate("5 nE 3", true, Boolean.class); evaluate("6 Ne 6", false, Boolean.class); evaluate("3.0f NE 5.0f", true, Boolean.class); evaluate("3.0f ne 3.0f", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') ne new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('3') ne new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('5') ne new java.math.BigDecimal('3')", true, Boolean.class); + evaluate("3 ne new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') ne 5", true, Boolean.class); + evaluate("3L ne new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3.0d ne new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("3L ne new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d ne new java.math.BigDecimal('3.1')", true, Boolean.class); + evaluate("3.0d ne new java.math.BigDecimal('3.0')", false, Boolean.class); } @Test public void testGreaterThanOrEqual() { + evaluate("3 >= 5", false, Boolean.class); + evaluate("5 >= 3", true, Boolean.class); evaluate("3 >= 5", false, Boolean.class); evaluate("5 >= 3", true, Boolean.class); evaluate("6 >= 6", true, Boolean.class); @@ -135,15 +230,39 @@ public void testGreaterThanOrEqual() { evaluate("'abc' >= 'def'",false,Boolean.class); evaluate("'def' >= 'abc'",true,Boolean.class); evaluate("'abc' >= 'abc'",true,Boolean.class); + evaluate("new java.math.BigDecimal('5') >= new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') >= new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') >= new java.math.BigDecimal('3')", true, Boolean.class); + evaluate("3 >= new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('3') >= 5", false, Boolean.class); + evaluate("3L >= new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3.0d >= new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3L >= new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d >= new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d >= new java.math.BigDecimal('3.0')", true, Boolean.class); + evaluate("3 GE 5", false, Boolean.class); + evaluate("5 gE 3", true, Boolean.class); evaluate("3 GE 5", false, Boolean.class); evaluate("5 gE 3", true, Boolean.class); evaluate("6 Ge 6", true, Boolean.class); evaluate("3L ge 5L", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') ge new java.math.BigDecimal('5')", true, Boolean.class); + evaluate("new java.math.BigDecimal('3') ge new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') ge new java.math.BigDecimal('3')", true, Boolean.class); + evaluate("3 ge new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('3') ge 5", false, Boolean.class); + evaluate("3L ge new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3.0d ge new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3L ge new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d ge new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d ge new java.math.BigDecimal('3.0')", true, Boolean.class); } @Test public void testGreaterThan() { + evaluate("3 > 5", false, Boolean.class); + evaluate("5 > 3", true, Boolean.class); evaluate("3 > 5", false, Boolean.class); evaluate("5 > 3", true, Boolean.class); evaluate("3L > 5L", false, Boolean.class); @@ -152,11 +271,31 @@ public void testGreaterThan() { evaluate("5.0d > 3.0d", true, Boolean.class); evaluate("'abc' > 'def'",false,Boolean.class); evaluate("'def' > 'abc'",true,Boolean.class); + evaluate("new java.math.BigDecimal('3') > new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') > new java.math.BigDecimal('3')", true, Boolean.class); + evaluate("3 > new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('3') > 5", false, Boolean.class); + evaluate("3L > new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3.0d > new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3L > new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d > new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d > new java.math.BigDecimal('3.0')", false, Boolean.class); + evaluate("3.0d gt 5.0d", false, Boolean.class); + evaluate("5.0d gT 3.0d", true, Boolean.class); evaluate("3.0d gt 5.0d", false, Boolean.class); evaluate("5.0d gT 3.0d", true, Boolean.class); evaluate("'abc' Gt 'def'",false,Boolean.class); evaluate("'def' GT 'abc'",true,Boolean.class); + evaluate("new java.math.BigDecimal('3') gt new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('5') gt new java.math.BigDecimal('3')", true, Boolean.class); + evaluate("3 gt new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("new java.math.BigDecimal('3') gt 5", false, Boolean.class); + evaluate("3L gt new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3.0d gt new java.math.BigDecimal('5')", false, Boolean.class); + evaluate("3L gt new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d gt new java.math.BigDecimal('3.1')", false, Boolean.class); + evaluate("3.0d gt new java.math.BigDecimal('3.0')", false, Boolean.class); } @Test @@ -169,6 +308,30 @@ public void testMultiplyDoubleDoubleGivesDouble() { evaluate("3.0d * 5.0d", 15.0d, Double.class); } + @Test + public void testMixedOperandsBigDecimal() { + evaluate("3 * new java.math.BigDecimal('5')", new BigDecimal("15"), BigDecimal.class); + evaluate("3L * new java.math.BigDecimal('5')", new BigDecimal("15"), BigDecimal.class); + evaluate("3.0d * new java.math.BigDecimal('5')", new BigDecimal("15.0"), BigDecimal.class); + + evaluate("3 + new java.math.BigDecimal('5')", new BigDecimal("8"), BigDecimal.class); + evaluate("3L + new java.math.BigDecimal('5')", new BigDecimal("8"), BigDecimal.class); + evaluate("3.0d + new java.math.BigDecimal('5')", new BigDecimal("8.0"), BigDecimal.class); + + evaluate("3 - new java.math.BigDecimal('5')", new BigDecimal("-2"), BigDecimal.class); + evaluate("3L - new java.math.BigDecimal('5')", new BigDecimal("-2"), BigDecimal.class); + evaluate("3.0d - new java.math.BigDecimal('5')", new BigDecimal("-2.0"), BigDecimal.class); + + evaluate("3 / new java.math.BigDecimal('5')", new BigDecimal("0.600"), BigDecimal.class); + evaluate("3L / new java.math.BigDecimal('5')", new BigDecimal("0.600"), BigDecimal.class); + evaluate("3.0d / new java.math.BigDecimal('5')", new BigDecimal("0.600"), BigDecimal.class); + + evaluate("5 % new java.math.BigDecimal('3')", new BigDecimal("2"), BigDecimal.class); + evaluate("3 % new java.math.BigDecimal('5')", new BigDecimal("3"), BigDecimal.class); + evaluate("3L % new java.math.BigDecimal('5')", new BigDecimal("3"), BigDecimal.class); + evaluate("3.0d % new java.math.BigDecimal('5')", new BigDecimal("3.0"), BigDecimal.class); + } + @Test public void testMathOperatorAdd02() { evaluate("'hello' + ' ' + 'world'", "hello world", String.class); @@ -183,6 +346,7 @@ public void testMathOperatorsInChains() { @Test public void testIntegerArithmetic() { + // XXX SONO ARRIVATO QUI evaluate("2 + 4", "6", Integer.class); evaluate("5 - 4", "1", Integer.class); evaluate("3 * 5", 15, Integer.class); @@ -201,6 +365,7 @@ public void testPlus() throws Exception { evaluate("7 + 2", "9", Integer.class); evaluate("3.0f + 5.0f", 8.0d, Double.class); evaluate("3.0d + 5.0d", 8.0d, Double.class); + evaluate("3 + new java.math.BigDecimal('5')", new BigDecimal("8"), BigDecimal.class); evaluate("'ab' + 2", "ab2", String.class); evaluate("2 + 'a'", "2a", String.class); @@ -217,6 +382,7 @@ public void testPlus() throws Exception { evaluate("+5d",5d,Double.class); evaluate("+5L",5L,Long.class); evaluate("+5",5,Integer.class); + evaluate("+new java.math.BigDecimal('5')", new BigDecimal("5"),BigDecimal.class); evaluateAndCheckError("+'abc'",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES); // string concatenation @@ -240,6 +406,7 @@ public void testMinus() throws Exception { evaluate("-5d",-5d,Double.class); evaluate("-5L",-5L,Long.class); evaluate("-5",-5,Integer.class); + evaluate("-new java.math.BigDecimal('5')", new BigDecimal("-5"),BigDecimal.class); evaluateAndCheckError("-'abc'",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES); } @@ -249,6 +416,8 @@ public void testModulus() { evaluate("3L%2L",1L,Long.class); evaluate("3.0f%2.0f",1d,Double.class); evaluate("5.0d % 3.1d", 1.9d, Double.class); + evaluate("new java.math.BigDecimal('5') % new java.math.BigDecimal('3')", new BigDecimal("2"), BigDecimal.class); + evaluate("new java.math.BigDecimal('5') % 3", new BigDecimal("2"), BigDecimal.class); evaluateAndCheckError("'abc'%'def'",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES); } @@ -258,6 +427,7 @@ public void testDivide() { evaluate("4L/2L",2L,Long.class); evaluate("3.0f div 5.0f", 0.6d, Double.class); evaluate("4L DIV 2L",2L,Long.class); + evaluate("new java.math.BigDecimal('3') / 5", new BigDecimal("0.600"), BigDecimal.class); evaluateAndCheckError("'abc'/'def'",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES); } @@ -284,6 +454,18 @@ public void testDoubles() { evaluate("6.0d % 3.5d", 2.5d, Double.class); } + + @Test + public void testBigDecimals() { + evaluate("3 + new java.math.BigDecimal('5')", new BigDecimal("8"), BigDecimal.class); + evaluate("3 - new java.math.BigDecimal('5')", new BigDecimal("-2"), BigDecimal.class); + evaluate("3 * new java.math.BigDecimal('5')", new BigDecimal("15"), BigDecimal.class); + evaluate("3 / new java.math.BigDecimal('5')", new BigDecimal("0.600"), BigDecimal.class); + evaluate("5 % new java.math.BigDecimal('3')", new BigDecimal("2"), BigDecimal.class); + evaluate("new java.math.BigDecimal('5') % 3", new BigDecimal("2"), BigDecimal.class); + evaluate("new java.math.BigDecimal('5') ^ 3", new BigDecimal("125"), BigDecimal.class); + } + @Test public void testOperatorNames() throws Exception { Operator node = getOperatorNode((SpelExpression)parser.parseExpression("1==3")); @@ -335,6 +517,7 @@ public void testPower() { evaluate("3.0d^2.0d",9.0d,Double.class); evaluate("3L^2L",9L,Long.class); evaluate("(2^32)^2",9223372036854775807L,Long.class); + evaluate("new java.math.BigDecimal('5') ^ 3", new BigDecimal("125"), BigDecimal.class); } @Test From 9844dfc90ba3618a7bb1b9453f6e4499b44b2997 Mon Sep 17 00:00:00 2001 From: dallogliog Date: Mon, 14 May 2012 15:53:43 +0200 Subject: [PATCH 2/3] Minor Syntax --- .../java/org/springframework/expression/spel/ast/OpEQ.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java index 6eee15b52dd1..1cf139ec0b5b 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java @@ -44,8 +44,7 @@ public BooleanTypedValue getValueInternal(ExpressionState state) throws Evaluati if (left instanceof Number && right instanceof Number) { Number op1 = (Number) left; Number op2 = (Number) right; - if ( op1 instanceof BigDecimal || op2 instanceof BigDecimal ) - { + if ( op1 instanceof BigDecimal || op2 instanceof BigDecimal ) { BigDecimal bd1 = NumberUtils.convertNumberToTargetClass(op1, BigDecimal.class); BigDecimal bd2 = NumberUtils.convertNumberToTargetClass(op2, BigDecimal.class); if ( bd1 == null || bd2 == null ) { From 114d3a1694420a8841977efa8dc691467fc5afc6 Mon Sep 17 00:00:00 2001 From: dallogliog Date: Tue, 15 May 2012 13:27:36 +0200 Subject: [PATCH 3/3] Update code to upstream / master --- .../AsyncExecutionInterceptor.java | 2 +- .../AbstractPrototypeBasedTargetSource.java | 7 +- .../aop/config/spring-aop-3.2.xsd | 410 ++++++ .../aspectj/AspectJAsyncConfiguration.java | 4 +- .../beans/factory/annotation/Autowired.java | 9 +- .../beans/factory/annotation/Value.java | 7 +- .../config/FieldRetrievingFactoryBean.java | 2 +- .../config/PlaceholderConfigurerSupport.java | 8 +- .../xml/BeanDefinitionParserDelegate.java | 4 +- .../support/ResourceEditorRegistrar.java | 5 +- .../beans/factory/xml/spring-beans-3.2.xsd | 1180 +++++++++++++++++ .../beans/factory/xml/spring-tool-3.2.xsd | 115 ++ .../beans/factory/xml/spring-util-3.2.xsd | 212 +++ .../quartz/CronTriggerFactoryBean.java | 6 +- .../quartz/SimpleTriggerFactoryBean.java | 6 +- .../annotation/CacheAnnotationParser.java | 4 +- .../CachingConfigurationSelector.java | 4 +- .../cache/annotation/EnableCaching.java | 4 +- .../cache/concurrent/ConcurrentMapCache.java | 4 +- .../cache/ehcache/EhCacheCacheManager.java | 6 +- ...eanFactoryCacheOperationSourceAdvisor.java | 3 +- .../interceptor/CacheProxyFactoryBean.java | 6 +- .../NameMatchCacheOperationSource.java | 1 - .../CommonAnnotationBeanPostProcessor.java | 25 +- .../context/annotation/ComponentScan.java | 2 +- .../context/annotation/Configuration.java | 41 +- .../annotation/EnableLoadTimeWeaving.java | 6 +- .../context/annotation/FilterType.java | 4 +- .../context/annotation/Import.java | 18 +- .../annotation/LoadTimeWeavingConfigurer.java | 12 +- .../support/AbstractApplicationContext.java | 2 +- .../PropertySourcesPlaceholderConfigurer.java | 4 +- .../joda/JodaTimeFormatterRegistrar.java | 4 +- .../glassfish/GlassFishLoadTimeWeaver.java | 8 +- .../jmx/access/MBeanClientInterceptor.java | 2 +- .../assembler/AbstractMBeanInfoAssembler.java | 4 +- .../annotation/AsyncAnnotationAdvisor.java | 6 +- .../MethodValidationInterceptor.java | 4 +- .../cache/config/spring-cache-3.2.xsd | 235 ++++ .../context/config/spring-context-3.2.xsd | 533 ++++++++ .../ejb/config/spring-jee-3.2.xsd | 267 ++++ .../scheduling/config/spring-task-3.2.xsd | 250 ++++ .../scripting/config/spring-lang-3.2.xsd | 233 ++++ .../convert/ConverterNotFoundException.java | 3 +- .../core/convert/TypeDescriptor.java | 14 +- .../core/env/AbstractEnvironment.java | 6 +- .../core/env/PropertyResolver.java | 8 +- .../support/SerializingConverter.java | 2 +- .../task/support/ExecutorServiceAdapter.java | 2 +- .../springframework/util/AntPathMatcher.java | 4 +- .../util/AntPathMatcherTests.java | 15 +- .../expression/spel/SpelNode.java | 4 +- .../expression/spel/ast/OpMinus.java | 3 +- .../expression/spel/ast/OpMultiply.java | 35 +- .../expression/spel/ast/OpPlus.java | 68 +- .../expression/spel/ast/OperatorPower.java | 2 +- .../expression/spel/ast/OpPlusTests.java | 226 ++++ .../jdbc/core/JdbcOperations.java | 6 +- .../ParameterizedPreparedStatementSetter.java | 8 +- .../embedded/EmbeddedDatabaseConfigurer.java | 2 +- .../jdbc/config/spring-jdbc-3.2.xsd | 181 +++ .../MappingJacksonMessageConverter.java | 3 +- .../jms/support/converter/MessageType.java | 2 +- .../jms/config/spring-jms-3.2.xsd | 480 +++++++ .../hibernate3/LocalSessionFactoryBean.java | 47 +- .../support/OpenSessionInViewFilter.java | 41 +- .../support/OpenSessionInViewInterceptor.java | 49 +- .../hibernate4/LocalSessionFactoryBean.java | 2 +- .../support/OpenSessionInViewFilter.java | 38 +- .../support/OpenSessionInViewInterceptor.java | 45 +- .../orm/ibatis/SqlMapClientFactoryBean.java | 1 - .../orm/jdo/JdoOperations.java | 3 +- .../orm/jpa/vendor/EclipseLinkJpaDialect.java | 4 +- .../orm/jpa/vendor/TopLinkJpaDialect.java | 4 +- .../support/OpenSessionInViewTests.java | 773 ++++++----- spring-oxm/oxm.gradle | 20 +- .../oxm/GenericMarshaller.java | 2 +- .../oxm/GenericUnmarshaller.java | 2 +- .../oxm/castor/CastorMarshaller.java | 6 +- .../oxm/jibx/JibxMarshaller.java | 4 +- .../oxm/config/spring-oxm-3.2.xsd | 158 +++ .../springframework/oxm/jibx/FlightType.java | 26 +- .../oxm/jibx/JibxUnmarshallerTests.java | 29 +- .../org/springframework/oxm/jibx/binding.xml | 1 + .../web/struts/ActionSupport.java | 1 - .../web/struts/ContextLoaderPlugIn.java | 1 - .../web/struts/DispatchActionSupport.java | 1 - .../struts/LookupDispatchActionSupport.java | 1 - .../struts/MappingDispatchActionSupport.java | 1 - .../ContextConfigurationAttributes.java | 28 +- .../test/context/SmartContextLoader.java | 13 +- .../RunAfterTestMethodCallbacks.java | 10 +- .../support/AbstractContextLoader.java | 32 +- .../support/AbstractGenericContextLoader.java | 30 +- .../AnnotationConfigContextLoader.java | 24 +- .../support/DelegatingSmartContextLoader.java | 2 +- .../mock/web/MockServletContextTests.java | 16 +- .../ProfileAnnotationConfigTestSuite.java | 4 +- .../DefaultProfileAnnotationConfigTests.java | 10 +- ...figClassesWithoutAtConfigurationTests.java | 102 ++ .../context/junit4/spr9051/LifecycleBean.java | 51 + .../dao/QueryTimeoutException.java | 0 .../jca/work/jboss/JBossWorkManagerUtils.java | 2 +- .../EnableTransactionManagement.java | 4 +- .../TransactionProxyFactoryBean.java | 3 +- .../DelegatingTransactionDefinition.java | 2 +- .../transaction/config/spring-tx-3.2.xsd | 247 ++++ .../org/springframework/http/MediaType.java | 62 +- .../client/ClientHttpRequestInterceptor.java | 4 +- .../HttpMessageNotWritableException.java | 3 +- .../MappingJackson2HttpMessageConverter.java | 220 +++ .../MappingJacksonHttpMessageConverter.java | 36 +- .../web/bind/annotation/CookieValue.java | 3 +- .../web/bind/annotation/PathVariable.java | 5 +- .../web/bind/annotation/RequestBody.java | 11 +- .../web/bind/annotation/RequestHeader.java | 2 +- .../web/bind/annotation/RequestMapping.java | 14 +- .../web/bind/annotation/RequestParam.java | 15 +- .../web/bind/annotation/ResponseStatus.java | 5 +- .../ConfigurableWebBindingInitializer.java | 4 +- .../web/client/RestTemplate.java | 16 +- .../web/context/ContextLoader.java | 7 +- .../web/context/ContextLoaderListener.java | 23 +- .../async/AbstractDelegatingCallable.java | 54 + .../request/async/AsyncExecutionChain.java | 219 +++ .../async/AsyncExecutionChainRunnable.java | 79 ++ .../request/async/AsyncWebRequest.java | 78 ++ .../async/AsyncWebRequestInterceptor.java | 73 + .../context/request/async/DeferredResult.java | 170 +++ .../request/async/NoOpAsyncWebRequest.java | 65 + .../StaleAsyncRequestCheckingCallable.java | 50 + .../async/StaleAsyncWebRequestException.java | 35 + .../async/StandardServletAsyncWebRequest.java | 140 ++ ...AnnotationConfigWebApplicationContext.java | 10 +- .../filter/AbstractRequestLoggingFilter.java | 28 +- .../web/filter/OncePerRequestFilter.java | 26 +- .../web/filter/RequestContextFilter.java | 59 +- .../web/filter/ShallowEtagHeaderFilter.java | 36 +- .../web/method/HandlerMethod.java | 73 +- .../ModelAttributeMethodProcessor.java | 14 +- ...dlerMethodReturnValueHandlerComposite.java | 26 +- .../support/InvocableHandlerMethod.java | 4 +- .../method/support/ModelAndViewContainer.java | 94 +- .../StandardMultipartHttpServletRequest.java | 4 +- .../web/util/UriComponentsBuilder.java | 16 +- .../springframework/http/MediaTypeTests.java | 10 +- ...ppingJacksonHttpMessageConverterTests.java | 218 +++ ...pingJackson2HttpMessageConverterTests.java | 106 ++ ...ppingJacksonHttpMessageConverterTests.java | 180 +-- .../async/AsyncExecutionChainTests.java | 248 ++++ .../request/async/DeferredResultTests.java | 119 ++ ...taleAsyncRequestCheckingCallableTests.java | 71 + .../StandardServletAsyncWebRequestTests.java | 170 +++ .../filter/CharacterEncodingFilterTests.java | 138 +- .../ModelAttributeMethodProcessorTests.java | 122 +- .../web/util/UriComponentsBuilderTests.java | 11 + .../web/portlet/DispatcherPortlet.java | 1 - ...tRefreshablePortletApplicationContext.java | 2 +- .../portlet/context/PortletContextScope.java | 2 +- .../StaticPortletApplicationContext.java | 2 +- ...letRequestMethodNotSupportedException.java | 1 - ...otationMethodHandlerExceptionResolver.java | 34 +- .../web/servlet/AsyncHandlerInterceptor.java | 82 ++ .../web/servlet/DispatcherServlet.java | 250 ++-- .../web/servlet/FrameworkServlet.java | 144 +- .../web/servlet/HandlerExecutionChain.java | 116 +- .../AnnotationDrivenBeanDefinitionParser.java | 54 +- .../WebMvcConfigurationSupport.java | 190 +-- .../handler/AbstractHandlerMethodMapping.java | 59 +- .../handler/DispatcherServletWebRequest.java | 2 +- .../WebRequestHandlerInterceptorAdapter.java | 25 +- .../AnnotationMethodHandlerAdapter.java | 6 +- ...otationMethodHandlerExceptionResolver.java | 36 +- .../AbstractMediaTypeExpression.java | 20 +- .../mvc/condition/RequestCondition.java | 44 +- .../mvc/condition/RequestConditionHolder.java | 26 +- .../RequestMappingInfoHandlerMapping.java | 20 +- ...stractMessageConverterMethodProcessor.java | 43 +- .../AsyncMethodReturnValueHandler.java | 75 ++ .../ExceptionHandlerExceptionResolver.java | 62 +- .../RequestMappingHandlerAdapter.java | 248 ++-- .../RequestMappingHandlerMapping.java | 37 +- .../ServletInvocableHandlerMethod.java | 135 +- .../ServletModelAttributeMethodProcessor.java | 28 +- .../DefaultServletHttpRequestHandler.java | 3 +- .../resource/ResourceHttpRequestHandler.java | 10 +- .../web/servlet/support/RequestContext.java | 26 +- .../view/ContentNegotiatingViewResolver.java | 28 +- .../view/json/MappingJackson2JsonView.java | 253 ++++ .../view/json/MappingJacksonJsonView.java | 40 +- .../web/servlet/config/spring-mvc-3.2.xsd | 326 +++++ .../servlet/HandlerExecutionChainTests.java | 202 +++ .../WebMvcConfigurationSupportTests.java | 62 +- .../handler/HandlerMethodMappingTests.java | 12 +- .../ConsumesRequestConditionTests.java | 28 +- .../ProducesRequestConditionTests.java | 38 +- .../RequestConditionHolderTests.java | 31 +- ...HandlerMethodAnnotationDetectionTests.java | 105 +- .../HttpEntityMethodProcessorTests.java | 21 +- ...questResponseBodyMethodProcessorTests.java | 44 +- .../ServletInvocableHandlerMethodTests.java | 91 +- .../ResourceHttpRequestHandlerTests.java | 37 +- .../ContentNegotiatingViewResolverTests.java | 65 +- .../json/MappingJackson2JsonViewTest.java | 367 +++++ .../view/json/MappingJacksonJsonViewTest.java | 19 +- src/dist/changelog.txt | 22 +- src/reference/docbook/aop.xml | 2 +- .../docbook/beans-classpath-scanning.xml | 2 +- src/reference/docbook/beans.xml | 6 +- src/reference/docbook/cache.xml | 12 +- src/reference/docbook/classic-aop-spring.xml | 2 +- src/reference/docbook/expressions.xml | 2 +- src/reference/docbook/jdbc.xml | 16 +- src/reference/docbook/mvc.xml | 21 +- src/reference/docbook/new-in-3.1.xml | 2 +- src/reference/docbook/overview.xml | 10 +- src/reference/docbook/portlet.xml | 2 +- src/reference/docbook/remoting.xml | 6 +- src/reference/docbook/resources.xml | 2 +- src/reference/docbook/scheduling.xml | 2 +- src/reference/docbook/validation.xml | 18 +- src/reference/docbook/view.xml | 4 +- src/reference/docbook/web-integration.xml | 2 +- src/reference/docbook/xml-custom.xml | 2 +- src/reference/docbook/xsd-configuration.xml | 4 +- 225 files changed, 11450 insertions(+), 2000 deletions(-) create mode 100644 spring-aop/src/main/resources/org/springframework/aop/config/spring-aop-3.2.xsd create mode 100644 spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-beans-3.2.xsd create mode 100644 spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-tool-3.2.xsd create mode 100644 spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-util-3.2.xsd create mode 100644 spring-context/src/main/resources/org/springframework/cache/config/spring-cache-3.2.xsd create mode 100644 spring-context/src/main/resources/org/springframework/context/config/spring-context-3.2.xsd create mode 100644 spring-context/src/main/resources/org/springframework/ejb/config/spring-jee-3.2.xsd create mode 100644 spring-context/src/main/resources/org/springframework/scheduling/config/spring-task-3.2.xsd create mode 100644 spring-context/src/main/resources/org/springframework/scripting/config/spring-lang-3.2.xsd create mode 100644 spring-expression/src/test/java/org/springframework/expression/spel/ast/OpPlusTests.java create mode 100644 spring-jdbc/src/main/resources/org/springframework/jdbc/config/spring-jdbc-3.2.xsd create mode 100644 spring-jms/src/main/resources/org/springframework/jms/config/spring-jms-3.2.xsd create mode 100644 spring-oxm/src/main/resources/org/springframework/oxm/config/spring-oxm-3.2.xsd create mode 100644 spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AnnotatedConfigClassesWithoutAtConfigurationTests.java create mode 100644 spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/LifecycleBean.java rename {spring-transaction => spring-tx}/src/main/java/org/springframework/dao/QueryTimeoutException.java (100%) create mode 100644 spring-tx/src/main/resources/org/springframework/transaction/config/spring-tx-3.2.xsd create mode 100644 spring-web/src/main/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverter.java create mode 100644 spring-web/src/main/java/org/springframework/web/context/request/async/AbstractDelegatingCallable.java create mode 100644 spring-web/src/main/java/org/springframework/web/context/request/async/AsyncExecutionChain.java create mode 100644 spring-web/src/main/java/org/springframework/web/context/request/async/AsyncExecutionChainRunnable.java create mode 100644 spring-web/src/main/java/org/springframework/web/context/request/async/AsyncWebRequest.java create mode 100644 spring-web/src/main/java/org/springframework/web/context/request/async/AsyncWebRequestInterceptor.java create mode 100644 spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java create mode 100644 spring-web/src/main/java/org/springframework/web/context/request/async/NoOpAsyncWebRequest.java create mode 100644 spring-web/src/main/java/org/springframework/web/context/request/async/StaleAsyncRequestCheckingCallable.java create mode 100644 spring-web/src/main/java/org/springframework/web/context/request/async/StaleAsyncWebRequestException.java create mode 100644 spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java create mode 100644 spring-web/src/test/java/org/springframework/http/converter/json/AbstractMappingJacksonHttpMessageConverterTests.java create mode 100644 spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java create mode 100644 spring-web/src/test/java/org/springframework/web/context/request/async/AsyncExecutionChainTests.java create mode 100644 spring-web/src/test/java/org/springframework/web/context/request/async/DeferredResultTests.java create mode 100644 spring-web/src/test/java/org/springframework/web/context/request/async/StaleAsyncRequestCheckingCallableTests.java create mode 100644 spring-web/src/test/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequestTests.java create mode 100644 spring-webmvc/src/main/java/org/springframework/web/servlet/AsyncHandlerInterceptor.java create mode 100644 spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AsyncMethodReturnValueHandler.java create mode 100644 spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java create mode 100644 spring-webmvc/src/main/resources/org/springframework/web/servlet/config/spring-mvc-3.2.xsd create mode 100644 spring-webmvc/src/test/java/org/springframework/web/servlet/HandlerExecutionChainTests.java create mode 100644 spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTest.java diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java index 6039ce304cda..1cc6f8e0221a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java @@ -32,7 +32,7 @@ /** * AOP Alliance MethodInterceptor that processes method invocations * asynchronously, using a given {@link org.springframework.core.task.AsyncTaskExecutor}. - * Typically used with the {@link org.springframework.context.task.Async} annotation. + * Typically used with the {@link org.springframework.scheduling.annotation.Async} annotation. * *

In terms of target method signatures, any parameter types are supported. * However, the return type is constrained to either void or diff --git a/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java index 83c8083e5b74..f2677afbc210 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -28,8 +28,9 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory; /** - * Base class for dynamic {@link TargetSource} implementations that create new prototype - * bean instances to support a pooling or new-instance-per-invocation strategy. + * Base class for dynamic {@link org.springframework.aop.TargetSource} implementations + * that create new prototype bean instances to support a pooling or + * new-instance-per-invocation strategy. * *

Such TargetSources must run in a {@link BeanFactory}, as it needs to * call the getBean method to create a new prototype instance. diff --git a/spring-aop/src/main/resources/org/springframework/aop/config/spring-aop-3.2.xsd b/spring-aop/src/main/resources/org/springframework/aop/config/spring-aop-3.2.xsd new file mode 100644 index 000000000000..7dae8fc44690 --- /dev/null +++ b/spring-aop/src/main/resources/org/springframework/aop/config/spring-aop-3.2.xsd @@ -0,0 +1,410 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AspectJAsyncConfiguration.java b/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AspectJAsyncConfiguration.java index d9d677a57093..c2df8e984dbc 100644 --- a/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AspectJAsyncConfiguration.java +++ b/spring-aspects/src/main/java/org/springframework/scheduling/aspectj/AspectJAsyncConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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,7 @@ * @author Chris Beams * @since 3.1 * @see EnableAsync - * @see AsyncConfigurationSelector + * @see org.springframework.scheduling.annotation.AsyncConfigurationSelector */ @Configuration public class AspectJAsyncConfiguration extends AbstractAsyncConfiguration { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java index 2c815be98869..066dd11da520 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -39,7 +39,7 @@ * a special case of such a general config method. Such config methods * do not have to be public. * - *

In the case of multiple argument methods, the 'required' parameter is + *

In the case of multiple argument methods, the 'required' parameter is * applicable for all arguments. * *

In case of a {@link java.util.Collection} or {@link java.util.Map} @@ -52,8 +52,9 @@ * BeanPostProcessor} which in turn means that you cannot * use {@code @Autowired} to inject references into * {@link org.springframework.beans.factory.config.BeanPostProcessor - * BeanPostProcessor} or {@link BeanFactoryPostProcessor} types. Please - * consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor} + * BeanPostProcessor} or + * {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor BeanFactoryPostProcessor} + * types. Please consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor} * class (which, by default, checks for the presence of this annotation). * * @author Juergen Hoeller diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Value.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Value.java index 2136666cfbd2..eb257fdfcb1c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Value.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Value.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -37,8 +37,9 @@ * BeanPostProcessor} which in turn means that you cannot use * {@code @Value} within * {@link org.springframework.beans.factory.config.BeanPostProcessor - * BeanPostProcessor} or {@link BeanFactoryPostProcessor} types. Please - * consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor} + * BeanPostProcessor} or + * {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor BeanFactoryPostProcessor} + * types. Please consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor} * class (which, by default, checks for the presence of this annotation). * * @author Juergen Hoeller diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java index 6e5d0f5780a4..7b3c5ea5df29 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java @@ -171,7 +171,7 @@ public void afterPropertiesSet() throws ClassNotFoundException, NoSuchFieldExcep int lastDotIndex = this.staticField.lastIndexOf('.'); if (lastDotIndex == -1 || lastDotIndex == this.staticField.length()) { throw new IllegalArgumentException( - "staticField must be a fully qualified class plus method name: " + + "staticField must be a fully qualified class plus static field name: " + "e.g. 'example.MyExampleClass.MY_EXAMPLE_FIELD'"); } String className = this.staticField.substring(0, lastDotIndex); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java index ddf060283c4c..2f6bd6865a11 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -36,8 +36,8 @@ * *

{@code
  *
- *    
- *    
+ *    
+ *    
  *
  *}
* @@ -76,7 +76,7 @@ *

Example XML property with default value: * *

{@code
- *  
+ *  
  *}
* * @author Chris Beams diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java index b63652e79ff0..df22acc2f49b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -353,7 +353,7 @@ public void initDefaults(Element root) { * parentDefaults in case the defaults are not explicitly set * locally. * @param defaults the defaults to populate - * @param defaults the parent BeanDefinitionParserDelegate (if any) defaults to fall back to + * @param parentDefaults the parent BeanDefinitionParserDelegate (if any) defaults to fall back to * @param root the root element of the current bean definition document (or nested beans element) */ protected void populateDefaults(DocumentDefaultsDefinition defaults, DocumentDefaultsDefinition parentDefaults, Element root) { diff --git a/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java b/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java index b1c537ed3920..bcf6c8931c91 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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,6 @@ import org.springframework.beans.propertyeditors.InputStreamEditor; import org.springframework.beans.propertyeditors.URIEditor; import org.springframework.beans.propertyeditors.URLEditor; -import org.springframework.core.env.Environment; import org.springframework.core.env.PropertyResolver; import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.ContextResource; @@ -71,7 +70,7 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar { * @see org.springframework.core.io.support.ResourcePatternResolver * @see org.springframework.context.ApplicationContext * @deprecated as of Spring 3.1 in favor of - * {@link #ResourceEditorRegistrar(ResourceLoader, Environment)} + * {@link #ResourceEditorRegistrar(ResourceLoader, PropertyResolver)} */ @Deprecated public ResourceEditorRegistrar(ResourceLoader resourceLoader) { diff --git a/spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-beans-3.2.xsd b/spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-beans-3.2.xsd new file mode 100644 index 000000000000..c8dec329588d --- /dev/null +++ b/spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-beans-3.2.xsd @@ -0,0 +1,1180 @@ + + + + + + + + + + + + + + + + + + element. + ]]> + + + + + + + + and other elements, typically the root element in the document. + Allows the definition of default values for all nested bean definitions. May itself + be nested for the purpose of defining a subset of beans with certain default values or + to be registered only when certain profile(s) are active. Any such nested element + must be declared as the last element in the document. + ]]> + + + + + + + + + + + + + + + element may be parsed. Multiple profiles can be + separated by any number of spaces, commas, or semi-colons (or indeed any mixture of the three). + If one or more of the specified profiles are active at time of parsing, the element + will be parsed, and all of its elements registered, <import> elements followed, + etc. If none of the specified profiles are active at time of parsing, then the entire element + and its contents will be ignored. + + Profiles are activated in one of two ways: + Programmatic: + ConfigurableEnvironment#setActiveProfiles(String...) + ConfigurableEnvironment#setDefaultProfiles(String...) + + Properties (typically through -D system properties, environment variables, or servlet context init params): + spring.profiles.active=p1,p2 + spring.profiles.default=p1,p2 + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + element (or "ref" + attribute). We recommend this in most cases as it makes documentation + more explicit. + + Note that this default mode also allows for annotation-driven autowiring, + if activated. "no" refers to externally driven autowiring only, not + affecting any autowiring demands that the bean class itself expresses. + + 2. "byName" + Autowiring by property name. If a bean of class Cat exposes a "dog" + property, Spring will try to set this to the value of the bean "dog" + in the current container. If there is no matching bean by name, nothing + special happens. + + 3. "byType" + Autowiring if there is exactly one bean of the property type in the + container. If there is more than one, a fatal error is raised, and + you cannot use byType autowiring for that bean. If there is none, + nothing special happens. + + 4. "constructor" + Analogous to "byType" for constructor arguments. If there is not exactly + one bean of the constructor argument type in the bean factory, a fatal + error is raised. + + Note that explicit dependencies, i.e. "property" and "constructor-arg" + elements, always override autowiring. + + Note: This attribute will not be inherited by child bean definitions. + Hence, it needs to be specified per concrete bean definition. + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + " element. + ]]> + + + + + ..." element. + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ". + ]]> + + + + + ..." element. + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ". + ]]> + + + + + ..." + element. + ]]> + + + + + ". + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-tool-3.2.xsd b/spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-tool-3.2.xsd new file mode 100644 index 000000000000..9d84906adead --- /dev/null +++ b/spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-tool-3.2.xsd @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-util-3.2.xsd b/spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-util-3.2.xsd new file mode 100644 index 000000000000..f7a754aa6c24 --- /dev/null +++ b/spring-beans/src/main/resources/org/springframework/beans/factory/xml/spring-util-3.2.xsd @@ -0,0 +1,212 @@ + + + + + + + + + + + Reference a public, static field on a type and expose its value as + a bean. For example <util:constant static-field="java.lang.Integer.MAX_VALUE"/>. + + + + + + + + + + + + Reference a property on a bean (or as a nested value) and expose its values as + a bean. For example <util:property-path path="order.customer.name"/>. + + + + + + + + + + + + Builds a List instance of the specified type, populated with the specified content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Builds a Set instance of the specified type, populated with the specified content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Builds a Map instance of the specified type, populated with the specified content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Loads a Properties instance from the resource location specified by the 'location' attribute. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java index a8294f05d41e..eb2644c5f7f9 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/CronTriggerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -56,9 +56,7 @@ * @since 3.1 * @see #setName * @see #setGroup - * @see #setStartTime - * @see #setJobName - * @see #setJobGroup + * @see #setStartDelay * @see #setJobDetail * @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setTriggers * @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setJobDetails diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java index c26b0d004245..9de19249487d 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleTriggerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -56,9 +56,7 @@ * @since 3.1 * @see #setName * @see #setGroup - * @see #setStartTime - * @see #setJobName - * @see #setJobGroup + * @see #setStartDelay * @see #setJobDetail * @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setTriggers * @see org.springframework.scheduling.quartz.SchedulerFactoryBean#setJobDetails diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/CacheAnnotationParser.java b/spring-context/src/main/java/org/springframework/cache/annotation/CacheAnnotationParser.java index f6757adb5ae7..a1d8a79c8087 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/CacheAnnotationParser.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/CacheAnnotationParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -41,7 +41,7 @@ public interface CacheAnnotationParser { * @param ae the annotated method or class * @return CacheOperation the configured caching operation, * or {@code null} if none was found - * @see AnnotationCacheOperationSource#determineCacheOperation + * @see AnnotationCacheOperationSource#determineCacheOperations(AnnotatedElement) */ Collection parseCacheAnnotations(AnnotatedElement ae); } diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java index df8be605cc1f..33c4a120a766 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -30,7 +30,7 @@ * @since 3.1 * @see EnableCaching * @see ProxyCachingConfiguration - * @see AnnotationConfigUtils.CACHE_ASPECT_CONFIGURATION_CLASS_NAME + * @see AnnotationConfigUtils#CACHE_ASPECT_CONFIGURATION_CLASS_NAME */ public class CachingConfigurationSelector extends AdviceModeImportSelector { diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java b/spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java index a054afa6f7bb..771487a56ff8 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -163,7 +163,7 @@ /** * Indicate how caching advice should be applied. The default is - * {@link AdviceMode.PROXY}. + * {@link AdviceMode#PROXY}. * @see AdviceMode */ AdviceMode mode() default AdviceMode.PROXY; diff --git a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java index 71e8561bec4e..5c78b309203b 100644 --- a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java +++ b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -115,7 +115,7 @@ public void clear() { /** * Convert the given value from the internal store to a user value * returned from the get method (adapting null). - * @param userValue the store value + * @param storeValue the store value * @return the value to return to the user */ protected Object fromStoreValue(Object storeValue) { diff --git a/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java b/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java index 2fb21c7e637e..a1588ac7dfc0 100644 --- a/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -39,8 +39,8 @@ public class EhCacheCacheManager extends AbstractCacheManager { /** - * Returns the backing Ehcache {@link net.sf.ehcache.CacheManager}. - * @return + * Returns the backing EhCache {@link net.sf.ehcache.CacheManager}. + * @return the backing EhCache {@link net.sf.ehcache.CacheManager}. */ public net.sf.ehcache.CacheManager getCacheManager() { return cacheManager; diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/BeanFactoryCacheOperationSourceAdvisor.java b/spring-context/src/main/java/org/springframework/cache/interceptor/BeanFactoryCacheOperationSourceAdvisor.java index 97cb34d624b9..a8d4a51e7b7a 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/BeanFactoryCacheOperationSourceAdvisor.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/BeanFactoryCacheOperationSourceAdvisor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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,6 @@ protected CacheOperationSource getCacheOperationSource() { * Set the cache operation attribute source which is used to find cache * attributes. This should usually be identical to the source reference * set on the cache interceptor itself. - * @see CacheInterceptor#setCacheAttributeSource */ public void setCacheOperationSource(CacheOperationSource cacheOperationSource) { this.cacheOperationSource = cacheOperationSource; diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java index d156a701cdaf..67a22e2b3535 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2011 the original author or authors. + * Copyright 2010-2012 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,7 +24,7 @@ * Proxy factory bean for simplified declarative caching handling. * This is a convenient alternative to a standard AOP * {@link org.springframework.aop.framework.ProxyFactoryBean} - * with a separate {@link CachingInterceptor} definition. + * with a separate {@link CacheInterceptor} definition. * *

This class is designed to facilitate declarative cache demarcation: namely, wrapping * a singleton target object with a caching proxy, proxying all the interfaces that the @@ -36,7 +36,7 @@ * * @author Costin Leau * @see org.springframework.aop.framework.ProxyFactoryBean - * @see CachingInterceptor + * @see CacheInterceptor */ @SuppressWarnings("serial") public class CacheProxyFactoryBean extends AbstractSingletonProxyFactoryBean { diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java index 55d6f2a6c37a..69f22ec49fae 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java @@ -50,7 +50,6 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri * (e.g. "myMethod") and CacheOperation instances * (or Strings to be converted to CacheOperation instances). * @see CacheOperation - * @see CacheOperationEditor */ public void setNameMap(Map> nameMap) { for (Map.Entry> entry : nameMap.entrySet()) { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java index 8478cf6f2ffd..23995bcac9e4 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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 java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; + import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.annotation.Resource; @@ -509,9 +510,12 @@ public final DependencyDescriptor getDependencyDescriptor() { */ private class ResourceElement extends LookupElement { - @SuppressWarnings("unused") protected boolean shareable = true; + private volatile boolean cached = false; + + private volatile Object cachedFieldValue; + public ResourceElement(Member member, PropertyDescriptor pd) { super(member, pd); } @@ -546,7 +550,20 @@ else if (beanFactory instanceof ConfigurableBeanFactory){ @Override protected Object getResourceToInject(Object target, String requestingBeanName) { - return getResource(this, requestingBeanName); + Object value = null; + if (this.cached && this.shareable) { + value = this.cachedFieldValue; + } + synchronized (this) { + if (!this.cached) { + value = getResource(this, requestingBeanName); + if (value != null && this.shareable) { + this.cachedFieldValue = value; + this.cached = true; + } + } + } + return value; } } @@ -724,4 +741,4 @@ public Class getDependencyType() { } } -} +} \ No newline at end of file diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ComponentScan.java b/spring-context/src/main/java/org/springframework/context/annotation/ComponentScan.java index f0826a62ebed..26a3a6cec985 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ComponentScan.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ComponentScan.java @@ -132,7 +132,7 @@ /** * Declares the type filter to be used as an {@linkplain ComponentScan#includeFilters() - * include filter} or {@linkplain ComponentScan#includeFilters() exclude filter}. + * include filter} or {@linkplain ComponentScan#excludeFilters() exclude filter}. */ @Retention(RetentionPolicy.RUNTIME) @Target({}) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java b/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java index 5d39ac635c8a..b09623c29c0f 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -28,7 +28,7 @@ import org.springframework.stereotype.Component; /** - * Indicates that a class declares one or more @{@link Bean} methods and may be processed + * Indicates that a class declares one or more {@link Bean @Bean} methods and may be processed * by the Spring container to generate bean definitions and service requests for those * beans at runtime, for example: *

@@ -76,14 +76,14 @@
  * post processors that facilitate handling {@code @Configuration} classes.
  *
  * 

Via component scanning

- *

{@code @Configuration} is meta-annotated with @{@link Component}, therefore + *

{@code @Configuration} is meta-annotated with {@link Component @Component}, therefore * {@code @Configuration} classes are candidates for component scanning (typically using * Spring XML's {@code } element) and therefore may also take - * advantage of @{@link Autowired}/@{@link Inject} at the field and method level (but not - * at the constructor level). + * advantage of {@link Autowired @Autowired}/{@link javax.inject.Inject @Inject} + * at the field and method level (but not at the constructor level). *

{@code @Configuration} classes may not only be bootstrapped using * component scanning, but may also themselves configure component scanning using - * the @{@link ComponentScan} annotation: + * the {@link ComponentScan @ComponentScan} annotation: *

  * @Configuration
  * @ComponentScan("com.acme.app.services")
@@ -91,8 +91,8 @@
  *     // various @Bean definitions ...
  * }
* - * See @{@link ComponentScan} Javadoc for details. - * + * See {@link ComponentScan @ComponentScan} Javadoc for details. + * * *

Working with externalized values

*

Using the {@code Environment} API

@@ -115,7 +115,8 @@ * * Properties resolved through the {@code Environment} reside in one or more "property * source" objects, and {@code @Configuration} classes may contribute property sources to - * the {@code Environment} object using the @{@link PropertySources} annotation: + * the {@code Environment} object using + * the {@link org.springframework.core.env.PropertySources @PropertySources} annotation: *
  * @Configuration
  * @PropertySource("classpath:/com/acme/app.properties")
@@ -129,11 +130,11 @@
  * }
* * See {@link org.springframework.core.env.Environment Environment} - * and @{@link PropertySource} Javadoc for further details. - * + * and {@link PropertySource @PropertySource} Javadoc for further details. + * *

Using the {@code @Value} annotation

* Externalized values may be 'wired into' {@code @Configuration} classes using - * the @{@link Value} annotation: + * the {@link Value @Value} annotation: *
  * @Configuration
  * @PropertySource("classpath:/com/acme/app.properties")
@@ -151,13 +152,13 @@
  * PropertySourcesPlaceholderConfigurer}, usually enabled via XML with
  * {@code }.  See the section below on composing
  * {@code @Configuration} classes with Spring XML using {@code @ImportResource},
- * see @{@link Value} Javadoc, and see @{@link Bean} Javadoc for details on working with
+ * see {@link Value @Value} Javadoc, and see {@link Bean @Bean} Javadoc for details on working with
  * {@code BeanFactoryPostProcessor} types such as
  * {@code PropertySourcesPlaceholderConfigurer}.
  *
  * 

Composing {@code @Configuration} classes

*

With the {@code @Import} annotation

- *

{@code @Configuration} classes may be composed using the @{@link Import} annotation, + *

{@code @Configuration} classes may be composed using the {@link Import @Import} annotation, * not unlike the way that {@code } works in Spring XML. Because * {@code @Configuration} objects are managed as Spring beans within the container, * imported configurations may be injected using {@code @Autowired} or {@code @Inject}: @@ -189,7 +190,7 @@ * new AnnotationConfigApplicationContext(AppConfig.class);

* *

With the {@code @Profile} annotation

- * {@code @Configuration} classes may be marked with the @{@link Profile} annotation to + * {@code @Configuration} classes may be marked with the {@link Profile @Profile} annotation to * indicate they should be processed only if a given profile or profiles are * active: *
@@ -211,14 +212,14 @@
  *     }
  * }
* - * See @{@link Profile} and {@link org.springframework.core.env.Environment Environment} + * See {@link Profile @Profile} and {@link org.springframework.core.env.Environment Environment} * Javadoc for further details. * *

With Spring XML using the {@code @ImportResource} annotation

* As mentioned above, {@code @Configuration} classes may be declared as regular Spring * {@code } definitions within Spring XML files. It is also possible to * import Spring XML configuration files into {@code @Configuration} classes using - * the @{@link ImportResource} annotation. Bean definitions imported from XML can be + * the {@link ImportResource @ImportResource} annotation. Bean definitions imported from XML can be * injected using {@code @Autowired} or {@code @Import}: *
  * @Configuration
@@ -267,7 +268,7 @@
  * 

Configuring lazy initialization

*

By default, {@code @Bean} methods will be eagerly instantiated at container * bootstrap time. To avoid this, {@code @Configuration} may be used in conjunction with - * the @{@link Lazy} annotation to indicate that all {@code @Bean} methods declared within + * the {@link Lazy @Lazy} annotation to indicate that all {@code @Bean} methods declared within * the class are by default lazily initialized. Note that {@code @Lazy} may be used on * individual {@code @Bean} methods as well. * @@ -291,7 +292,7 @@ * }

* * See TestContext framework reference documentation for details. - * + * *

Enabling built-in Spring features using {@code @Enable} annotations

* Spring features such as asynchronous method execution, scheduled task execution, * annotation driven transaction management, and even Spring MVC can be enabled and @@ -309,7 +310,7 @@ *
  • @Configuration classes must be non-final *
  • @Configuration classes must be non-local (may not be declared within a method) *
  • @Configuration classes must have a default/no-arg constructor and may not - * use @{@link Autowired} constructor parameters. Any nested configuration classes + * use {@link Autowired @Autowired} constructor parameters. Any nested configuration classes * must be {@code static} * * diff --git a/spring-context/src/main/java/org/springframework/context/annotation/EnableLoadTimeWeaving.java b/spring-context/src/main/java/org/springframework/context/annotation/EnableLoadTimeWeaving.java index bed3cec76acd..3c8abd8066fd 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/EnableLoadTimeWeaving.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/EnableLoadTimeWeaving.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -64,13 +64,13 @@ * TomcatInstrumentableClassLoader}). * *

    To customize the weaver used, the {@code @Configuration} class annotated with - * {@code @EnableLoadTimeWeaving} may also implement the {@link LoadTimeWeaverConfigurer} + * {@code @EnableLoadTimeWeaving} may also implement the {@link LoadTimeWeavingConfigurer} * interface and return a custom {@code LoadTimeWeaver} instance through the * {@code #getLoadTimeWeaver} method: *

      * @Configuration
      * @EnableLoadTimeWeaving
    - * public class AppConfig implements LoadTimeWeaverConfigurer {
    + * public class AppConfig implements LoadTimeWeavingConfigurer {
      *     @Override
      *     public LoadTimeWeaver getLoadTimeWeaver() {
      *         MyLoadTimeWeaver ltw = new MyLoadTimeWeaver();
    diff --git a/spring-context/src/main/java/org/springframework/context/annotation/FilterType.java b/spring-context/src/main/java/org/springframework/context/annotation/FilterType.java
    index 9ed1b8994348..26bd302d8e8f 100644
    --- a/spring-context/src/main/java/org/springframework/context/annotation/FilterType.java
    +++ b/spring-context/src/main/java/org/springframework/context/annotation/FilterType.java
    @@ -28,8 +28,8 @@
      * @author Chris Beams
      * @since 2.5
      * @see ComponentScan
    - * @see ComponentScan.IncludeFilter
    - * @see ComponentScan.ExcludeFilter
    + * @see ComponentScan#includeFilters()
    + * @see ComponentScan#excludeFilters()
      * @see org.springframework.core.type.filter.TypeFilter
      */
     public enum FilterType {
    diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Import.java b/spring-context/src/main/java/org/springframework/context/annotation/Import.java
    index 4a2fe947ca87..6aacf68a4403 100644
    --- a/spring-context/src/main/java/org/springframework/context/annotation/Import.java
    +++ b/spring-context/src/main/java/org/springframework/context/annotation/Import.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2002-2011 the original author or authors.
    + * Copyright 2002-2012 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,23 +23,23 @@
     import java.lang.annotation.Target;
     
     /**
    - * Indicates one or more @{@link Configuration} classes to import.
    + * Indicates one or more {@link Configuration @Configuration} classes to import.
      *
      * 

    Provides functionality equivalent to the {@code } element in Spring XML. * Only supported for classes annotated with {@code @Configuration} or declaring at least - * one {@link @Bean} method, as well as {@link ImportSelector} and + * one {@link Bean @Bean} method, as well as {@link ImportSelector} and * {@link ImportBeanDefinitionRegistrar} implementations. * - *

    @{@code Bean} definitions declared in imported {@code @Configuration} classes - * should be accessed by using @{@link Autowired} injection. Either the bean itself can - * be autowired, or the configuration class instance declaring the bean can be autowired. - * The latter approach allows for explicit, IDE-friendly navigation between - * {@code @Configuration} class methods. + *

    {@code @Bean} definitions declared in imported {@code @Configuration} classes + * should be accessed by using {@link org.springframework.beans.factory.annotation.Autowired @Autowired} + * injection. Either the bean itself can be autowired, or the configuration class instance + * declaring the bean can be autowired. The latter approach allows for explicit, + * IDE-friendly navigation between {@code @Configuration} class methods. * *

    May be declared at the class level or as a meta-annotation. * *

    If XML or other non-{@code @Configuration} bean definition resources need to be - * imported, use @{@link ImportResource} + * imported, use {@link ImportResource @ImportResource} * * @author Chris Beams * @since 3.0 diff --git a/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfigurer.java b/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfigurer.java index 63322f629665..8df85b91f095 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfigurer.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/LoadTimeWeavingConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -19,12 +19,14 @@ import org.springframework.instrument.classloading.LoadTimeWeaver; /** - * Interface to be implemented by @{@link org.springframework.context.annotation.Configuration - * Configuration} classes annotated with @{@link EnableLoadTimeWeaving} that wish to + * Interface to be implemented by + * {@link org.springframework.context.annotation.Configuration @Configuration} + * classes annotated with {@link EnableLoadTimeWeaving @EnableLoadTimeWeaving} that wish to * customize the {@link LoadTimeWeaver} instance to be used. * - *

    See @{@link EnableAsync} for usage examples and information on how a default - * {@code LoadTimeWeaver} is selected when this interface is not used. + *

    See {@link org.springframework.scheduling.annotation.EnableAsync @EnableAsync} + * for usage examples and information on how a default {@code LoadTimeWeaver} + * is selected when this interface is not used. * * @author Chris Beams * @since 3.1 diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index 84831884b7be..23b157f1d8ab 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -506,7 +506,7 @@ protected void prepareRefresh() { /** *

    Replace any stub property sources with actual instances. * @see org.springframework.core.env.PropertySource.StubPropertySource - * @see org.springframework.web.context.support.WebApplicationContextUtils#initSerlvetPropertySources + * @see org.springframework.web.context.support.WebApplicationContextUtils#initServletPropertySources */ protected void initPropertySources() { // For subclasses: do nothing by default. diff --git a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java index aa8d9e799249..c831bbb85514 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java +++ b/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2012 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. @@ -108,7 +108,7 @@ public void setEnvironment(Environment environment) { *

    Processing occurs by replacing ${...} placeholders in bean definitions by resolving each * against this configurer's set of {@link PropertySources}, which includes: *