From 83e8c95ea7d257166d350a59bfd81e9833ec14fd Mon Sep 17 00:00:00 2001 From: clemenso Date: Thu, 5 Nov 2009 19:05:14 +0000 Subject: [#484] European Language support git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@535 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../at/gv/egiz/bku/viewer/ValidatorFactory.java | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java') diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java index e16a261e..ad9bf6bb 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/viewer/ValidatorFactory.java @@ -17,6 +17,8 @@ package at.gv.egiz.bku.viewer; import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.util.Collections; import java.util.Enumeration; @@ -108,14 +110,25 @@ public class ValidatorFactory { return null; } - + + /** + * + * @throws InvocationTargetException if className's (nullary) constructor throws exception + */ private Validator createValidatorInstance(String className) throws ClassNotFoundException, InstantiationException, - IllegalAccessException { - + IllegalAccessException, NoSuchMethodException, InvocationTargetException { + try { - Class implClass = classLoader.loadClass(className); - return (Validator) implClass.newInstance(); + Constructor implConstructor = classLoader.loadClass(className).getConstructor((Class[])null); + return (Validator) implConstructor.newInstance((Object[])null); + } catch (InvocationTargetException ex) { + //ex from constructor + log.error("Failed to initialize validator class '" + className + "': " + ex.getCause().getMessage(), ex.getCause()); + throw ex; + } catch (NoSuchMethodException ex) { + log.error("Validator class '" + className + "' has no nullary constructor", ex); + throw ex; } catch (ClassNotFoundException e) { log.error("Validator class '" + className + "' not found.", e); throw e; -- cgit v1.2.3