Repository: deltaspike Updated Branches: refs/heads/master d2a015ced -> 1a706f35d
DELTASPIKE-823 fixed use case Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/1a706f35 Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/1a706f35 Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/1a706f35 Branch: refs/heads/master Commit: 1a706f35d07cceaf6e6d43d8d51ccefb16d435ae Parents: d2a015c Author: Thomas Andraschko <[email protected]> Authored: Fri Feb 13 22:03:43 2015 +0100 Committer: Thomas Andraschko <[email protected]> Committed: Fri Feb 13 22:03:43 2015 +0100 ---------------------------------------------------------------------- .../impl/ASMProxyClassGenerator.java | 2 +- .../impl/PartialBeanProxyFactory.java | 23 ++++++ .../core/api/partialbean/uc008/PartialBean.java | 11 +++ .../api/partialbean/uc008/PartialBeanTest.java | 73 ++++++++++++++++++++ .../api/partialbean/uc008/SuperInterface.java | 24 +++++++ .../api/partialbean/uc008/SuperInterface2.java | 24 +++++++ 6 files changed, 156 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1a706f35/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/ASMProxyClassGenerator.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/ASMProxyClassGenerator.java b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/ASMProxyClassGenerator.java index f8292dd..25b8a88 100644 --- a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/ASMProxyClassGenerator.java +++ b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/ASMProxyClassGenerator.java @@ -195,7 +195,7 @@ public abstract class ASMProxyClassGenerator Label tryBlockStart = exceptionTypes.length > 0 ? mg.mark() : null; - mg.push(Type.getType(method.getDeclaringClass())); + mg.push(proxyType); // the following code generates the bytecode for this line of Java: // Method method = <proxy>.class.getMethod("add", new Class[] { <array of function argument classes> }); http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1a706f35/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java index 34d6a2c..ac5e964 100644 --- a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java +++ b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java @@ -172,7 +172,30 @@ public abstract class PartialBeanProxyFactory currentClass = currentClass.getSuperclass(); } + + // sort out method with same signature (see uc008) + ArrayList<Method> duplicates = new ArrayList<Method>(); + for (Method outer : methods) + { + for (Method inner : methods) + { + if (inner != outer + && hasSameSignature(outer, inner) + && !(duplicates.contains(outer) || duplicates.contains(inner))) + { + duplicates.add(inner); + } + } + } + methods.removeAll(duplicates); return methods.toArray(new Method[methods.size()]); } + + private static boolean hasSameSignature(Method a, Method b) + { + return a.getName().equals(b.getName()) + && a.getReturnType().equals(b.getReturnType()) + && Arrays.equals(a.getParameterTypes(), b.getParameterTypes()); + } } http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1a706f35/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBean.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBean.java new file mode 100644 index 0000000..2f21899 --- /dev/null +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBean.java @@ -0,0 +1,11 @@ +package org.apache.deltaspike.test.core.api.partialbean.uc008; + +import javax.enterprise.context.ApplicationScoped; +import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; + +@TestPartialBeanBinding +@ApplicationScoped +public interface PartialBean extends SuperInterface<Object>, SuperInterface2<Object> +{ + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1a706f35/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBeanTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBeanTest.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBeanTest.java new file mode 100644 index 0000000..d96791f --- /dev/null +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/PartialBeanTest.java @@ -0,0 +1,73 @@ +/* + * 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.deltaspike.test.core.api.partialbean.uc008; + +import org.apache.deltaspike.core.api.provider.BeanProvider; +import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; +import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils; +import org.apache.deltaspike.test.utils.CdiContainerUnderTest; +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assume; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class PartialBeanTest +{ + private static final String CONTAINER_OWB_1_2_x_BEFORE_1_2_8 = "owb-1\\.2\\.[0-7]"; + + @Deployment + public static WebArchive war() + { + if (CdiContainerUnderTest.is(CONTAINER_OWB_1_2_x_BEFORE_1_2_8)) + { + return ShrinkWrap.create(WebArchive.class, "empty.war"); + } + + String simpleName = PartialBeanTest.class.getSimpleName(); + String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); + + JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar") + .addPackage(PartialBeanTest.class.getPackage()) + .addPackage(TestPartialBeanBinding.class.getPackage()) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + + WebArchive webArchive = ShrinkWrap.create(WebArchive.class, archiveName + ".war") + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive()) + .addAsLibraries(testJar) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + + return webArchive; + } + + @Test + public void testPartialBeanWithApplicationScope() throws Exception + { + // this test is known to not work under OWB 1.2.0 till 1.2.7 - see OWB #1036 + Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_OWB_1_2_x_BEFORE_1_2_8)); + + PartialBean bean = BeanProvider.getContextualReference(PartialBean.class); + bean.test(this); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1a706f35/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface.java new file mode 100644 index 0000000..5cd1c08 --- /dev/null +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface.java @@ -0,0 +1,24 @@ +/* + * 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.deltaspike.test.core.api.partialbean.uc008; + +public interface SuperInterface<E> +{ + E test(E entity); +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1a706f35/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface2.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface2.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface2.java new file mode 100644 index 0000000..1f607a7 --- /dev/null +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/SuperInterface2.java @@ -0,0 +1,24 @@ +/* + * 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.deltaspike.test.core.api.partialbean.uc008; + +public interface SuperInterface2<E> +{ + E test(E entity); +}
