Return-Path: X-Original-To: apmail-deltaspike-commits-archive@www.apache.org Delivered-To: apmail-deltaspike-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C5B851960A for ; Mon, 21 Mar 2016 22:10:28 +0000 (UTC) Received: (qmail 41939 invoked by uid 500); 21 Mar 2016 22:10:28 -0000 Delivered-To: apmail-deltaspike-commits-archive@deltaspike.apache.org Received: (qmail 41881 invoked by uid 500); 21 Mar 2016 22:10:28 -0000 Mailing-List: contact commits-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltaspike.apache.org Delivered-To: mailing list commits@deltaspike.apache.org Received: (qmail 41872 invoked by uid 99); 21 Mar 2016 22:10:28 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Mar 2016 22:10:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4DC24DFA43; Mon, 21 Mar 2016 22:10:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tandraschko@apache.org To: commits@deltaspike.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: deltaspike git commit: DELTASPIKE-1069 evaluate interceptors for producer-methods Date: Mon, 21 Mar 2016 22:10:28 +0000 (UTC) Repository: deltaspike Updated Branches: refs/heads/master 495aa0bf4 -> dfe5676a9 DELTASPIKE-1069 evaluate interceptors for producer-methods Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/dfe5676a Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/dfe5676a Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/dfe5676a Branch: refs/heads/master Commit: dfe5676a9237784067ceaf8da7b361ac2af75d83 Parents: 495aa0b Author: Thomas Andraschko Authored: Mon Mar 21 23:09:56 2016 +0100 Committer: Thomas Andraschko Committed: Mon Mar 21 23:10:18 2016 +0100 ---------------------------------------------------------------------- .../proxy/api/DeltaSpikeProxyFactory.java | 6 ++ .../proxy/api/EnableBeanInterceptors.java | 37 ++++++++++ .../proxy/spi/DummyInvocationHandler.java | 31 +++++++++ .../spi/EnableBeanInterceptorsInterceptor.java | 52 ++++++++++++++ .../spi/EnableBeanInterceptorsProxyFactory.java | 45 ++++++++++++ .../api/src/main/resources/META-INF/beans.xml | 3 + deltaspike/modules/proxy/impl-asm5/pom.xml | 6 ++ .../EnableBeanInterceptorsTest.java | 73 ++++++++++++++++++++ ...eanInterceptors_WithoutInterceptor_Test.java | 66 ++++++++++++++++++ .../impl/enablebeaninterceptors/MyBean.java | 55 +++++++++++++++ .../MyBeanInterceptor.java | 37 ++++++++++ .../MyBeanInterceptorBinding.java | 37 ++++++++++ .../enablebeaninterceptors/MyBeanProducer.java | 32 +++++++++ .../test/proxy/impl/util/ArchiveUtils.java | 49 +++++++++++++ 14 files changed, 529 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyFactory.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyFactory.java b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyFactory.java index ddd9d00..fc2cc2d 100644 --- a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyFactory.java +++ b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/DeltaSpikeProxyFactory.java @@ -32,6 +32,7 @@ import javax.interceptor.InterceptorBinding; import org.apache.deltaspike.core.util.ClassUtils; import org.apache.deltaspike.core.util.ServiceUtils; +import org.apache.deltaspike.proxy.spi.DummyInvocationHandler; import org.apache.deltaspike.proxy.spi.ProxyClassGenerator; public abstract class DeltaSpikeProxyFactory @@ -100,6 +101,11 @@ public abstract class DeltaSpikeProxyFactory return proxyClass; } + + public Class getProxyClass(BeanManager beanManager, Class targetClass) + { + return getProxyClass(beanManager, targetClass, DummyInvocationHandler.class); + } private synchronized Class createProxyClass(BeanManager beanManager, ClassLoader classLoader, Class targetClass, Class delegateInvocationHandlerClass) http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/EnableBeanInterceptors.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/EnableBeanInterceptors.java b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/EnableBeanInterceptors.java new file mode 100644 index 0000000..94122d0 --- /dev/null +++ b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/api/EnableBeanInterceptors.java @@ -0,0 +1,37 @@ +/* + * 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.proxy.api; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.interceptor.InterceptorBinding; + +@InterceptorBinding +@Documented +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE, ElementType.METHOD }) +public @interface EnableBeanInterceptors +{ + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/DummyInvocationHandler.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/DummyInvocationHandler.java b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/DummyInvocationHandler.java new file mode 100644 index 0000000..a8c9b53 --- /dev/null +++ b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/DummyInvocationHandler.java @@ -0,0 +1,31 @@ +/* + * 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.proxy.spi; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; + +public class DummyInvocationHandler implements InvocationHandler +{ + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable + { + return null; + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/EnableBeanInterceptorsInterceptor.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/EnableBeanInterceptorsInterceptor.java b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/EnableBeanInterceptorsInterceptor.java new file mode 100644 index 0000000..28c9285 --- /dev/null +++ b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/EnableBeanInterceptorsInterceptor.java @@ -0,0 +1,52 @@ +/* + * 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.proxy.spi; + +import java.io.Serializable; +import javax.enterprise.inject.spi.BeanManager; +import javax.inject.Inject; +import javax.interceptor.AroundInvoke; +import javax.interceptor.Interceptor; +import javax.interceptor.InvocationContext; +import org.apache.deltaspike.proxy.api.EnableBeanInterceptors; + +@Interceptor +@EnableBeanInterceptors +public class EnableBeanInterceptorsInterceptor implements Serializable +{ + @Inject + private BeanManager beanManager; + + @AroundInvoke + public Object wrapBeanCandidate(InvocationContext invocationContext) throws Exception + { + Object beanCandidate = invocationContext.proceed(); + + if (beanCandidate == null) + { + throw new IllegalStateException("Can not apply " + + EnableBeanInterceptors.class.getSimpleName() + + " on a null instance!"); + } + + Class proxy = EnableBeanInterceptorsProxyFactory.getInstance().getProxyClass(beanManager, + beanCandidate.getClass()); + return proxy.newInstance(); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/EnableBeanInterceptorsProxyFactory.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/EnableBeanInterceptorsProxyFactory.java b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/EnableBeanInterceptorsProxyFactory.java new file mode 100644 index 0000000..d3a68aa --- /dev/null +++ b/deltaspike/modules/proxy/api/src/main/java/org/apache/deltaspike/proxy/spi/EnableBeanInterceptorsProxyFactory.java @@ -0,0 +1,45 @@ +/* + * 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.proxy.spi; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import org.apache.deltaspike.proxy.api.DeltaSpikeProxyFactory; + +public class EnableBeanInterceptorsProxyFactory extends DeltaSpikeProxyFactory +{ + private static final EnableBeanInterceptorsProxyFactory INSTANCE = new EnableBeanInterceptorsProxyFactory(); + + public static EnableBeanInterceptorsProxyFactory getInstance() + { + return INSTANCE; + } + + @Override + protected ArrayList getDelegateMethods(Class targetClass, ArrayList allMethods) + { + return null; + } + + @Override + protected String getProxyClassSuffix() + { + return "$$DSBeanInterceptorProxy"; + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/api/src/main/resources/META-INF/beans.xml ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/api/src/main/resources/META-INF/beans.xml b/deltaspike/modules/proxy/api/src/main/resources/META-INF/beans.xml index a2308ff..2eecf4c 100644 --- a/deltaspike/modules/proxy/api/src/main/resources/META-INF/beans.xml +++ b/deltaspike/modules/proxy/api/src/main/resources/META-INF/beans.xml @@ -20,4 +20,7 @@ + + org.apache.deltaspike.proxy.spi.EnableBeanInterceptorsInterceptor + http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/impl-asm5/pom.xml ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/impl-asm5/pom.xml b/deltaspike/modules/proxy/impl-asm5/pom.xml index b566601..0c79ad1 100644 --- a/deltaspike/modules/proxy/impl-asm5/pom.xml +++ b/deltaspike/modules/proxy/impl-asm5/pom.xml @@ -116,6 +116,12 @@ 5.0.3 true + + + org.apache.deltaspike.core + deltaspike-core-impl + test + http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/EnableBeanInterceptorsTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/EnableBeanInterceptorsTest.java b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/EnableBeanInterceptorsTest.java new file mode 100644 index 0000000..553c869 --- /dev/null +++ b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/EnableBeanInterceptorsTest.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.proxy.impl.enablebeaninterceptors; + +import javax.inject.Inject; +import org.apache.deltaspike.test.proxy.impl.util.ArchiveUtils; +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.Asset; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class EnableBeanInterceptorsTest +{ + @Deployment + public static WebArchive war() + { + Asset beansXml = new StringAsset( + "" + + MyBeanInterceptor.class.getName() + + "" + ); + + String simpleName = EnableBeanInterceptorsTest.class.getSimpleName(); + String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); + + JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar") + .addPackage(EnableBeanInterceptorsTest.class.getPackage()) + .addAsManifestResource(beansXml, "beans.xml"); + + return ShrinkWrap.create(WebArchive.class, archiveName + ".war") + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndProxyArchive()) + .addAsLibraries(testJar) + .addAsWebInfResource(beansXml, "beans.xml"); + } + + @Inject + private MyBean myBean; + + @Test + public void testPartialBeanWithApplicationScope() throws Exception + { + Assert.assertFalse(myBean.isIntercepted()); + Assert.assertFalse(myBean.isMethodCalled()); + + myBean.somethingIntercepted(); + + Assert.assertTrue(myBean.isIntercepted()); + Assert.assertTrue(myBean.isMethodCalled()); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/EnableBeanInterceptors_WithoutInterceptor_Test.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/EnableBeanInterceptors_WithoutInterceptor_Test.java b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/EnableBeanInterceptors_WithoutInterceptor_Test.java new file mode 100644 index 0000000..42ea1f5 --- /dev/null +++ b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/EnableBeanInterceptors_WithoutInterceptor_Test.java @@ -0,0 +1,66 @@ +/* + * 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.proxy.impl.enablebeaninterceptors; + +import javax.inject.Inject; +import org.apache.deltaspike.test.proxy.impl.util.ArchiveUtils; +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.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class EnableBeanInterceptors_WithoutInterceptor_Test +{ + @Deployment + public static WebArchive war() + { + String simpleName = EnableBeanInterceptors_WithoutInterceptor_Test.class.getSimpleName(); + String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); + + JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar") + .addPackage(EnableBeanInterceptors_WithoutInterceptor_Test.class.getPackage()) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + + return ShrinkWrap.create(WebArchive.class, archiveName + ".war") + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndProxyArchive()) + .addAsLibraries(testJar) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Inject + private MyBean myBean; + + @Test + public void testPartialBeanWithApplicationScope() throws Exception + { + Assert.assertFalse(myBean.isIntercepted()); + Assert.assertFalse(myBean.isMethodCalled()); + + myBean.somethingIntercepted(); + + Assert.assertFalse(myBean.isIntercepted()); + Assert.assertTrue(myBean.isMethodCalled()); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBean.java b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBean.java new file mode 100644 index 0000000..65969a4 --- /dev/null +++ b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBean.java @@ -0,0 +1,55 @@ +/* + * 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.proxy.impl.enablebeaninterceptors; + +import org.apache.deltaspike.core.api.exclude.Exclude; + +@Exclude +public class MyBean +{ + private boolean intercepted; + private boolean methodCalled; + + public boolean isIntercepted() + { + return intercepted; + } + + public void setIntercepted(boolean intercepted) + { + this.intercepted = intercepted; + } + + public boolean isMethodCalled() + { + return methodCalled; + } + + public void setMethodCalled(boolean methodCalled) + { + this.methodCalled = methodCalled; + } + + + @MyBeanInterceptorBinding + public void somethingIntercepted() + { + methodCalled = true; + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanInterceptor.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanInterceptor.java b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanInterceptor.java new file mode 100644 index 0000000..74fe9d9 --- /dev/null +++ b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanInterceptor.java @@ -0,0 +1,37 @@ +/* + * 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.proxy.impl.enablebeaninterceptors; + +import java.io.Serializable; +import javax.interceptor.AroundInvoke; +import javax.interceptor.Interceptor; +import javax.interceptor.InvocationContext; + +@Interceptor +@MyBeanInterceptorBinding +public class MyBeanInterceptor implements Serializable +{ + @AroundInvoke + public Object wrapBeanCandidate(InvocationContext invocationContext) throws Exception + { + ((MyBean) invocationContext.getTarget()).setIntercepted(true); + + return invocationContext.proceed(); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanInterceptorBinding.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanInterceptorBinding.java b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanInterceptorBinding.java new file mode 100644 index 0000000..5e54ea1 --- /dev/null +++ b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanInterceptorBinding.java @@ -0,0 +1,37 @@ +/* + * 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.proxy.impl.enablebeaninterceptors; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.interceptor.InterceptorBinding; + +@InterceptorBinding +@Documented +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE, ElementType.METHOD }) +public @interface MyBeanInterceptorBinding +{ + +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanProducer.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanProducer.java b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanProducer.java new file mode 100644 index 0000000..1903a7a --- /dev/null +++ b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/proxy/impl/enablebeaninterceptors/MyBeanProducer.java @@ -0,0 +1,32 @@ +/* + * 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.proxy.impl.enablebeaninterceptors; + +import javax.enterprise.inject.Produces; +import org.apache.deltaspike.proxy.api.EnableBeanInterceptors; + +public class MyBeanProducer +{ + @Produces + @EnableBeanInterceptors + public MyBean produce() + { + return new MyBean(); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/dfe5676a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/test/proxy/impl/util/ArchiveUtils.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/test/proxy/impl/util/ArchiveUtils.java b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/test/proxy/impl/util/ArchiveUtils.java new file mode 100644 index 0000000..bba08f5 --- /dev/null +++ b/deltaspike/modules/proxy/impl-asm5/src/test/java/org/apache/deltaspike/test/proxy/impl/util/ArchiveUtils.java @@ -0,0 +1,49 @@ +/* + * 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.proxy.impl.util; + +import java.util.ArrayList; +import java.util.Arrays; +import org.apache.deltaspike.test.utils.ShrinkWrapArchiveUtil; +import org.jboss.shrinkwrap.api.spec.JavaArchive; + +public abstract class ArchiveUtils +{ + private ArchiveUtils() + { + } + + public static JavaArchive[] getDeltaSpikeCoreAndProxyArchive() + { + ArrayList result = new ArrayList(); + + JavaArchive[] temp; + + temp = ShrinkWrapArchiveUtil.getArchives(null, + "META-INF/beans.xml", + new String[] { "org.apache.deltaspike.core", + "org.apache.deltaspike.proxy", + "org.apache.deltaspike.test.category" }, + new String[] { "META-INF.apache-deltaspike.properties" }, + "ds-core_and_proxy"); + result.addAll(Arrays.asList(temp)); + + return result.toArray(new JavaArchive[result.size()]); + } +}