01: /*
02: * Copyright (c) 2002-2006 by OpenSymphony
03: * All rights reserved.
04: */
05:
06: package com.opensymphony.xwork.validator;
07:
08: import org.apache.commons.logging.Log;
09: import org.apache.commons.logging.LogFactory;
10: import com.opensymphony.util.ClassLoaderUtil;
11: import com.opensymphony.xwork.XworkException;
12:
13: /**
14: * <code>ActionValidatorManagerFactory</code>
15: *
16: * @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
17: * @version $Id: ActionValidatorManagerFactory.java 994 2006-04-11 21:02:00Z mrdon $
18: */
19: public class ActionValidatorManagerFactory {
20:
21: private static final Log LOG = LogFactory
22: .getLog(ActionValidatorManagerFactory.class);
23:
24: private static ActionValidatorManager instance = new DefaultActionValidatorManager();
25:
26: static {
27: try {
28: Class c = ClassLoaderUtil
29: .loadClass(
30: "com.opensymphony.xwork.validator.AnnotationActionValidatorManager",
31: ActionValidatorManagerFactory.class);
32:
33: LOG
34: .info("Detected AnnotationActionValidatorManager, initializing it...");
35: instance = (ActionValidatorManager) c.newInstance();
36: } catch (ClassNotFoundException e) {
37: // this is fine, just fall back to the default object type determiner
38: } catch (Exception e) {
39: throw new XworkException(e);
40: }
41: }
42:
43: public static void setInstance(ActionValidatorManager instance) {
44: ActionValidatorManagerFactory.instance = instance;
45: }
46:
47: public static ActionValidatorManager getInstance() {
48: return instance;
49: }
50: }
|