WW-3829 adds better logging and improve example in JavaDoc

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1436526 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lukasz Lenart
2013-01-21 18:13:32 +00:00
parent 32ea57d925
commit 96c99ce061
2 changed files with 39 additions and 8 deletions
@@ -22,13 +22,13 @@ import java.lang.annotation.Target;
/**
* <!-- START SNIPPET: description -->
* <p/>A marker annotation for type conversions at Type level.
* A marker annotation for type conversions at Type level.
* <!-- END SNIPPET: description -->
*
* <p/> <u>Annotation usage:</u>
*
* <!-- START SNIPPET: usage -->
* <p/>The Conversion annotation must be applied at Type level.
* The Conversion annotation must be applied at Type level. Check also [TypeConversion Annotation] for more examples!
* <!-- END SNIPPET: usage -->
*
* <p/> <u>Annotation parameters:</u>
@@ -58,8 +58,24 @@ import java.lang.annotation.Target;
*
* <pre>
* <!-- START SNIPPET: example -->
* &#64;Conversion()
* &#64;Conversion(
* conversions = {
* // key must be the name of a property for which converter should be used
* &#64;TypeConversion(key = "date", converter = "org.demo.converter.DateConverter")
* }
* )
* public class ConversionAction implements Action {
*
* private Date date;
*
* public setDate(Date date) {
* this.date = date;
* }
*
* public Date getDate() {
* return date;
* }
*
* }
*
* <!-- END SNIPPET: example -->
@@ -20,8 +20,8 @@ import com.opensymphony.xwork2.FileManager;
import com.opensymphony.xwork2.FileManagerFactory;
import com.opensymphony.xwork2.ObjectFactory;
import com.opensymphony.xwork2.XWorkConstants;
import com.opensymphony.xwork2.XWorkMessages;
import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.XWorkMessages;
import com.opensymphony.xwork2.conversion.TypeConverter;
import com.opensymphony.xwork2.conversion.annotations.Conversion;
import com.opensymphony.xwork2.conversion.annotations.ConversionRule;
@@ -29,10 +29,15 @@ import com.opensymphony.xwork2.conversion.annotations.ConversionType;
import com.opensymphony.xwork2.conversion.annotations.TypeConversion;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.ognl.XWorkTypeConverterWrapper;
import com.opensymphony.xwork2.util.*;
import com.opensymphony.xwork2.util.AnnotationUtils;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import com.opensymphony.xwork2.util.CompoundRoot;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.InputStream;
@@ -40,10 +45,16 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.text.MessageFormat;
/**
@@ -587,7 +598,11 @@ public class XWorkConverter extends DefaultTypeConverter {
break;
}
if (LOG.isDebugEnabled()) {
LOG.debug(key + ":" + key);
if (StringUtils.isEmpty(key)) {
LOG.debug("WARNING! key of @TypeConversion [#0] applied to [#1] is empty!", tc.converter(), clazz.getName());
} else {
LOG.debug("TypeConversion [#0] with key: [#1]", tc.converter(), key);
}
}
if (key != null) {