tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r652542 - in /incubator/tuscany/java/sca: modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/ vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annota...
Date Thu, 01 May 2008 14:51:22 GMT
Author: slaws
Date: Thu May  1 07:51:22 2008
New Revision: 652542

URL: http://svn.apache.org/viewvc?rev=652542&view=rev
Log:
TUSCANY-2271 - Thanks for the patch Vamsi

Modified:
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
    incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java
    incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java
    incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java
    incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/resources/property.composite
    incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java?rev=652542&r1=652541&r2=652542&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
Thu May  1 07:51:22 2008
@@ -112,7 +112,16 @@
 
         if (element != null && configuredProperty.getValue() != null) {
             if (!(element.getAnchor() instanceof Constructor)) {
-                instanceFactoryProvider.getInjectionSites().add(element);
+                if(element.getElementType() == ElementType.FIELD) {
+                    Field field = (Field)element.getAnchor();
+                    if(Modifier.isPublic(field.getModifiers())) {
+                        instanceFactoryProvider.getInjectionSites().add(element);
+                    } else if(field.getAnnotation(org.osoa.sca.annotations.Property.class)
!= null) {
+                        instanceFactoryProvider.getInjectionSites().add(element);
+                    }
+                } else {
+                    instanceFactoryProvider.getInjectionSites().add(element);
+                }
             }
 
             //Class propertyJavaType = JavaIntrospectionHelper.getBaseType(element.getType(),
element.getGenericType());

Modified: incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java?rev=652542&r1=652541&r2=652542&view=diff
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java
(original)
+++ incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/AService.java
Thu May  1 07:51:22 2008
@@ -85,4 +85,5 @@
 
 	public int getP21Size();
 	
+	public String getP22();
 }

Modified: incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java?rev=652542&r1=652541&r2=652542&view=diff
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java
(original)
+++ incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AServiceImpl.java
Thu May  1 07:51:22 2008
@@ -79,6 +79,8 @@
 
 	@Property(required=false)
 	public Integer[] p21;			// an array and injected via field
+	
+	protected String p22;           // unannotated protected field should not be injected
 
     public String getName() {
         return "AService";
@@ -257,5 +259,9 @@
 		return p21.length;
 	}
 
+	public String getP22() {
+	    return p22;
+	}
 }
 
+

Modified: incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java?rev=652542&r1=652541&r2=652542&view=diff
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java
(original)
+++ incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/impl/AnotherAServiceImpl.java
Thu May  1 07:51:22 2008
@@ -31,6 +31,8 @@
     
     public boolean p14SetterIsCalled = false;
     
+    protected String p22;           // unannotated protected field should not be injected
+
     public String getName() {
         return "AService";
     }
@@ -163,4 +165,8 @@
     public int getP21Size() {
         return -1;
     }
+
+    public String getP22() {
+        return p22;
+    }
 }

Modified: incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/resources/property.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/resources/property.composite?rev=652542&r1=652541&r2=652542&view=diff
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/resources/property.composite
(original)
+++ incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/main/resources/property.composite
Thu May  1 07:51:22 2008
@@ -137,5 +137,6 @@
             class="org.apache.tuscany.sca.vtest.javaapi.annotations.property.impl.AnotherAServiceImpl"
/>
             <property name="p13">p13</property>
             <property name="p14">p14</property>
+            <property name="p22">p22</property>
     </component>
 </composite>

Modified: incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java?rev=652542&r1=652541&r2=652542&view=diff
==============================================================================
--- incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java
(original)
+++ incubator/tuscany/java/sca/vtest/java-api/annotations/property/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/property/PropertyAnnotationTestCase.java
Thu May  1 07:51:22 2008
@@ -253,4 +253,20 @@
 
     }
 
+    /**
+     * Lines 1349 to 1352:<br>
+     * 1.8.13. "@Property"<br>
+     * ...<br>
+     * Properties may also be injected via public setter methods even when the "@Property"
annotation is not
+     * present. However, the "@Property" annotation must be used in order to inject a property
onto a non-public
+     * field. In the case where there is no "@Property" annotation, the name of the property
is the same as the
+     * name of the field or setter.
+     * <p>
+     * p22 - unannotated protected field which should not be injected
+     */
+    @Test
+    public void atProperty7() throws Exception {
+        AService anotherAService = domain.getService(AService.class, "AnotherAComponent");
+        Assert.assertNull(anotherAService.getP22());
+    }
 }



Mime
View raw message