diff --git a/core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java b/core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java index 5b41afdbf..64f46d58a 100644 --- a/core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java +++ b/core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java @@ -73,16 +73,6 @@ public class AnnotationValidationConfigurationBuilder { if (a instanceof Validations) { processValidationAnnotation(a, fieldName, methodName, result); } - - // Process single custom validator - if (a instanceof Validation) { - Validation v = (Validation) a; - if (v.validations() != null) { - for (Validations val : v.validations()) { - processValidationAnnotation(val, fieldName, methodName, result); - } - } - } // Process single custom validator else if (a instanceof ExpressionValidator) { ExpressionValidator v = (ExpressionValidator) a; diff --git a/core/src/main/java/com/opensymphony/xwork2/validator/annotations/Validation.java b/core/src/main/java/com/opensymphony/xwork2/validator/annotations/Validation.java deleted file mode 100644 index 036b2dd35..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/validator/annotations/Validation.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.opensymphony.xwork2.validator.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * - * This annotation has been deprecated since 2.1 as its previous purpose, to define classes that support annotation validations, - * is no longer necessary. - * - * - *
Annotation usage:
- * - * - *The Validation annotation must be applied at Type level.
- * - * - *Annotation parameters:
- * - * - *| Parameter | - *Required | - *Default | - *Notes | - *
|---|---|---|---|
| validations | - *yes | - *- * | - * |
Example code:
- * - * An Annotated Interface - *
- *
- * @Validation()
- * public interface AnnotationDataAware {
- *
- * void setBarObj(Bar b);
- *
- * Bar getBarObj();
- *
- * @RequiredFieldValidator(message = "You must enter a value for data.")
- * @RequiredStringValidator(message = "You must enter a value for data.")
- * void setData(String data);
- *
- * String getData();
- * }
- *
- *
- *
- * Example code:
- * - * An Annotated Class - *
- *
- * @Validation()
- * public class SimpleAnnotationAction extends ActionSupport {
- *
- * @RequiredFieldValidator(type = ValidatorType.FIELD, message = "You must enter a value for bar.")
- * @IntRangeFieldValidator(type = ValidatorType.FIELD, min = "6", max = "10", message = "bar must be between ${min} and ${max}, current value is ${bar}.")
- * public void setBar(int bar) {
- * this.bar = bar;
- * }
- *
- * public int getBar() {
- * return bar;
- * }
- *
- * @Validations(
- * requiredFields =
- * {@RequiredFieldValidator(type = ValidatorType.SIMPLE, fieldName = "customfield", message = "You must enter a value for field.")},
- * requiredStrings =
- * {@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "stringisrequired", message = "You must enter a value for string.")},
- * emails =
- * { @EmailValidator(type = ValidatorType.SIMPLE, fieldName = "emailaddress", message = "You must enter a value for email.")},
- * urls =
- * { @UrlValidator(type = ValidatorType.SIMPLE, fieldName = "hreflocation", message = "You must enter a value for email.")},
- * stringLengthFields =
- * {@StringLengthFieldValidator(type = ValidatorType.SIMPLE, trim = true, minLength="10" , maxLength = "12", fieldName = "needstringlength", message = "You must enter a stringlength.")},
- * intRangeFields =
- * { @IntRangeFieldValidator(type = ValidatorType.SIMPLE, fieldName = "intfield", min = "6", max = "10", message = "bar must be between ${min} and ${max}, current value is ${bar}.")},
- * dateRangeFields =
- * {@DateRangeFieldValidator(type = ValidatorType.SIMPLE, fieldName = "datefield", min = "-1", max = "99", message = "bar must be between ${min} and ${max}, current value is ${bar}.")},
- * expressions = {
- * @ExpressionValidator(expression = "foo > 1", message = "Foo must be greater than Bar 1. Foo = ${foo}, Bar = ${bar}."),
- * @ExpressionValidator(expression = "foo > 2", message = "Foo must be greater than Bar 2. Foo = ${foo}, Bar = ${bar}."),
- * @ExpressionValidator(expression = "foo > 3", message = "Foo must be greater than Bar 3. Foo = ${foo}, Bar = ${bar}."),
- * @ExpressionValidator(expression = "foo > 4", message = "Foo must be greater than Bar 4. Foo = ${foo}, Bar = ${bar}."),
- * @ExpressionValidator(expression = "foo > 5", message = "Foo must be greater than Bar 5. Foo = ${foo}, Bar = ${bar}.")
- * }
- * )
- * public String execute() throws Exception {
- * return SUCCESS;
- * }
- * }
- *
- *
- *
- *
- * @author Rainer Hermanns
- * @deprecated Since Struts 2.1 because it isn't necessary anymore
- */
-@Deprecated
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Validation {
-
- /**
- * Used for class or interface validation rules.
- *
- * @return array of validations
- */
- Validations[] validations() default {};
-}
diff --git a/core/src/test/java/com/opensymphony/xwork2/SimpleAnnotationAction.java b/core/src/test/java/com/opensymphony/xwork2/SimpleAnnotationAction.java
index eda907d38..5e21a0984 100644
--- a/core/src/test/java/com/opensymphony/xwork2/SimpleAnnotationAction.java
+++ b/core/src/test/java/com/opensymphony/xwork2/SimpleAnnotationAction.java
@@ -26,12 +26,8 @@ import java.util.Properties;
/**
- * Simple Test Action for annotaton processing.
- *
- * @author Rainer Hermanns
- * @version $Revision$
+ * Simple Test Action for annotation processing.
*/
-@Validation()
public class SimpleAnnotationAction extends ActionSupport {
//~ Static fields/initializers /////////////////////////////////////////////
diff --git a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationDataAware.java b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationDataAware.java
index 9ec0d60c6..13a65ed0b 100644
--- a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationDataAware.java
+++ b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationDataAware.java
@@ -24,7 +24,6 @@ import com.opensymphony.xwork2.conversion.impl.FooBarConverter;
import com.opensymphony.xwork2.util.Bar;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
-import com.opensymphony.xwork2.validator.annotations.Validation;
/**
diff --git a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUser.java b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUser.java
index 91b656924..0b941b1d3 100644
--- a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUser.java
+++ b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUser.java
@@ -21,7 +21,11 @@ package com.opensymphony.xwork2.test;
import com.opensymphony.xwork2.conversion.annotations.ConversionRule;
import com.opensymphony.xwork2.conversion.annotations.TypeConversion;
import com.opensymphony.xwork2.util.KeyProperty;
-import com.opensymphony.xwork2.validator.annotations.*;
+import com.opensymphony.xwork2.validator.annotations.EmailValidator;
+import com.opensymphony.xwork2.validator.annotations.ExpressionValidator;
+import com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator;
+import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
+import com.opensymphony.xwork2.validator.annotations.Validations;
import java.util.Collection;
import java.util.List;
@@ -30,17 +34,12 @@ import java.util.Map;
/**
* Test bean.
- *
- * @author Mark Woon
- * @author Rainer Hermanns
*/
-@Validation(
- validations = @Validations(
- expressions = {
- @ExpressionValidator(expression = "email.startsWith('mark')", message = "Email does not start with mark"),
- @ExpressionValidator(expression = "email2.startsWith('mark')", message = "Email2 does not start with mark")
- }
- )
+@Validations(
+ expressions = {
+ @ExpressionValidator(expression = "email.startsWith('mark')", message = "Email does not start with mark"),
+ @ExpressionValidator(expression = "email2.startsWith('mark')", message = "Email2 does not start with mark")
+ }
)
public class AnnotationUser implements AnnotationUserMarker {
@@ -84,7 +83,7 @@ public class AnnotationUser implements AnnotationUserMarker {
list = l;
}
- @KeyProperty( value = "name")
+ @KeyProperty(value = "name")
@TypeConversion(converterClass = String.class, rule = ConversionRule.COLLECTION)
public List getList() {
return list;
diff --git a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUserMarker.java b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUserMarker.java
index e4820cfa7..f68adb40b 100644
--- a/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUserMarker.java
+++ b/core/src/test/java/com/opensymphony/xwork2/test/AnnotationUserMarker.java
@@ -20,25 +20,19 @@ package com.opensymphony.xwork2.test;
import com.opensymphony.xwork2.validator.annotations.ExpressionValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
-import com.opensymphony.xwork2.validator.annotations.Validation;
import com.opensymphony.xwork2.validator.annotations.Validations;
/**
* Marker interface to help test hierarchy traversal.
- *
- * @author Mark Woon
- * @author Rainer Hermanns
*/
-@Validation(
- validations = @Validations(
- requiredFields = {
- @RequiredFieldValidator(fieldName = "email", shortCircuit = true, message = "You must enter a value for email."),
- @RequiredFieldValidator(fieldName = "email2", shortCircuit = true, message = "You must enter a value for email2.")
- },
- expressions = {
- @ExpressionValidator(shortCircuit = true, expression = "email.equals(email2)", message = "Email not the same as email2" )
- }
- )
+@Validations(
+ requiredFields = {
+ @RequiredFieldValidator(fieldName = "email", shortCircuit = true, message = "You must enter a value for email."),
+ @RequiredFieldValidator(fieldName = "email2", shortCircuit = true, message = "You must enter a value for email2.")
+ },
+ expressions = {
+ @ExpressionValidator(shortCircuit = true, expression = "email.equals(email2)", message = "Email not the same as email2")
+ }
)
public interface AnnotationUserMarker {
}
diff --git a/core/src/test/java/com/opensymphony/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java b/core/src/test/java/com/opensymphony/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java
index cfb9b16d7..b57361cd4 100644
--- a/core/src/test/java/com/opensymphony/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java
+++ b/core/src/test/java/com/opensymphony/xwork2/test/annotations/ValidateAnnotatedMethodOnlyAction.java
@@ -20,15 +20,10 @@ package com.opensymphony.xwork2.test.annotations;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.ExpressionValidator;
-import com.opensymphony.xwork2.validator.annotations.Validation;
/**
* ValidateAnnotatedMethodOnlyAction
- *
- * @author Rainer Hermanns
- * @version $Id$
*/
-@Validation
public class ValidateAnnotatedMethodOnlyAction extends ActionSupport {
String param1;
@@ -52,7 +47,7 @@ public class ValidateAnnotatedMethodOnlyAction extends ActionSupport {
}
@ExpressionValidator(expression = "(param1 != null) || (param2 != null)",
- message = "Need param1 or param2.")
+ message = "Need param1 or param2.")
public String annotatedMethod() {
try {
// do search