[jboss-cvs] JBossAS SVN: r73210 - in projects/ejb3/trunk/interceptors/src/test: java/org/jboss/ejb3/test/interceptors/exclude and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 9 11:22:43 EDT 2008
Author: kabir.khan at jboss.com
Date: 2008-05-09 11:22:43 -0400 (Fri, 09 May 2008)
New Revision: 73210
Added:
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedAllInterceptorsBean.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassAndDefaultBean.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassAndDefaultForMethodBean.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassBean.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeDefaultBean.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeDefaultForMethodBean.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/ClassInterceptor.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/DefaultInterceptor.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/Interceptions.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/MethodInterceptor.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/MyInterface.java
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/unit/
projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/unit/ExcludeInterceptorsTestCase.java
projects/ejb3/trunk/interceptors/src/test/resources/exclude/
projects/ejb3/trunk/interceptors/src/test/resources/exclude/META-INF/
projects/ejb3/trunk/interceptors/src/test/resources/exclude/META-INF/ejb-jar.xml
Log:
[EJBTHREE-1347] Test exclusion of class and default interceptors via annotations
A test/java/org/jboss/ejb3/test/interceptors/exclude
A test/java/org/jboss/ejb3/test/interceptors/exclude/MethodInterceptor.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/unit
A test/java/org/jboss/ejb3/test/interceptors/exclude/unit/ExcludeInterceptorsTestCase.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeDefaultBean.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassAndDefaultForMethodBean.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassBean.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/DefaultInterceptor.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/ClassInterceptor.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/Interceptions.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/MyInterface.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeDefaultForMethodBean.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassAndDefaultBean.java
A test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedAllInterceptorsBean.java
A test/resources/exclude
A test/resources/exclude/META-INF
A test/resources/exclude/META-INF/ejb-jar.xml
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedAllInterceptorsBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedAllInterceptorsBean.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedAllInterceptorsBean.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Interceptors(ClassInterceptor.class)
+public class AnnotatedAllInterceptorsBean implements MyInterface
+{
+ @Interceptors(MethodInterceptor.class)
+ public String method()
+ {
+ return AnnotatedAllInterceptorsBean.class.getName();
+ }
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ Interceptions.add(this);
+ return ctx.proceed();
+ }
+
+ @PostConstruct
+ @PreDestroy
+ public void lifecycle()
+ {
+ Interceptions.add(this);
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassAndDefaultBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassAndDefaultBean.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassAndDefaultBean.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Interceptors(ClassInterceptor.class)
+ at ExcludeDefaultInterceptors
+public class AnnotatedExcludeClassAndDefaultBean implements MyInterface
+{
+ @Interceptors(MethodInterceptor.class)
+ @ExcludeClassInterceptors
+ public String method()
+ {
+ return AnnotatedExcludeClassAndDefaultBean.class.getName();
+ }
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ Interceptions.add(this);
+ return ctx.proceed();
+ }
+
+ @PostConstruct
+ @PreDestroy
+ public void lifecycle()
+ {
+ Interceptions.add(this);
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassAndDefaultForMethodBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassAndDefaultForMethodBean.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassAndDefaultForMethodBean.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Interceptors(ClassInterceptor.class)
+public class AnnotatedExcludeClassAndDefaultForMethodBean implements MyInterface
+{
+ @Interceptors(MethodInterceptor.class)
+ @ExcludeDefaultInterceptors
+ @ExcludeClassInterceptors
+ public String method()
+ {
+ return AnnotatedExcludeClassAndDefaultForMethodBean.class.getName();
+ }
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ Interceptions.add(this);
+ return ctx.proceed();
+ }
+
+ @PostConstruct
+ @PreDestroy
+ public void lifecycle()
+ {
+ Interceptions.add(this);
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassBean.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeClassBean.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Interceptors(ClassInterceptor.class)
+public class AnnotatedExcludeClassBean implements MyInterface
+{
+ @Interceptors(MethodInterceptor.class)
+ @ExcludeClassInterceptors
+ public String method()
+ {
+ return AnnotatedExcludeClassBean.class.getName();
+ }
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ Interceptions.add(this);
+ return ctx.proceed();
+ }
+
+ @PostConstruct
+ @PreDestroy
+ public void lifecycle()
+ {
+ Interceptions.add(this);
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeDefaultBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeDefaultBean.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeDefaultBean.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Interceptors(ClassInterceptor.class)
+ at ExcludeDefaultInterceptors
+public class AnnotatedExcludeDefaultBean implements MyInterface
+{
+ @Interceptors(MethodInterceptor.class)
+ public String method()
+ {
+ return AnnotatedExcludeDefaultBean.class.getName();
+ }
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ Interceptions.add(this);
+ return ctx.proceed();
+ }
+
+ @PostConstruct
+ @PreDestroy
+ public void lifecycle()
+ {
+ Interceptions.add(this);
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeDefaultForMethodBean.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeDefaultForMethodBean.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/AnnotatedExcludeDefaultForMethodBean.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Interceptors(ClassInterceptor.class)
+public class AnnotatedExcludeDefaultForMethodBean implements MyInterface
+{
+ @Interceptors(MethodInterceptor.class)
+ @ExcludeDefaultInterceptors
+ public String method()
+ {
+ return AnnotatedExcludeDefaultForMethodBean.class.getName();
+ }
+
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ Interceptions.add(this);
+ return ctx.proceed();
+ }
+
+ @PostConstruct
+ @PreDestroy
+ public void lifecycle()
+ {
+ Interceptions.add(this);
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/ClassInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/ClassInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/ClassInterceptor.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInterceptor
+{
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ Interceptions.add(this);
+ return ctx.proceed();
+ }
+
+ @PostConstruct
+ @PreDestroy
+ public void lifecycle(InvocationContext ctx)
+ {
+ try
+ {
+ Interceptions.add(this);
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ // AutoGenerated
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/DefaultInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/DefaultInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/DefaultInterceptor.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultInterceptor
+{
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ Interceptions.add(this);
+ return ctx.proceed();
+ }
+
+ @PostConstruct
+ @PreDestroy
+ public void postConstruct(InvocationContext ctx)
+ {
+ try
+ {
+ Interceptions.add(this);
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ // AutoGenerated
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/Interceptions.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/Interceptions.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/Interceptions.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Interceptions
+{
+ private static ArrayList<Class<?>> interceptions = new ArrayList<Class<?>>();
+
+ public static void add(Object icptr)
+ {
+ interceptions.add(icptr.getClass());
+ }
+
+ public static void clear()
+ {
+ interceptions.clear();
+ }
+
+ public static ArrayList<Class<?>> getInterceptions()
+ {
+ return interceptions;
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/MethodInterceptor.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/MethodInterceptor.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/MethodInterceptor.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MethodInterceptor
+{
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext ctx) throws Exception
+ {
+ Interceptions.add(this);
+ return ctx.proceed();
+ }
+
+ @PostConstruct
+ @PreDestroy
+ public void lifecycle(InvocationContext ctx)
+ {
+ try
+ {
+ Interceptions.add(this);
+ ctx.proceed();
+ }
+ catch (Exception e)
+ {
+ // AutoGenerated
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/MyInterface.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/MyInterface.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/MyInterface.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MyInterface
+{
+ String method();
+}
Added: projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/unit/ExcludeInterceptorsTestCase.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/unit/ExcludeInterceptorsTestCase.java (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/test/interceptors/exclude/unit/ExcludeInterceptorsTestCase.java 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,535 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3.test.interceptors.exclude.unit;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aspects.common.AOPDeployer;
+import org.jboss.ejb3.interceptors.container.BeanContext;
+import org.jboss.ejb3.interceptors.direct.AbstractDirectContainer;
+import org.jboss.ejb3.interceptors.metadata.AdditiveBeanInterceptorMetaDataBridge;
+import org.jboss.ejb3.interceptors.metadata.InterceptorComponentMetaDataLoaderFactory;
+import org.jboss.ejb3.interceptors.metadata.InterceptorMetaDataBridge;
+import org.jboss.ejb3.metadata.MetaDataBridge;
+import org.jboss.ejb3.metadata.annotation.AnnotationRepositoryToMetaData;
+import org.jboss.ejb3.test.interceptors.exclude.AnnotatedAllInterceptorsBean;
+import org.jboss.ejb3.test.interceptors.exclude.AnnotatedExcludeClassAndDefaultBean;
+import org.jboss.ejb3.test.interceptors.exclude.AnnotatedExcludeClassAndDefaultForMethodBean;
+import org.jboss.ejb3.test.interceptors.exclude.AnnotatedExcludeClassBean;
+import org.jboss.ejb3.test.interceptors.exclude.AnnotatedExcludeDefaultBean;
+import org.jboss.ejb3.test.interceptors.exclude.AnnotatedExcludeDefaultForMethodBean;
+import org.jboss.ejb3.test.interceptors.exclude.ClassInterceptor;
+import org.jboss.ejb3.test.interceptors.exclude.DefaultInterceptor;
+import org.jboss.ejb3.test.interceptors.exclude.Interceptions;
+import org.jboss.ejb3.test.interceptors.exclude.MethodInterceptor;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBoss50MetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.jboss.metadata.ejb.spec.InterceptorMetaData;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.builder.JBossXBBuilder;
+import org.w3c.dom.ls.LSInput;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExcludeInterceptorsTestCase extends TestCase
+{
+ private static final Logger log = Logger.getLogger(ExcludeInterceptorsTestCase.class);
+
+ private class MyContainer<T> extends AbstractDirectContainer<T, MyContainer<T>>
+ {
+ public MyContainer(String name, String domainName, Class<? extends T> beanClass, JBossEnterpriseBeanMetaData beanMetaData)
+ {
+ super();
+
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ AnnotationRepositoryToMetaData annotations = new AnnotationRepositoryToMetaData(beanClass, beanMetaData, name, classLoader);
+ List<MetaDataBridge<InterceptorMetaData>> interceptorBridges = new ArrayList<MetaDataBridge<InterceptorMetaData>>();
+ interceptorBridges.add(new InterceptorMetaDataBridge());
+ annotations.addComponentMetaDataLoaderFactory(new InterceptorComponentMetaDataLoaderFactory(interceptorBridges));
+ annotations.addMetaDataBridge(new AdditiveBeanInterceptorMetaDataBridge(beanClass, classLoader, beanMetaData));
+
+ initializeAdvisor(name, getDomain(domainName), beanClass, annotations);
+ }
+
+ public void testAdvisor()
+ {
+ MyContainer<?> container = getAdvisor().getContainer();
+ assertNotNull("container not set in managed object advisor", container);
+ assertTrue(container == this);
+ }
+ }
+
+ protected static SchemaBindingResolver schemaResolverForClass(final Class<?> root)
+ {
+ return new SchemaBindingResolver()
+ {
+ public String getBaseURI()
+ {
+ return null;
+ }
+
+ public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation)
+ {
+ return JBossXBBuilder.build(root);
+ }
+
+ public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation)
+ {
+ return null;
+ }
+
+ public void setBaseURI(String baseURI)
+ {
+ }
+ };
+ }
+
+ // FIXME: use the right jboss-aop.xml
+ AOPDeployer deployer = new AOPDeployer("proxy/jboss-aop.xml");
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ log.info(deployer.deploy());
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ log.info(deployer.undeploy());
+ }
+
+ public void testAnnotatedAllInterceptors() throws Throwable
+ {
+ AspectManager.verbose = true;
+
+ // To make surefire happy
+ Thread.currentThread().setContextClassLoader(AnnotatedAllInterceptorsBean.class.getClassLoader());
+
+ // Bootstrap metadata
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ URL url = Thread.currentThread().getContextClassLoader().getResource("exclude/META-INF/ejb-jar.xml");
+ EjbJar30MetaData metaData = (EjbJar30MetaData) unmarshaller.unmarshal(url.toString(), schemaResolverForClass(EjbJar30MetaData.class));
+ JBoss50MetaData jbossMetaData = new JBoss50MetaData();
+ jbossMetaData.merge(null, metaData);
+
+ JBossEnterpriseBeanMetaData beanMetaData = jbossMetaData.getEnterpriseBean("AnnotatedAllInterceptorsBean");
+ assertNotNull(beanMetaData);
+ MyContainer<AnnotatedAllInterceptorsBean> container = new MyContainer<AnnotatedAllInterceptorsBean>("AnnotatedAllInterceptorsBean", "Test", AnnotatedAllInterceptorsBean.class, beanMetaData);
+ container.testAdvisor();
+
+ Interceptions.clear();
+ ArrayList<Class<?>> interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+ BeanContext<AnnotatedAllInterceptorsBean> bean = container.construct();
+ assertEquals(3, interceptions.size());
+ assertEquals(DefaultInterceptor.class, interceptions.get(0));
+ assertEquals(ClassInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedAllInterceptorsBean.class, interceptions.get(2));
+
+ Interceptions.clear();
+ assertEquals(0, interceptions.size());
+
+ String ret = container.invoke(bean, "method");
+ assertEquals(AnnotatedAllInterceptorsBean.class.getName(), ret);
+ assertEquals(4, interceptions.size());
+ assertEquals(DefaultInterceptor.class, interceptions.get(0));
+ assertEquals(ClassInterceptor.class, interceptions.get(1));
+ assertEquals(MethodInterceptor.class, interceptions.get(2));
+ assertEquals(AnnotatedAllInterceptorsBean.class, interceptions.get(3));
+
+ Interceptions.clear();
+ assertEquals(0, interceptions.size());
+ container.destroy(bean);
+ assertEquals(3, interceptions.size());
+ assertEquals(DefaultInterceptor.class, interceptions.get(0));
+ assertEquals(ClassInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedAllInterceptorsBean.class, interceptions.get(2));
+
+ log.info("======= Done");
+ }
+
+
+ public void testAnnotatedExcludeDefaultInterceptors() throws Throwable
+ {
+ AspectManager.verbose = true;
+
+ // To make surefire happy
+ Thread.currentThread().setContextClassLoader(AnnotatedExcludeDefaultBean.class.getClassLoader());
+
+ // Bootstrap metadata
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ URL url = Thread.currentThread().getContextClassLoader().getResource("exclude/META-INF/ejb-jar.xml");
+ EjbJar30MetaData metaData = (EjbJar30MetaData) unmarshaller.unmarshal(url.toString(), schemaResolverForClass(EjbJar30MetaData.class));
+ JBoss50MetaData jbossMetaData = new JBoss50MetaData();
+ jbossMetaData.merge(null, metaData);
+
+ JBossEnterpriseBeanMetaData beanMetaData = jbossMetaData.getEnterpriseBean("AnnotatedExcludeDefaultBean");
+ assertNotNull(beanMetaData);
+ MyContainer<AnnotatedExcludeDefaultBean> container = new MyContainer<AnnotatedExcludeDefaultBean>("AnnotatedExcludeDefaultBean", "Test", AnnotatedExcludeDefaultBean.class, beanMetaData);
+ container.testAdvisor();
+
+ Interceptions.clear();
+ ArrayList<Class<?>> interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+ BeanContext<AnnotatedExcludeDefaultBean> bean = container.construct();
+ assertEquals(2, interceptions.size());
+ assertEquals(ClassInterceptor.class, interceptions.get(0));
+ assertEquals(AnnotatedExcludeDefaultBean.class, interceptions.get(1));
+
+ Interceptions.clear();
+ interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+
+ String ret = container.invoke(bean, "method");
+ assertEquals(AnnotatedExcludeDefaultBean.class.getName(), ret);
+ assertEquals(3, interceptions.size());
+ assertEquals(ClassInterceptor.class, interceptions.get(0));
+ assertEquals(MethodInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedExcludeDefaultBean.class, interceptions.get(2));
+
+ Interceptions.clear();
+ assertEquals(0, interceptions.size());
+ container.destroy(bean);
+ assertEquals(2, interceptions.size());
+ assertEquals(ClassInterceptor.class, interceptions.get(0));
+ assertEquals(AnnotatedExcludeDefaultBean.class, interceptions.get(1));
+
+ log.info("======= Done");
+ }
+
+ public void testAnnotatedExcludeDefaultInterceptorsForMethod() throws Throwable
+ {
+ AspectManager.verbose = true;
+
+ // To make surefire happy
+ Thread.currentThread().setContextClassLoader(AnnotatedExcludeDefaultForMethodBean.class.getClassLoader());
+
+ // Bootstrap metadata
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ URL url = Thread.currentThread().getContextClassLoader().getResource("exclude/META-INF/ejb-jar.xml");
+ EjbJar30MetaData metaData = (EjbJar30MetaData) unmarshaller.unmarshal(url.toString(), schemaResolverForClass(EjbJar30MetaData.class));
+ JBoss50MetaData jbossMetaData = new JBoss50MetaData();
+ jbossMetaData.merge(null, metaData);
+
+ JBossEnterpriseBeanMetaData beanMetaData = jbossMetaData.getEnterpriseBean("AnnotatedExcludeDefaultForMethodBean");
+ assertNotNull(beanMetaData);
+ MyContainer<AnnotatedExcludeDefaultForMethodBean> container = new MyContainer<AnnotatedExcludeDefaultForMethodBean>("AnnotatedExcludeDefaultForMethodBean", "Test", AnnotatedExcludeDefaultForMethodBean.class, beanMetaData);
+ container.testAdvisor();
+
+ Interceptions.clear();
+ ArrayList<Class<?>> interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+ BeanContext<AnnotatedExcludeDefaultForMethodBean> bean = container.construct();
+ assertEquals(3, interceptions.size());
+ assertEquals(DefaultInterceptor.class, interceptions.get(0));
+ assertEquals(ClassInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedExcludeDefaultForMethodBean.class, interceptions.get(2));
+
+ Interceptions.clear();
+ interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+
+ String ret = container.invoke(bean, "method");
+ assertEquals(AnnotatedExcludeDefaultForMethodBean.class.getName(), ret);
+ assertEquals(3, interceptions.size());
+ assertEquals(ClassInterceptor.class, interceptions.get(0));
+ assertEquals(MethodInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedExcludeDefaultForMethodBean.class, interceptions.get(2));
+
+ Interceptions.clear();
+ assertEquals(0, interceptions.size());
+ container.destroy(bean);
+ assertEquals(3, interceptions.size());
+ assertEquals(DefaultInterceptor.class, interceptions.get(0));
+ assertEquals(ClassInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedExcludeDefaultForMethodBean.class, interceptions.get(2));
+
+ log.info("======= Done");
+ }
+
+ public void testAnnotatedExcludeClassInterceptors() throws Throwable
+ {
+ AspectManager.verbose = true;
+
+ // To make surefire happy
+ Thread.currentThread().setContextClassLoader(AnnotatedExcludeClassBean.class.getClassLoader());
+
+ // Bootstrap metadata
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ URL url = Thread.currentThread().getContextClassLoader().getResource("exclude/META-INF/ejb-jar.xml");
+ EjbJar30MetaData metaData = (EjbJar30MetaData) unmarshaller.unmarshal(url.toString(), schemaResolverForClass(EjbJar30MetaData.class));
+ JBoss50MetaData jbossMetaData = new JBoss50MetaData();
+ jbossMetaData.merge(null, metaData);
+
+ JBossEnterpriseBeanMetaData beanMetaData = jbossMetaData.getEnterpriseBean("AnnotatedExcludeClassBean");
+ assertNotNull(beanMetaData);
+ MyContainer<AnnotatedExcludeClassBean> container = new MyContainer<AnnotatedExcludeClassBean>("AnnotatedExcludeClassBean", "Test", AnnotatedExcludeClassBean.class, beanMetaData);
+ container.testAdvisor();
+
+ Interceptions.clear();
+ ArrayList<Class<?>> interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+ BeanContext<AnnotatedExcludeClassBean> bean = container.construct();
+ assertEquals(3, interceptions.size());
+ assertEquals(DefaultInterceptor.class, interceptions.get(0));
+ assertEquals(ClassInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedExcludeClassBean.class, interceptions.get(2));
+
+ Interceptions.clear();
+ interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+
+ String ret = container.invoke(bean, "method");
+ assertEquals(AnnotatedExcludeClassBean.class.getName(), ret);
+ assertEquals(3, interceptions.size());
+ assertEquals(DefaultInterceptor.class, interceptions.get(0));
+ assertEquals(MethodInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedExcludeClassBean.class, interceptions.get(2));
+
+ Interceptions.clear();
+ assertEquals(0, interceptions.size());
+ container.destroy(bean);
+ assertEquals(3, interceptions.size());
+ assertEquals(DefaultInterceptor.class, interceptions.get(0));
+ assertEquals(ClassInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedExcludeClassBean.class, interceptions.get(2));
+
+ log.info("======= Done");
+ }
+
+ public void testAnnotatedExcludeClassAndDefaultInterceptors() throws Throwable
+ {
+ AspectManager.verbose = true;
+
+ // To make surefire happy
+ Thread.currentThread().setContextClassLoader(AnnotatedExcludeClassAndDefaultBean.class.getClassLoader());
+
+ // Bootstrap metadata
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ URL url = Thread.currentThread().getContextClassLoader().getResource("exclude/META-INF/ejb-jar.xml");
+ EjbJar30MetaData metaData = (EjbJar30MetaData) unmarshaller.unmarshal(url.toString(), schemaResolverForClass(EjbJar30MetaData.class));
+ JBoss50MetaData jbossMetaData = new JBoss50MetaData();
+ jbossMetaData.merge(null, metaData);
+
+ JBossEnterpriseBeanMetaData beanMetaData = jbossMetaData.getEnterpriseBean("AnnotatedExcludeClassAndDefaultBean");
+ assertNotNull(beanMetaData);
+ MyContainer<AnnotatedExcludeClassAndDefaultBean> container = new MyContainer<AnnotatedExcludeClassAndDefaultBean>("AnnotatedExcludeClassAndDefaultBean", "Test", AnnotatedExcludeClassAndDefaultBean.class, beanMetaData);
+ container.testAdvisor();
+
+ Interceptions.clear();
+ ArrayList<Class<?>> interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+ BeanContext<AnnotatedExcludeClassAndDefaultBean> bean = container.construct();
+ assertEquals(2, interceptions.size());
+ assertEquals(ClassInterceptor.class, interceptions.get(0));
+ assertEquals(AnnotatedExcludeClassAndDefaultBean.class, interceptions.get(1));
+
+ Interceptions.clear();
+ interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+
+ String ret = container.invoke(bean, "method");
+ assertEquals(AnnotatedExcludeClassAndDefaultBean.class.getName(), ret);
+ assertEquals(2, interceptions.size());
+ assertEquals(MethodInterceptor.class, interceptions.get(0));
+ assertEquals(AnnotatedExcludeClassAndDefaultBean.class, interceptions.get(1));
+
+ Interceptions.clear();
+ assertEquals(0, interceptions.size());
+ container.destroy(bean);
+ assertEquals(2, interceptions.size());
+ assertEquals(ClassInterceptor.class, interceptions.get(0));
+ assertEquals(AnnotatedExcludeClassAndDefaultBean.class, interceptions.get(1));
+
+ log.info("======= Done");
+ }
+
+ public void testAnnotatedExcludeClassAndDefaultInterceptorsForMethod() throws Throwable
+ {
+ AspectManager.verbose = true;
+
+ // To make surefire happy
+ Thread.currentThread().setContextClassLoader(AnnotatedExcludeClassAndDefaultForMethodBean.class.getClassLoader());
+
+ // Bootstrap metadata
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ URL url = Thread.currentThread().getContextClassLoader().getResource("exclude/META-INF/ejb-jar.xml");
+ EjbJar30MetaData metaData = (EjbJar30MetaData) unmarshaller.unmarshal(url.toString(), schemaResolverForClass(EjbJar30MetaData.class));
+ JBoss50MetaData jbossMetaData = new JBoss50MetaData();
+ jbossMetaData.merge(null, metaData);
+
+ JBossEnterpriseBeanMetaData beanMetaData = jbossMetaData.getEnterpriseBean("AnnotatedExcludeClassAndDefaultForMethodBean");
+ assertNotNull(beanMetaData);
+ MyContainer<AnnotatedExcludeClassAndDefaultForMethodBean> container = new MyContainer<AnnotatedExcludeClassAndDefaultForMethodBean>("AnnotatedExcludeClassAndDefaultForMethodBean", "Test", AnnotatedExcludeClassAndDefaultForMethodBean.class, beanMetaData);
+ container.testAdvisor();
+
+ Interceptions.clear();
+ ArrayList<Class<?>> interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+ BeanContext<AnnotatedExcludeClassAndDefaultForMethodBean> bean = container.construct();
+ assertEquals(3, interceptions.size());
+ assertEquals(DefaultInterceptor.class, interceptions.get(0));
+ assertEquals(ClassInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedExcludeClassAndDefaultForMethodBean.class, interceptions.get(2));
+
+ Interceptions.clear();
+ interceptions = Interceptions.getInterceptions();
+ assertEquals(0, interceptions.size());
+
+ String ret = container.invoke(bean, "method");
+ assertEquals(AnnotatedExcludeClassAndDefaultForMethodBean.class.getName(), ret);
+ assertEquals(2, interceptions.size());
+ assertEquals(MethodInterceptor.class, interceptions.get(0));
+ assertEquals(AnnotatedExcludeClassAndDefaultForMethodBean.class, interceptions.get(1));
+
+ Interceptions.clear();
+ assertEquals(0, interceptions.size());
+ container.destroy(bean);
+ assertEquals(3, interceptions.size());
+ assertEquals(DefaultInterceptor.class, interceptions.get(0));
+ assertEquals(ClassInterceptor.class, interceptions.get(1));
+ assertEquals(AnnotatedExcludeClassAndDefaultForMethodBean.class, interceptions.get(2));
+
+ log.info("======= Done");
+ }
+
+// public void testXmlAllInterceptors() throws Throwable
+// {
+// AspectManager.verbose = true;
+//
+// // To make surefire happy
+// Thread.currentThread().setContextClassLoader(AnnotatedAllInterceptorsBean.class.getClassLoader());
+//
+// // Bootstrap metadata
+// UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+// Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+// URL url = Thread.currentThread().getContextClassLoader().getResource("exclude/META-INF/ejb-jar.xml");
+// EjbJar30MetaData metaData = (EjbJar30MetaData) unmarshaller.unmarshal(url.toString(), schemaResolverForClass(EjbJar30MetaData.class));
+// JBoss50MetaData jbossMetaData = new JBoss50MetaData();
+// jbossMetaData.merge(null, metaData);
+//
+// JBossEnterpriseBeanMetaData beanMetaData = jbossMetaData.getEnterpriseBean("XmlAllInterceptorsBean");
+// assertNotNull(beanMetaData);
+// MyContainer<XmlAllInterceptorsBean> container = new MyContainer<XmlAllInterceptorsBean>("XmlAllInterceptorsBean", "Test", XmlAllInterceptorsBean.class, beanMetaData);
+// container.testAdvisor();
+//
+// Interceptions.clear();
+// ArrayList<Class<?>> interceptions = Interceptions.getInterceptions();
+// assertEquals(0, interceptions.size());
+// BeanContext<XmlAllInterceptorsBean> bean = container.construct();
+// assertEquals(3, interceptions.size());
+// assertEquals(DefaultInterceptor.class, interceptions.get(0));
+// assertEquals(ClassInterceptor.class, interceptions.get(1));
+// assertEquals(XmlAllInterceptorsBean.class, interceptions.get(2));
+//
+// Interceptions.clear();
+// assertEquals(0, interceptions.size());
+//
+// String ret = container.invoke(bean, "method");
+// assertEquals(XmlAllInterceptorsBean.class.getName(), ret);
+// assertEquals(4, interceptions.size());
+// assertEquals(DefaultInterceptor.class, interceptions.get(0));
+// assertEquals(ClassInterceptor.class, interceptions.get(1));
+// assertEquals(MethodInterceptor.class, interceptions.get(2));
+// assertEquals(XmlAllInterceptorsBean.class, interceptions.get(3));
+//
+// Interceptions.clear();
+// assertEquals(0, interceptions.size());
+// container.destroy(bean);
+// assertEquals(3, interceptions.size());
+// assertEquals(DefaultInterceptor.class, interceptions.get(0));
+// assertEquals(ClassInterceptor.class, interceptions.get(1));
+// assertEquals(XmlAllInterceptorsBean.class, interceptions.get(2));
+//
+// log.info("======= Done");
+// }
+//
+// public void testXmlExcludeDefaultInterceptors() throws Throwable
+// {
+// AspectManager.verbose = true;
+//
+// // To make surefire happy
+// Thread.currentThread().setContextClassLoader(XmlExcludeDefaultBean.class.getClassLoader());
+//
+// // Bootstrap metadata
+// UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+// Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+// URL url = Thread.currentThread().getContextClassLoader().getResource("exclude/META-INF/ejb-jar.xml");
+// EjbJar30MetaData metaData = (EjbJar30MetaData) unmarshaller.unmarshal(url.toString(), schemaResolverForClass(EjbJar30MetaData.class));
+// JBoss50MetaData jbossMetaData = new JBoss50MetaData();
+// jbossMetaData.merge(null, metaData);
+//
+// JBossEnterpriseBeanMetaData beanMetaData = jbossMetaData.getEnterpriseBean("XmlExcludeDefaultBean");
+// assertNotNull(beanMetaData);
+// MyContainer<XmlExcludeDefaultBean> container = new MyContainer<XmlExcludeDefaultBean>("XmlExcludeDefaultBean", "Test", XmlExcludeDefaultBean.class, beanMetaData);
+// container.testAdvisor();
+//
+// Interceptions.clear();
+// ArrayList<Class<?>> interceptions = Interceptions.getInterceptions();
+// assertEquals(0, interceptions.size());
+// BeanContext<XmlExcludeDefaultBean> bean = container.construct();
+// assertEquals(2, interceptions.size());
+// assertEquals(ClassInterceptor.class, interceptions.get(0));
+// assertEquals(XmlExcludeDefaultBean.class, interceptions.get(1));
+//
+// Interceptions.clear();
+// interceptions = Interceptions.getInterceptions();
+// assertEquals(0, interceptions.size());
+//
+// String ret = container.invoke(bean, "method");
+// assertEquals(XmlExcludeDefaultBean.class.getName(), ret);
+// assertEquals(3, interceptions.size());
+// assertEquals(ClassInterceptor.class, interceptions.get(0));
+// assertEquals(MethodInterceptor.class, interceptions.get(1));
+// assertEquals(XmlExcludeDefaultBean.class, interceptions.get(2));
+//
+// Interceptions.clear();
+// assertEquals(0, interceptions.size());
+// container.destroy(bean);
+// assertEquals(2, interceptions.size());
+// assertEquals(ClassInterceptor.class, interceptions.get(0));
+// assertEquals(XmlExcludeDefaultBean.class, interceptions.get(1));
+//
+// log.info("======= Done");
+// }
+
+}
Added: projects/ejb3/trunk/interceptors/src/test/resources/exclude/META-INF/ejb-jar.xml
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/resources/exclude/META-INF/ejb-jar.xml (rev 0)
+++ projects/ejb3/trunk/interceptors/src/test/resources/exclude/META-INF/ejb-jar.xml 2008-05-09 15:22:43 UTC (rev 73210)
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+ <display-name>InterceptorsTest</display-name>
+ <!-- Must define a bean here, because we have no annotation on it -->
+ <!-- (Can't use @Stateless within ejb3-interceptors) -->
+ <enterprise-beans>
+ <session>
+ <ejb-name>AnnotatedAllInterceptorsBean</ejb-name>
+ </session>
+ <session>
+ <ejb-name>AnnotatedExcludeDefaultBean</ejb-name>
+ </session>
+ <session>
+ <ejb-name>AnnotatedExcludeDefaultForMethodBean</ejb-name>
+ </session>
+ <session>
+ <ejb-name>AnnotatedExcludeClassBean</ejb-name>
+ </session>
+ <session>
+ <ejb-name>AnnotatedExcludeClassAndDefaultBean</ejb-name>
+ </session>
+ <session>
+ <ejb-name>AnnotatedExcludeClassAndDefaultForMethodBean</ejb-name>
+ </session>
+<!--
+ <session>
+ <ejb-name>XmlAllInterceptorsBean</ejb-name>
+ <around-invoke>
+ <method-name>aroundInvoke</method-name>
+ </around-invoke>
+ <post-construct>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </post-construct>
+ <pre-destroy>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </pre-destroy>
+ </session>
+ <session>
+ <ejb-name>XmlExcludeDefaultBean</ejb-name>
+ <around-invoke>
+ <method-name>aroundInvoke</method-name>
+ </around-invoke>
+ <post-construct>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </post-construct>
+ <pre-destroy>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </pre-destroy>
+ </session>
+ <session>
+ <ejb-name>XmlExcludeDefaultForMethodBean</ejb-name>
+ <around-invoke>
+ <method-name>aroundInvoke</method-name>
+ </around-invoke>
+ <post-construct>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </post-construct>
+ <pre-destroy>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </pre-destroy>
+ </session>
+ <session>
+ <ejb-name>XmlExcludeClassBean</ejb-name>
+ <around-invoke>
+ <method-name>aroundInvoke</method-name>
+ </around-invoke>
+ <post-construct>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </post-construct>
+ <pre-destroy>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </pre-destroy>
+ </session>
+ <session>
+ <ejb-name>XmlExcludeClassAndDefaultBean</ejb-name>
+ <around-invoke>
+ <method-name>aroundInvoke</method-name>
+ </around-invoke>
+ <post-construct>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </post-construct>
+ <pre-destroy>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </pre-destroy>
+ </session>
+ <session>
+ <ejb-name>XmlExcludeClassAndDefaultForMethodBean</ejb-name>
+ <around-invoke>
+ <method-name>aroundInvoke</method-name>
+ </around-invoke>
+ <post-construct>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </post-construct>
+ <pre-destroy>
+ <lifecycle-callback-method>lifecycle</lifecycle-callback-method>
+ </pre-destroy>
+ </session>
+-->
+ </enterprise-beans>
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>org.jboss.ejb3.test.interceptors.exclude.DefaultInterceptor</interceptor-class>
+ </interceptor-binding>
+<!--
+ <interceptor-binding>
+ <ejb-name>XmlAllInterceptorsBean</ejb-name>
+ <interceptor-class>org.jboss.ejb3.test.interceptors.exclude.ClassInterceptor</interceptor-class>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>XmlAllInterceptorsBean</ejb-name>
+ <interceptor-class>org.jboss.ejb3.test.interceptors.exclude.MethodInterceptor</interceptor-class>
+ <method>
+ <method-name>method</method-name>
+ </method>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>XmlExcludeDefaultBean</ejb-name>
+ <interceptor-class>org.jboss.ejb3.test.interceptors.exclude.ClassInterceptor</interceptor-class>
+ <exclude-default-interceptors>true</exclude-default-interceptors>
+ </interceptor-binding>
+ <interceptor-binding>
+ <ejb-name>XmlExcludeDefaultBean</ejb-name>
+ <interceptor-class>org.jboss.ejb3.test.interceptors.exclude.MethodInterceptor</interceptor-class>
+ <method>
+ <method-name>method</method-name>
+ </method>
+ </interceptor-binding>
+-->
+ </assembly-descriptor>
+</ejb-jar>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list