Commits

rainerh  committed 2085a1c

o added ActionValidatorManagerFactory to support tiger classes

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

  • Participants
  • Parent commits 1ca77e1

Comments (0)

Files changed (1)

File src/java/com/opensymphony/xwork/validator/ActionValidatorManagerFactory.java

+/*
+ * Copyright (c) 2005, Your Corporation. All Rights Reserved.
+ */
+
+package com.opensymphony.xwork.validator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import com.opensymphony.util.ClassLoaderUtil;
+
+/**
+ * <code>ActionValidatorManagerFactory</code>
+ *
+ * @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
+ * @version $Id$
+ */
+public class ActionValidatorManagerFactory {
+
+    private static final Log LOG = LogFactory.getLog(ActionValidatorManagerFactory.class);
+
+    private static ActionValidatorManager instance = new ActionValidatorManager();
+
+    static {
+        try {
+            Class c = ClassLoaderUtil.loadClass("com.opensymphony.xwork.util.AnnotationActionValidatorManager", ActionValidatorManagerFactory.class);
+
+            LOG.info("Detected AnnotationActionValidatorManager, initializing it...");
+            instance = (ActionValidatorManager) c.newInstance();
+        } 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 AnnotationActionValidatorManager", e);
+        }
+    }
+
+    public static void setInstance(ActionValidatorManager instance) {
+        ActionValidatorManagerFactory.instance = instance;
+    }
+
+    public static ActionValidatorManager getInstance() {
+        return instance;
+    }
+}