webwork/src/main/webwork/util InjectionUtils.java,1.1,1.2

[email protected] Wed, 09 Jun 2004 16:46:25 -0700
Newsgroups gmane.comp.java.open-symphony.cvs
Message-ID <[email protected]>
Update of /cvsroot/opensymphony/webwork/src/main/webwork/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2910/src/main/webwork/util

Modified Files:
	InjectionUtils.java 
Log Message:
Fixed up implementation so that it doesn't require the
webwork.injection.class property to be set.  Previously this would throw
an IllegalArgumentException if it wasn't set.

More fixes on  WW-550.


Index: InjectionUtils.java
===================================================================
RCS file: /cvsroot/opensymphony/webwork/src/main/webwork/util/InjectionUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- InjectionUtils.java	4 Jun 2004 07:57:25 -0000	1.1
+++ InjectionUtils.java	9 Jun 2004 23:46:23 -0000	1.2
@@ -1,6 +1,7 @@
 package webwork.util;
 
 import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.LogConfigurationException;
 import webwork.config.Configuration;
 
 import java.lang.reflect.InvocationTargetException;
@@ -23,17 +24,28 @@
     static {
         impl = new DefaultInjectionImpl();
 
-        String classname = (String) Configuration.get(CLASS_NAME);
-        if (classname != null && classname.length() > 0) {
-            try
-            {
-                impl = (InjectionImpl) ClassLoaderUtils.loadClass(classname, InjectionUtils.class).newInstance();
-            }
-            catch (Exception e)
-            {
-                LogFactory.getLog(InjectionUtils.class).error("Could not load class " + classname + " or could not cast it to InjectionUtils.  Using default", e);
+        try
+        {
+            String classname = (String) Configuration.get(CLASS_NAME);
+            if (classname != null && classname.length() > 0) {
+                try
+                {
+                    impl = (InjectionImpl) ClassLoaderUtils.loadClass(classname, InjectionUtils.class).newInstance();
+                }
+                catch (Exception e)
+                {
+                    LogFactory.getLog(InjectionUtils.class).error("Could not load class " + classname + " or could not cast it to InjectionUtils.  Using default", e);
+                }
             }
         }
+        catch (IllegalArgumentException e)
+        {
+            //do nothing - this is just because the property couldn't be found.
+        }
+        catch (LogConfigurationException e)
+        {
+            //just catching this to be safe.
+        }
     }
 
     public static Object invoke(Method target, Object value, Object[] args) throws IllegalAccessException, InvocationTargetException {



-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org