Commits

Anonymous committed 3b0b29e

o added support for XWorkAnnotationConverter from xwork-tiger project via fake factory
o refactored some methods visibility from private to package local to allow extending in subclasses

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@659e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork/util/XWorkConverter.java

  */
 public class XWorkConverter extends DefaultTypeConverter {
     private static XWorkConverter instance;
-    private static final Log LOG = LogFactory.getLog(XWorkConverter.class);
+    protected static final Log LOG = LogFactory.getLog(XWorkConverter.class);
     public static final String REPORT_CONVERSION_ERRORS = "report.conversion.errors";
     public static final String CONVERSION_PROPERTY_FULLNAME = "conversion.property.fullName";
     public static final String CONVERSION_ERROR_PROPERTY_PREFIX = "invalid.fieldvalue.";
     ObjectTypeDeterminer keyElementDeterminer = ObjectTypeDeterminerFactory.getInstance();
 
 
-    private XWorkConverter() {
+    protected XWorkConverter() {
         try {
             // note: this file is deprecated
             loadConversionProperties("xwork-default-conversion.properties");
 
     public static XWorkConverter getInstance() {
         if (instance == null) {
-            instance = new XWorkConverter();
+            try {
+                Class clazz = Thread.currentThread().getContextClassLoader().loadClass("com.opensymphony.xwork.util.AnnotationXWorkConverter");
+                instance = (XWorkConverter) clazz.newInstance();
+                LOG.info("Detected AnnotationXWorkConverter, initializing it...");
+            } catch (ClassNotFoundException e) {
+                // this is fine, just fall back to the default object type determiner
+            } catch (Exception e) {
+                LOG.error("Exception when trying to create new AnnotationXWorkConverter", e);
+            }
+            if ( instance == null ) {
+                instance = new XWorkConverter();
+            }
         }
 
         return instance;
      * @param mapping an existing map to add new converter mappings to
      * @param clazz   class to look for converter mappings for
      */
-    private void addConverterMapping(Map mapping, Class clazz) {
+    void addConverterMapping(Map mapping, Class clazz) {
         try {
             InputStream is = FileManager.loadFile(buildConverterFilename(clazz), clazz);
 
         return mapping;
     }
 
-    private TypeConverter createTypeConverter(String className) throws Exception {
+    TypeConverter createTypeConverter(String className) throws Exception {
         Class conversionClass = Thread.currentThread().getContextClassLoader().loadClass(className);
 
         // type converters are used across users
      * @param clazz the class the TypeConverter must handle
      * @return a TypeConverter to handle the specified class or null if none can be found
      */
-    private TypeConverter lookupSuper(Class clazz) {
+    TypeConverter lookupSuper(Class clazz) {
         TypeConverter result = null;
 
         if (clazz != null) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.