You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by mn...@apache.org on 2007/06/18 11:23:27 UTC
svn commit: r548273 - in
/openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/openejb/ src/main/java/org/apache/openejb/test/
src/main/ja...
Author: mnour
Date: Mon Jun 18 02:23:25 2007
New Revision: 548273
URL: http://svn.apache.org/viewvc?view=rev&rev=548273
Log:
OPENEJB-201, forgot to add openejb-itests-interceptor-beans
Added:
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/pom.xml
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/SecondStatefulInterceptedBean.java
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/StatefulInterceptedBean.java
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/ThirdStatefulInterceptedBean.java
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/SecondStatelessInterceptedBean.java
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/StatelessInterceptedBean.java
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/ThirdStatelessInterceptedBean.java
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/resources/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/resources/META-INF/
openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/resources/META-INF/ejb-jar.xml
Added: openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/pom.xml?view=auto&rev=548273
==============================================================================
--- openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/pom.xml (added)
+++ openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/pom.xml Mon Jun 18 02:23:25 2007
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>itests</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>openejb-itests-interceptor-beans</artifactId>
+ <packaging>jar</packaging>
+ <name>OpenEJB :: iTests Interceptor Beans</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-itests-beans</artifactId>
+ <version>${version}</version>
+ </dependency>
+ </dependencies>
+</project>
Added: openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/SecondStatefulInterceptedBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/SecondStatefulInterceptedBean.java?view=auto&rev=548273
==============================================================================
--- openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/SecondStatefulInterceptedBean.java (added)
+++ openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/SecondStatefulInterceptedBean.java Mon Jun 18 02:23:25 2007
@@ -0,0 +1,164 @@
+/**
+ * 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.openejb.test.stateful;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Stateful;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+import org.apache.openejb.test.SuperInterceptedBean;
+import org.apache.openejb.test.interceptor.ClassInterceptor;
+import org.apache.openejb.test.interceptor.Interceptor;
+import org.apache.openejb.test.interceptor.MethodInterceptor;
+import org.apache.openejb.test.interceptor.SecondClassInterceptor;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+@Stateful(name="SecondStatefulIntercepted")
+@Interceptors({ClassInterceptor.class, SecondClassInterceptor.class})
+public class SecondStatefulInterceptedBean extends SuperInterceptedBean
+ implements BasicStatefulInterceptedLocal, BasicStatefulInterceptedRemote {
+
+ private static Map<String, Object> contextData = new HashMap<String, Object>();
+
+ /**
+ * A simple dummy business method to concat 2 strings
+ * @see org.apache.openejb.test.Stateful.fulInterceptedLocal#concat(java.lang.String, java.lang.String)
+ */
+ public String concat(String str1, String str2) {
+ return str1.concat(str2);
+ }
+
+ /**
+ * A simple dummy busines method to reverse a string
+ * @see org.apache.openejb.test.Stateful.fulInterceptedLocal#reverse(java.lang.String)
+ */
+ @Interceptors({MethodInterceptor.class})
+ public String reverse(String str) {
+ System.out.println("Reversing " + str);
+ StringBuffer b = new StringBuffer(str);
+ return b.reverse().toString();
+ }
+
+ /**
+ * <code>ClassInterceptor</code> should not intercept this.
+ *
+ * @return the contextData
+ */
+ @ExcludeClassInterceptors
+ public Map<String, Object> getContextData() {
+ return contextData;
+ }
+
+ /**
+ * @param contextData the contextData to set
+ */
+ private void setContextData(Map<String, Object> ctxData) {
+ SecondStatefulInterceptedBean.contextData.putAll(ctxData);
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept all business methods in this bean class.
+ * It cannot exclude even those annotated with <code>@ExcludeClassInterceptors</code>
+ *
+ * @param ctx - InvocationContext
+ *
+ * @return - the result of the next method invoked. If a method returns void, proceed returns null.
+ * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class,
+ * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned.
+ * If there is more than one such interceptor method, the invocation of proceed causes the container to execute those methods in order.
+ *
+ * @throws runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
+ */
+ @AroundInvoke
+ public Object inBeanInterceptor(InvocationContext ctx) throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(ctx);
+ setContextData(ctxData);
+
+ return ctx.proceed();
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept postConstruct of the bean
+ *
+ * @throws runtime exceptions.
+ */
+ @PostConstruct
+ public void inBeanInterceptorPostConstruct() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+
+ /**
+ * The interceptor method.
+ * This should intercept postActivate of the bean
+ *
+ * @throws runtime exceptions.
+ */
+ @PostActivate
+ public void inBeanInterceptorPostActivate() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept prePassivate of the bean.
+ *
+ * @throws runtime exceptions.
+ */
+ @PrePassivate
+ public void inBeanInterceptorPrePassivate() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept preDestroy of the bean.
+ *
+ * @throws runtime exceptions.
+ */
+ @PreDestroy
+ public void inBeanInterceptorPreDestroy() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+
+
+}
Added: openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/StatefulInterceptedBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/StatefulInterceptedBean.java?view=auto&rev=548273
==============================================================================
--- openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/StatefulInterceptedBean.java (added)
+++ openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/StatefulInterceptedBean.java Mon Jun 18 02:23:25 2007
@@ -0,0 +1,164 @@
+/**
+ * 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.openejb.test.stateful;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Stateful;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+import org.apache.openejb.test.SuperInterceptedBean;
+import org.apache.openejb.test.interceptor.ClassInterceptor;
+import org.apache.openejb.test.interceptor.Interceptor;
+import org.apache.openejb.test.interceptor.MethodInterceptor;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+@Stateful(name="StatefulIntercepted")
+@Interceptors({ClassInterceptor.class})
+public class StatefulInterceptedBean extends SuperInterceptedBean
+ implements BasicStatefulInterceptedLocal, BasicStatefulInterceptedRemote {
+
+ private static Map<String, Object> contextData = new HashMap<String, Object>();
+
+ /**
+ * A simple dummy business method to concat 2 strings
+ * @see org.apache.openejb.test.Stateful.fulInterceptedLocal#concat(java.lang.String, java.lang.String)
+ */
+ public String concat(String str1, String str2) {
+ return str1.concat(str2);
+ }
+
+ /**
+ * A simple dummy busines method to reverse a string
+ * @see org.apache.openejb.test.Stateful.fulInterceptedLocal#reverse(java.lang.String)
+ */
+ @Interceptors({MethodInterceptor.class})
+ public String reverse(String str) {
+ System.out.println("Reversing " + str);
+ StringBuffer b = new StringBuffer(str);
+ return b.reverse().toString();
+ }
+
+ /**
+ * <code>ClassInterceptor</code> should not intercept this.
+ *
+ * @return the contextData
+ */
+ @ExcludeDefaultInterceptors
+ @ExcludeClassInterceptors
+ public Map<String, Object> getContextData() {
+ return contextData;
+ }
+
+ /**
+ * @param contextData the contextData to set
+ */
+ private void setContextData(Map<String, Object> ctxData) {
+ StatefulInterceptedBean.contextData.putAll(ctxData);
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept all business methods in this bean class.
+ * It cannot exclude even those annotated with <code>@ExcludeClassInterceptors</code>
+ *
+ * @param ctx - InvocationContext
+ *
+ * @return - the result of the next method invoked. If a method returns void, proceed returns null.
+ * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class,
+ * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned.
+ * If there is more than one such interceptor method, the invocation of proceed causes the container to execute those methods in order.
+ *
+ * @throws runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
+ */
+ @AroundInvoke
+ public Object inBeanInterceptor(InvocationContext ctx) throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(ctx);
+ setContextData(ctxData);
+
+ return ctx.proceed();
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept postConstruct of the bean
+ *
+ * @throws runtime exceptions.
+ */
+ @PostConstruct
+ public void inBeanInterceptorPostConstruct() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+
+ /**
+ * The interceptor method.
+ * This should intercept postActivate of the bean
+ *
+ * @throws runtime exceptions.
+ */
+ @PostActivate
+ public void inBeanInterceptorPostActivate() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept prePassivate of the bean.
+ *
+ * @throws runtime exceptions.
+ */
+ @PrePassivate
+ public void inBeanInterceptorPrePassivate() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept preDestroy of the bean.
+ *
+ * @throws runtime exceptions.
+ */
+ @PreDestroy
+ public void inBeanInterceptorPreDestroy() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+
+
+}
Added: openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/ThirdStatefulInterceptedBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/ThirdStatefulInterceptedBean.java?view=auto&rev=548273
==============================================================================
--- openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/ThirdStatefulInterceptedBean.java (added)
+++ openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateful/ThirdStatefulInterceptedBean.java Mon Jun 18 02:23:25 2007
@@ -0,0 +1,164 @@
+/**
+ * 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.openejb.test.stateful;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Stateful;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+import org.apache.openejb.test.SuperInterceptedBean;
+import org.apache.openejb.test.interceptor.ClassInterceptor;
+import org.apache.openejb.test.interceptor.Interceptor;
+import org.apache.openejb.test.interceptor.MethodInterceptor;
+import org.apache.openejb.test.interceptor.SecondClassInterceptor;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+@Stateful(name="ThirdStatefulIntercepted")
+@Interceptors({ClassInterceptor.class, SecondClassInterceptor.class})
+public class ThirdStatefulInterceptedBean extends SuperInterceptedBean
+ implements BasicStatefulInterceptedLocal, BasicStatefulInterceptedRemote {
+
+ private static Map<String, Object> contextData = new HashMap<String, Object>();
+
+ /**
+ * A simple dummy business method to concat 2 strings
+ * @see org.apache.openejb.test.Stateful.fulInterceptedLocal#concat(java.lang.String, java.lang.String)
+ */
+ public String concat(String str1, String str2) {
+ return str1.concat(str2);
+ }
+
+ /**
+ * A simple dummy busines method to reverse a string
+ * @see org.apache.openejb.test.Stateful.fulInterceptedLocal#reverse(java.lang.String)
+ */
+ @Interceptors({MethodInterceptor.class})
+ public String reverse(String str) {
+ System.out.println("Reversing " + str);
+ StringBuffer b = new StringBuffer(str);
+ return b.reverse().toString();
+ }
+
+ /**
+ * <code>ClassInterceptor</code> should not intercept this.
+ *
+ * @return the contextData
+ */
+ @ExcludeClassInterceptors
+ public Map<String, Object> getContextData() {
+ return contextData;
+ }
+
+ /**
+ * @param contextData the contextData to set
+ */
+ private void setContextData(Map<String, Object> ctxData) {
+ ThirdStatefulInterceptedBean.contextData.putAll(ctxData);
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept all business methods in this bean class.
+ * It cannot exclude even those annotated with <code>@ExcludeClassInterceptors</code>
+ *
+ * @param ctx - InvocationContext
+ *
+ * @return - the result of the next method invoked. If a method returns void, proceed returns null.
+ * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class,
+ * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned.
+ * If there is more than one such interceptor method, the invocation of proceed causes the container to execute those methods in order.
+ *
+ * @throws runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
+ */
+ @AroundInvoke
+ public Object inBeanInterceptor(InvocationContext ctx) throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(ctx);
+ setContextData(ctxData);
+
+ return ctx.proceed();
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept postConstruct of the bean
+ *
+ * @throws runtime exceptions.
+ */
+ @PostConstruct
+ public void inBeanInterceptorPostConstruct() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+
+ /**
+ * The interceptor method.
+ * This should intercept postActivate of the bean
+ *
+ * @throws runtime exceptions.
+ */
+ @PostActivate
+ public void inBeanInterceptorPostActivate() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept prePassivate of the bean.
+ *
+ * @throws runtime exceptions.
+ */
+ @PrePassivate
+ public void inBeanInterceptorPrePassivate() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept preDestroy of the bean.
+ *
+ * @throws runtime exceptions.
+ */
+ @PreDestroy
+ public void inBeanInterceptorPreDestroy() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+
+
+}
Added: openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/SecondStatelessInterceptedBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/SecondStatelessInterceptedBean.java?view=auto&rev=548273
==============================================================================
--- openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/SecondStatelessInterceptedBean.java (added)
+++ openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/SecondStatelessInterceptedBean.java Mon Jun 18 02:23:25 2007
@@ -0,0 +1,135 @@
+/**
+ * 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.openejb.test.stateless;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+import org.apache.openejb.test.SuperInterceptedBean;
+import org.apache.openejb.test.interceptor.ClassInterceptor;
+import org.apache.openejb.test.interceptor.Interceptor;
+import org.apache.openejb.test.interceptor.MethodInterceptor;
+import org.apache.openejb.test.interceptor.SecondClassInterceptor;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+@Stateless(name="SecondStatelessIntercepted")
+@Interceptors({ClassInterceptor.class, SecondClassInterceptor.class})
+@ExcludeDefaultInterceptors
+public class SecondStatelessInterceptedBean extends SuperInterceptedBean
+ implements BasicStatelessInterceptedLocal, BasicStatelessInterceptedRemote {
+
+ private static Map<String, Object> contextData = new HashMap<String, Object>();
+
+ /**
+ * A simple dummy business method to concat 2 strings
+ * @see org.apache.openejb.test.stateless.BasicStatelessInterceptedLocal#concat(java.lang.String, java.lang.String)
+ */
+ public String concat(String str1, String str2) {
+ return str1.concat(str2);
+ }
+
+ /**
+ * A simple dummy busines method to reverse a string
+ * @see org.apache.openejb.test.stateless.BasicStatelessInterceptedLocal#reverse(java.lang.String)
+ */
+ @Interceptors({MethodInterceptor.class})
+ public String reverse(String str) {
+ System.out.println("Reversing " + str);
+ StringBuffer b = new StringBuffer(str);
+ return b.reverse().toString();
+ }
+
+ /**
+ * @param contextData the contextData to set
+ */
+ private void setContextData(Map<String, Object> ctxData) {
+ SecondStatelessInterceptedBean.contextData.putAll(ctxData);
+ }
+
+ /**
+ * <code>ClassInterceptor</code> should not intercept this.
+ *
+ * @return the contextData
+ */
+ @ExcludeClassInterceptors
+ public Map<String, Object> getContextData() {
+ return contextData;
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept all business methods in this bean class.
+ * It cannot exclude even those annotated with <code>@ExcludeClassInterceptors</code>
+ *
+ * @param ctx - InvocationContext
+ *
+ * @return - the result of the next method invoked. If a method returns void, proceed returns null.
+ * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class,
+ * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned.
+ * If there is more than one such interceptor method, the invocation of proceed causes the container to execute those methods in order.
+ *
+ * @throws runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
+ */
+ @AroundInvoke
+ public Object inBeanInterceptor(InvocationContext ctx) throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(ctx);
+ setContextData(ctxData);
+
+ return ctx.proceed();
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept postConstruct of the bean
+ *
+ * @throws runtime exceptions.
+ */
+ @PostConstruct
+ public void inBeanInterceptorPostConstruct() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+
+ /**
+ * The interceptor method.
+ * This should intercept preDestroy of the bean.
+ *
+ * @throws runtime exceptions.
+ */
+ @PreDestroy
+ public void inBeanInterceptorPreDestroy() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+}
Added: openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/StatelessInterceptedBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/StatelessInterceptedBean.java?view=auto&rev=548273
==============================================================================
--- openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/StatelessInterceptedBean.java (added)
+++ openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/StatelessInterceptedBean.java Mon Jun 18 02:23:25 2007
@@ -0,0 +1,134 @@
+/**
+ * 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.openejb.test.stateless;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+import org.apache.openejb.test.SuperInterceptedBean;
+import org.apache.openejb.test.interceptor.ClassInterceptor;
+import org.apache.openejb.test.interceptor.Interceptor;
+import org.apache.openejb.test.interceptor.MethodInterceptor;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+@Stateless(name="StatelessIntercepted")
+@Interceptors({ClassInterceptor.class})
+public class StatelessInterceptedBean extends SuperInterceptedBean
+ implements BasicStatelessInterceptedLocal, BasicStatelessInterceptedRemote {
+
+ private static Map<String, Object> contextData = new HashMap<String, Object>();
+
+ /**
+ * A simple dummy business method to concat 2 strings
+ * @see org.apache.openejb.test.stateless.BasicStatelessInterceptedLocal#concat(java.lang.String, java.lang.String)
+ */
+ public String concat(String str1, String str2) {
+ return str1.concat(str2);
+ }
+
+ /**
+ * A simple dummy busines method to reverse a string
+ * @see org.apache.openejb.test.stateless.BasicStatelessInterceptedLocal#reverse(java.lang.String)
+ */
+ @Interceptors({MethodInterceptor.class})
+ public String reverse(String str) {
+ System.out.println("Reversing " + str);
+ StringBuffer b = new StringBuffer(str);
+ return b.reverse().toString();
+ }
+
+ /**
+ * @param contextData the contextData to set
+ */
+ private void setContextData(Map<String, Object> ctxData) {
+ StatelessInterceptedBean.contextData.putAll(ctxData);
+ }
+
+ /**
+ * <code>ClassInterceptor</code> should not intercept this.
+ *
+ * @return the contextData
+ */
+ @ExcludeDefaultInterceptors
+ @ExcludeClassInterceptors
+ public Map<String, Object> getContextData() {
+ return contextData;
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept all business methods in this bean class.
+ * It cannot exclude even those annotated with <code>@ExcludeClassInterceptors</code>
+ *
+ * @param ctx - InvocationContext
+ *
+ * @return - the result of the next method invoked. If a method returns void, proceed returns null.
+ * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class,
+ * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned.
+ * If there is more than one such interceptor method, the invocation of proceed causes the container to execute those methods in order.
+ *
+ * @throws runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
+ */
+ @AroundInvoke
+ public Object inBeanInterceptor(InvocationContext ctx) throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(ctx);
+ setContextData(ctxData);
+
+ return ctx.proceed();
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept postConstruct of the bean
+ *
+ * @throws runtime exceptions.
+ */
+ @PostConstruct
+ public void inBeanInterceptorPostConstruct() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+
+ /**
+ * The interceptor method.
+ * This should intercept preDestroy of the bean.
+ *
+ * @throws runtime exceptions.
+ */
+ @PreDestroy
+ public void inBeanInterceptorPreDestroy() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+}
Added: openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/ThirdStatelessInterceptedBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/ThirdStatelessInterceptedBean.java?view=auto&rev=548273
==============================================================================
--- openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/ThirdStatelessInterceptedBean.java (added)
+++ openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/java/org/apache/openejb/test/stateless/ThirdStatelessInterceptedBean.java Mon Jun 18 02:23:25 2007
@@ -0,0 +1,133 @@
+/**
+ * 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.openejb.test.stateless;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.Interceptors;
+import javax.interceptor.InvocationContext;
+
+import org.apache.openejb.test.SuperInterceptedBean;
+import org.apache.openejb.test.interceptor.ClassInterceptor;
+import org.apache.openejb.test.interceptor.Interceptor;
+import org.apache.openejb.test.interceptor.MethodInterceptor;
+import org.apache.openejb.test.interceptor.SecondClassInterceptor;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+@Stateless(name="ThirdStatelessIntercepted")
+@Interceptors({ClassInterceptor.class, SecondClassInterceptor.class})
+public class ThirdStatelessInterceptedBean extends SuperInterceptedBean
+ implements BasicStatelessInterceptedLocal, BasicStatelessInterceptedRemote {
+
+ private static Map<String, Object> contextData = new HashMap<String, Object>();
+
+ /**
+ * A simple dummy business method to concat 2 strings
+ * @see org.apache.openejb.test.stateless.BasicStatelessInterceptedLocal#concat(java.lang.String, java.lang.String)
+ */
+ public String concat(String str1, String str2) {
+ return str1.concat(str2);
+ }
+
+ /**
+ * A simple dummy busines method to reverse a string
+ * @see org.apache.openejb.test.stateless.BasicStatelessInterceptedLocal#reverse(java.lang.String)
+ */
+ @Interceptors({MethodInterceptor.class})
+ public String reverse(String str) {
+ System.out.println("Reversing " + str);
+ StringBuffer b = new StringBuffer(str);
+ return b.reverse().toString();
+ }
+
+ /**
+ * @param contextData the contextData to set
+ */
+ private void setContextData(Map<String, Object> ctxData) {
+ ThirdStatelessInterceptedBean.contextData.putAll(ctxData);
+ }
+
+ /**
+ * <code>ClassInterceptor</code> should not intercept this.
+ *
+ * @return the contextData
+ */
+ @ExcludeClassInterceptors
+ public Map<String, Object> getContextData() {
+ return contextData;
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept all business methods in this bean class.
+ * It cannot exclude even those annotated with <code>@ExcludeClassInterceptors</code>
+ *
+ * @param ctx - InvocationContext
+ *
+ * @return - the result of the next method invoked. If a method returns void, proceed returns null.
+ * For lifecycle callback interceptor methods, if there is no callback method defined on the bean class,
+ * the invocation of proceed in the last interceptor method in the chain is a no-op, and null is returned.
+ * If there is more than one such interceptor method, the invocation of proceed causes the container to execute those methods in order.
+ *
+ * @throws runtime exceptions or application exceptions that are allowed in the throws clause of the business method.
+ */
+ @AroundInvoke
+ public Object inBeanInterceptor(InvocationContext ctx) throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(ctx);
+ setContextData(ctxData);
+
+ return ctx.proceed();
+ }
+
+ /**
+ * The interceptor method.
+ * This should intercept postConstruct of the bean
+ *
+ * @throws runtime exceptions.
+ */
+ @PostConstruct
+ public void inBeanInterceptorPostConstruct() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+
+ /**
+ * The interceptor method.
+ * This should intercept preDestroy of the bean.
+ *
+ * @throws runtime exceptions.
+ */
+ @PreDestroy
+ public void inBeanInterceptorPreDestroy() throws Exception {
+ Map<String, Object> ctxData = Interceptor.profile(this);
+ setContextData(ctxData);
+ return;
+ }
+
+}
Added: openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/resources/META-INF/ejb-jar.xml?view=auto&rev=548273
==============================================================================
--- openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/resources/META-INF/ejb-jar.xml (added)
+++ openejb/trunk/openejb3/itests/openejb-itests-interceptor-beans/src/main/resources/META-INF/ejb-jar.xml Mon Jun 18 02:23:25 2007
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<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" metadata-complete="true">
+
+ <description>
+ This ejb-jar file contains assembled enterprise beans that are
+ part of employee self-service application.
+ </description>
+
+ <interceptors>
+ <interceptor>
+ <interceptor-class>
+ org.apache.openejb.test.interceptor.DefaultInterceptor
+ </interceptor-class>
+ </interceptor>
+ </interceptors>
+
+ <assembly-descriptor>
+
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+ <interceptor-class>
+ org.apache.openejb.test.interceptor.DefaultInterceptor
+ </interceptor-class>
+ </interceptor-binding>
+
+ <!--<interceptor-binding>
+ <ejb-name>SecondStatelessIntercepted</ejb-name>
+ <exclude-default-interceptors>
+ true
+ </exclude-default-interceptors>
+ </interceptor-binding>
+
+ --><interceptor-binding>
+ <ejb-name>SecondStatefulIntercepted</ejb-name>
+ <exclude-default-interceptors>
+ true
+ </exclude-default-interceptors>
+ </interceptor-binding>
+
+ <interceptor-binding>
+ <ejb-name>ThirdStatelessIntercepted</ejb-name>
+ <exclude-default-interceptors>
+ true
+ </exclude-default-interceptors>
+ <method>
+ <method-name>getContextData</method-name>
+ </method>
+ </interceptor-binding>
+
+ <interceptor-binding>
+ <ejb-name>ThirdStatefulIntercepted</ejb-name>
+ <exclude-default-interceptors>
+ true
+ </exclude-default-interceptors>
+ <method>
+ <method-name>getContextData</method-name>
+ </method>
+ </interceptor-binding>
+
+ </assembly-descriptor>
+</ejb-jar>