[jboss-cvs] JBossAS SVN: r67317 - projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 21 00:48:12 EST 2007


Author: scott.stark at jboss.org
Date: 2007-11-21 00:48:12 -0500 (Wed, 21 Nov 2007)
New Revision: 67317

Added:
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/TestClassInterceptor.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/TestMethodInterceptor.java
Modified:
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessBean.java
Log:
Add test interceptors

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java	2007-11-21 05:29:20 UTC (rev 67316)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/AnnotationEjb3UnitTestCase.java	2007-11-21 05:48:12 UTC (rev 67317)
@@ -58,6 +58,7 @@
 import org.jboss.metadata.ejb.spec.ExcludeListMetaData;
 import org.jboss.metadata.ejb.spec.InitMethodMetaData;
 import org.jboss.metadata.ejb.spec.InitMethodsMetaData;
+import org.jboss.metadata.ejb.spec.InterceptorBindingMetaData;
 import org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData;
 import org.jboss.metadata.ejb.spec.MethodMetaData;
 import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
@@ -439,6 +440,8 @@
       roles.add("AccessRole1");
       roles.add("AccessRole2");
       assertEquals(roles, rolesAllowed.getRoles());
+
+      InterceptorBindingMetaData interceptorBinding = assembly.getInterceptorBindingByEjbName("MyStatelessBean");
    }
 
    /**

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessBean.java	2007-11-21 05:29:20 UTC (rev 67316)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatelessBean.java	2007-11-21 05:48:12 UTC (rev 67317)
@@ -40,6 +40,8 @@
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
 import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
 import javax.interceptor.Interceptors;
 import javax.interceptor.InvocationContext;
 import javax.jms.Queue;
@@ -61,7 +63,8 @@
 })
 @DeclareRoles(value={"Role1","Role2"})
 @RunAs("InternalUser")
- at Interceptors(TestInterceptor.class)
+ at Interceptors(TestClassInterceptor.class)
+ at ExcludeDefaultInterceptors
 public class MyStatelessBean implements MyStatelessLocal
 {
    @EJB
@@ -147,7 +150,16 @@
    @AroundInvoke
    public Object intercept(InvocationContext ctx) throws Exception
    {
-      System.out.println("**** intercepted ****" + ctx.getMethod().getName());
+      System.out.println("**** intercept ****" + ctx.getMethod().getName());
       return ctx.proceed();
    }
+
+   @ExcludeClassInterceptors
+   @ExcludeDefaultInterceptors
+   @Interceptors(TestMethodInterceptor.class)
+   public Object intercept2(InvocationContext ctx) throws Exception
+   {
+      System.out.println("**** intercept2 ****" + ctx.getMethod().getName());
+      return ctx.proceed();
+   }
 }

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/TestClassInterceptor.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/TestClassInterceptor.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/TestClassInterceptor.java	2007-11-21 05:48:12 UTC (rev 67317)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.test.metadata.annotation.ejb3;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class TestClassInterceptor
+{
+   @PostConstruct
+   public void postConstruct(InvocationContext ctx)
+   {
+      System.out.println("PostConstruct");
+   }
+
+   @AroundInvoke
+   public Object around(InvocationContext ctx) throws Exception
+   {
+      System.out.println("Around invoke");
+      return ctx.proceed();
+   }
+
+}


Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/TestClassInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/TestMethodInterceptor.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/TestMethodInterceptor.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/TestMethodInterceptor.java	2007-11-21 05:48:12 UTC (rev 67317)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.test.metadata.annotation.ejb3;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class TestMethodInterceptor
+{
+   @PostConstruct
+   public void postConstruct(InvocationContext ctx)
+   {
+      System.out.println("PostConstruct");
+   }
+
+   @AroundInvoke
+   public Object around(InvocationContext ctx) throws Exception
+   {
+      System.out.println("Around invoke");
+      return ctx.proceed();
+   }
+
+}


Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/TestMethodInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list