tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmar...@apache.org
Subject svn commit: r399918 - in /incubator/tuscany/java/sca/containers/container.java/src: main/java/org/apache/tuscany/container/java/config/JavaContextFactory.java test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java
Date Fri, 05 May 2006 02:36:02 GMT
Author: jmarino
Date: Thu May  4 19:36:01 2006
New Revision: 399918

URL: http://svn.apache.org/viewcvs?rev=399918&view=rev
Log:
fix for TUSCANY-300

Modified:
    incubator/tuscany/java/sca/containers/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaContextFactory.java
    incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java

Modified: incubator/tuscany/java/sca/containers/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/containers/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaContextFactory.java?rev=399918&r1=399917&r2=399918&view=diff
==============================================================================
--- incubator/tuscany/java/sca/containers/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaContextFactory.java
(original)
+++ incubator/tuscany/java/sca/containers/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaContextFactory.java
Thu May  4 19:36:01 2006
@@ -13,6 +13,15 @@
  */
 package org.apache.tuscany.container.java.config;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import commonj.sdo.DataObject;
 import org.apache.tuscany.container.java.context.JavaAtomicContext;
 import org.apache.tuscany.core.builder.BuilderConfigException;
@@ -35,17 +44,9 @@
 import org.apache.tuscany.core.injection.SingletonObjectFactory;
 import org.apache.tuscany.core.wire.SourceWireFactory;
 import org.apache.tuscany.core.wire.TargetWireFactory;
-import org.apache.tuscany.model.assembly.Scope;
 import org.apache.tuscany.databinding.sdo.SDOObjectFactory;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import org.apache.tuscany.model.assembly.Scope;
+import org.osoa.sca.annotations.Reference;
 
 /**
  * A ContextFactory that handles POJO component implementation types
@@ -209,8 +210,8 @@
     }
 
     /**
-     * Creates proxy factories that represent target(s) of a reference and an <code>Injector</code>
responsible for injecting them
-     * into the reference
+     * Creates proxy factories that represent target(s) of a reference and an <code>Injector</code>
+     * responsible for injecting them into the reference
      */
     private Injector createReferenceInjector(String refName, List<SourceWireFactory>
wireFactories, boolean multiplicity) {
         assert wireFactories.size() > 0;
@@ -271,9 +272,33 @@
         } else {
             field = JavaIntrospectionHelper.findClosestMatchingField(refName, refClass, fields);
             if (field == null) {
-                method = JavaIntrospectionHelper.findClosestMatchingMethod(refName, new Class[]{refClass},
methods);
-                if (method == null) {
-                    throw new NoAccessorException(refName);
+                // hack for TUSCANY-300
+                for (Field current : fields) {
+                    Reference annot = current.getAnnotation(Reference.class);
+                    if (annot != null) {
+                        if (refName.equals(annot.name())) {
+                            field = current;
+                            break;
+                        }
+                    }
+                }
+                if (field == null) {
+                    method = JavaIntrospectionHelper.findClosestMatchingMethod(refName, new
Class[]{refClass}, methods);
+                    if (method == null) {
+                        // hack for TUSCANY-300
+                        for (Method current : methods) {
+                            Reference annot = current.getAnnotation(Reference.class);
+                            if (annot != null) {
+                                if (refName.equals(annot.name())) {
+                                    method = current;
+                                    break;
+                                }
+                            }
+                        }
+                        if (method == null) {
+                            throw new NoAccessorException(refName);
+                        }
+                    }
                 }
             }
             Injector injector;

Modified: incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java?rev=399918&r1=399917&r2=399918&view=diff
==============================================================================
--- incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java
(original)
+++ incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java
Thu May  4 19:36:01 2006
@@ -29,11 +29,11 @@
     @Property
     public String locale;
 
-    @Reference
-    public GreetingProvider greetingProvider;
+    @Reference(name="greetingProvider")
+    public GreetingProvider greetingProvider2;
 
     public String getGreetings(String name) {
-        return greetingProvider.getGreeting(name, locale);
+        return greetingProvider2.getGreeting(name, locale);
     }
 
 }



Mime
View raw message