You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by gn...@apache.org on 2018/01/30 22:36:38 UTC

svn commit: r1822713 - in /aries/trunk/blueprint/blueprint-core/src: main/java/org/apache/aries/blueprint/container/ test/java/org/apache/aries/blueprint/ test/java/org/apache/aries/blueprint/pojos/ test/resources/

Author: gnodet
Date: Tue Jan 30 22:36:38 2018
New Revision: 1822713

URL: http://svn.apache.org/viewvc?rev=1822713&view=rev
Log:
[ARIES-1544] Blueprint property resolution fails for setters with derived type

Added:
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/OverloadTest.java
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Overload.java
    aries/trunk/blueprint/blueprint-core/src/test/resources/test-overload.xml
Modified:
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java?rev=1822713&r1=1822712&r2=1822713&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java Tue Jan 30 22:36:38 2018
@@ -812,7 +812,10 @@ public class BeanRecipe extends Abstract
         final PropertyDescriptor pd = getPropertyDescriptor(clazz, names[names.length - 1]);
         if (pd.allowsSet()) {
             try {
-                pd.set(instance, propertyValue, blueprintContainer);
+                Object val = propertyValue instanceof UnwrapperedBeanHolder
+                        ? ((UnwrapperedBeanHolder) propertyValue).unwrapperedBean
+                        : propertyValue;
+                pd.set(instance, val, blueprintContainer);
             } catch (Exception e) {
                 throw new ComponentDefinitionException("Error setting property: " + pd, getRealCause(e));
             }

Added: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/OverloadTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/OverloadTest.java?rev=1822713&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/OverloadTest.java (added)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/OverloadTest.java Tue Jan 30 22:36:38 2018
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint;
+
+import org.apache.aries.blueprint.di.Repository;
+import org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl;
+import org.junit.Test;
+
+public class OverloadTest extends AbstractBlueprintTest {
+
+    @Test
+    public void testOverload() throws Exception {
+        ComponentDefinitionRegistryImpl registry = parse("/test-overload.xml");
+        Repository repository = new TestBlueprintContainer(registry).getRepository();
+        repository.create("b");
+    }
+}

Added: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Overload.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Overload.java?rev=1822713&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Overload.java (added)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Overload.java Tue Jan 30 22:36:38 2018
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.pojos;
+
+public class Overload {
+
+    public static class X {
+    }
+
+    public static class Y extends X {
+    }
+
+    public static class A {
+        private X x;
+        public X getX() { return x; }
+        public void setX(X x) { this.x = x; }
+    }
+
+    public static class B extends A {
+        public void setX(Y y) { super.setX(y); } // Y extends X
+    }
+
+}

Added: aries/trunk/blueprint/blueprint-core/src/test/resources/test-overload.xml
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/resources/test-overload.xml?rev=1822713&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/resources/test-overload.xml (added)
+++ aries/trunk/blueprint/blueprint-core/src/test/resources/test-overload.xml Tue Jan 30 22:36:38 2018
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            default-availability="mandatory" >
+
+    <bean id="b" class="org.apache.aries.blueprint.pojos.Overload.B">
+        <property name="x">
+            <bean class="org.apache.aries.blueprint.pojos.Overload.Y"/>
+        </property>
+    </bean>
+    
+
+</blueprint>