Author: dblevins
Date: Wed Jun 16 01:16:29 2010
New Revision: 955104

URL: http://svn.apache.org/viewvc?rev=955104&view=rev
Log:
OPENEJB-1300: Windows-only issue possibly results in 
"java.lang.ClassCastException: org.apache.xbean.recipe.ObjectRecipe cannot be 
cast to ...."

Modified:
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/PassthroughFactory.java

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/PassthroughFactory.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/PassthroughFactory.java?rev=955104&r1=955103&r2=955104&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/PassthroughFactory.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/PassthroughFactory.java
 Wed Jun 16 01:16:29 2010
@@ -24,12 +24,24 @@ import org.apache.openejb.InjectionProce
 */
 public class PassthroughFactory {
 
-    public static Object create(Object instance) {
-        return instance;
+    /**
+     * xbean-reflect seems to sometimes get confused.
+     * Despite explicitly setting the 'static Object create(Object)'
+     * method as the factory method, sometimes xbean instead would
+     * invoke the 'static ObjectRecipe recipe(Object)' method.
+     *
+     * Splitting the two methods into different classes seems to
+     * eliminate the chances that xbean-reflect will pick the wrong
+     * static method.
+     */
+    public static class Create {
+        public static Object create(Object instance) {
+            return instance;
+        }
     }
 
     public static ObjectRecipe recipe(Object instance) {
-        ObjectRecipe recipe = new ObjectRecipe(PassthroughFactory.class);
+        ObjectRecipe recipe = new 
ObjectRecipe(PassthroughFactory.Create.class);
         recipe.setFactoryMethod("create");
 
         String param = "instance"+recipe.hashCode();


Reply via email to