activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1035697 - /activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala
Date Tue, 16 Nov 2010 17:08:16 GMT
Author: chirino
Date: Tue Nov 16 17:08:16 2010
New Revision: 1035697

URL: http://svn.apache.org/viewvc?rev=1035697&view=rev
Log:
Support loading scala objects as the factory provider impl.

Modified:
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala?rev=1035697&r1=1035696&r2=1035697&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala
Tue Nov 16 17:08:16 2010
@@ -64,7 +64,16 @@ class ClassFinder[T](val path:String, va
       try {
         t += clazz.newInstance.asInstanceOf[T]
       } catch {
-        case e: Throwable => e.printStackTrace
+        case e: Throwable =>
+          // It may be a scala object.. check for a module class
+          try {
+            val moduleField = clazz.getClassLoader.loadClass(clazz.getName + "$").getDeclaredField("MODULE$")
+            val instance = moduleField.get(null).asInstanceOf[T]
+            t += instance
+          } catch {
+            case e2: Throwable =>
+              e.printStackTrace
+          }
       }
     }
     t.toList



Mime
View raw message