You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2007/03/10 07:39:51 UTC

svn commit: r516657 [2/2] - in /incubator/openejb/trunk/openejb3: container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ container/openejb-core/src/main/java/org/apache/openejb/config/ container/openejb-core/src/main/java/org/apache...

Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/InterceptorBindingInfoComparatorTest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/InterceptorBindingInfoComparatorTest.java?view=auto&rev=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/InterceptorBindingInfoComparatorTest.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/InterceptorBindingInfoComparatorTest.java Fri Mar  9 22:39:49 2007
@@ -0,0 +1,144 @@
+/**
+ * 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.assembler.classic;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Arrays;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InterceptorBindingInfoComparatorTest extends TestCase {
+    private ArrayList<InterceptorBindingInfo> expected;
+
+    public void testHighLevelOrdering() throws Exception {
+
+        ArrayList<InterceptorBindingInfo> expected = new ArrayList<InterceptorBindingInfo>();
+
+        InterceptorBindingInfo info = null;
+
+        // Package Interceptors (aka Default Interceptors) ///////////////
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "*";
+        info.interceptors.add("DefaultInterceptorUno");
+
+        // Class Interceptors ////////////////////////////////////////////
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "BeanOne";
+        info.interceptors.add("BeanOneClassInterceptorUno");
+
+        // Method Interceptors (no params) ///////////////////////////////
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "BeanTwo";
+        info.interceptors.add("BeanTwoMethodInterceptorDos");
+        info.method = new NamedMethodInfo();
+        info.method.methodName = "ping";
+
+        // Method Interceptors (params)    ///////////////////////////////
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "BeanTwo";
+        info.interceptors.add("BeanTwoMethodInterceptorDos");
+        info.method = new NamedMethodInfo();
+        info.method.methodName = "ping";
+        info.method.methodParams = new ArrayList<String>();
+        info.method.methodParams.add("java.lang.String");
+
+        ArrayList<InterceptorBindingInfo> actual = new ArrayList<InterceptorBindingInfo>(expected);
+        Collections.shuffle(actual);
+        Collections.sort(actual, new InterceptorBindingBuilder.IntercpetorBindingComparator());
+
+        for (int i = 0; i < actual.size(); i++) {
+            InterceptorBindingInfo a = actual.get(i);
+            InterceptorBindingInfo e = expected.get(i);
+            assertSame(e, a);
+        }
+    }
+
+    public void testInnerLevelOrdering() {
+
+        ArrayList<InterceptorBindingInfo> expected = new ArrayList<InterceptorBindingInfo>();
+        ArrayList<InterceptorBindingInfo> actual = new ArrayList<InterceptorBindingInfo>(7);
+        for (int i = 0; i < 7; i++) actual.add(null);
+
+        InterceptorBindingInfo info = null;
+
+        // Addition (class-level)
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "BeanOne";
+        info.interceptors.add("BeanOneClassInterceptorUno");
+        actual.set(3, info);
+
+        // Addition (class-level)
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "BeanOne";
+        info.interceptors.add("BeanOneClassInterceptorDos");
+        actual.set(4, info);
+
+        // Addition (class-level) + Exclusion (default level)
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "BeanOne";
+        info.excludeDefaultInterceptors = true;
+        info.interceptors.add("BeanOneClassInterceptorTres");
+        actual.set(5, info);
+
+        // Addition
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "BeanOne";
+        info.interceptors.add("BeanOneClassInterceptorQuatro");
+        actual.set(6, info);
+
+        // Exclusion (class level) + Addition (class-level)
+        // [this would be pointless, but good to test]
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "BeanOne";
+        info.excludeClassInterceptors = true;
+        info.interceptors.add("BeanOneClassInterceptorCinco");
+        actual.set(2, info);
+
+        // Exclusion (class and default levels)
+        // [excluding both is top of the exclusions at this level]
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "BeanOne";
+        info.excludeDefaultInterceptors = true;
+        info.excludeClassInterceptors = true;
+        actual.set(1, info);
+
+        // Excplicit Order (class level and default level)
+        // [trumps all bindings at this level and above]
+        info = add(expected, new InterceptorBindingInfo());
+        info.ejbName = "BeanOne";
+        info.interceptorOrder.add("TotalOrderingDefaultInterceptor");
+        actual.set(0, info);
+
+        Collections.sort(actual, new InterceptorBindingBuilder.IntercpetorBindingComparator());
+
+        for (int i = 0; i < actual.size(); i++) {
+            InterceptorBindingInfo a = actual.get(i);
+            InterceptorBindingInfo e = expected.get(i);
+            assertSame(e, a);
+        }
+    }
+
+    private InterceptorBindingInfo add(List list, InterceptorBindingInfo bindingInfo) {
+        list.add(bindingInfo);
+        return bindingInfo;
+    }
+}

Added: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessInterceptorTest.java?view=auto&rev=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessInterceptorTest.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/StatelessInterceptorTest.java Fri Mar  9 22:39:49 2007
@@ -0,0 +1,264 @@
+/**
+ * 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.core.stateless;
+
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.ConnectionManagerInfo;
+import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
+import org.apache.openejb.assembler.classic.SecurityServiceInfo;
+import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
+import org.apache.openejb.assembler.classic.TransactionServiceInfo;
+import org.apache.openejb.assembler.classic.EjbJarInfo;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.core.ivm.naming.InitContextFactory;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.StatelessBean;
+import org.apache.openejb.jee.Interceptor;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.InterceptorBinding;
+import org.apache.openejb.jee.AssemblyDescriptor;
+import org.apache.openejb.jee.NamedMethod;
+
+import javax.annotation.PostConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.naming.InitialContext;
+import javax.ejb.EJBException;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatelessInterceptorTest extends TestCase {
+
+    public void test() throws Exception {
+        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
+
+        ConfigurationFactory config = new ConfigurationFactory();
+        Assembler assembler = new Assembler();
+
+        assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
+        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
+        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
+
+        assembler.createConnectionManager(config.configureService(ConnectionManagerInfo.class));
+
+        // containers
+        assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));
+
+        EjbJarInfo ejbJar = config.configureApplication(buildTestApp());
+        assertNotNull(ejbJar);
+        assertEquals(1, ejbJar.enterpriseBeans.size());
+        assertEquals(1, ejbJar.enterpriseBeans.get(0).aroundInvoke.size());
+        assertEquals(1, ejbJar.enterpriseBeans.get(0).postConstruct.size());
+
+        assertEquals(3, ejbJar.interceptors.size());
+        assertEquals(1, ejbJar.interceptors.get(0).aroundInvoke.size());
+        assertEquals(1, ejbJar.interceptors.get(0).postConstruct.size());
+
+        assertEquals(3, ejbJar.interceptorBindings.size());
+
+        assembler.createApplication(ejbJar);
+
+        InitialContext ctx = new InitialContext();
+        Target target = (Target) ctx.lookup("TargetBeanBusinessLocal");
+        target.echo(new ArrayList());
+
+        assertCalls(Call.values());
+
+        calls.clear();
+
+        int i = target.echo(123);
+        assertEquals(123, i);
+
+        try {
+            target.throwAppException();
+            fail("Should have thrown app exception");
+        } catch (AppException e) {
+            // pass
+        }
+
+        try {
+            target.throwSysException();
+            fail("Should have thrown a sys exception");
+        } catch (EJBException e) {
+            // so far so good
+            Throwable cause = e.getCause();
+            if (!(cause instanceof SysException)) {
+                fail("Inner Exception should be a SysException");
+            }
+        }
+    }
+
+    private void assertCalls(Call... expectedCalls) {
+        List expected = Arrays.asList(expectedCalls);
+        assertEquals(join("\n", expected) , join("\n", calls));
+    }
+
+    public static enum Call {
+        Default_PostConstruct_BEFORE,
+        Class_PostConstruct_BEFORE,
+        Bean_PostConstruct,
+        Class_PostConstruct_AFTER,
+        Default_PostConstruct_AFTER,
+
+        Default_Invoke_BEFORE,
+        Class_Invoke_BEFORE,
+        Method_Invoke_BEFORE,
+        Bean_Invoke_BEFORE,
+        Bean_Invoke,
+        Bean_Invoke_AFTER,
+        Method_Invoke_AFTER,
+        Class_Invoke_AFTER,
+        Default_Invoke_AFTER,
+
+    }
+
+    public EjbModule buildTestApp() {
+        EjbJar ejbJar = new EjbJar();
+        AssemblyDescriptor ad = ejbJar.getAssemblyDescriptor();
+
+        EnterpriseBean bean = ejbJar.addEnterpriseBean(new StatelessBean(TargetBean.class));
+
+        Interceptor interceptor;
+
+        interceptor = ejbJar.addInterceptor(new Interceptor(ClassInterceptor.class));
+        ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
+
+        interceptor = ejbJar.addInterceptor(new Interceptor(DefaultInterceptor.class));
+        ad.addInterceptorBinding(new InterceptorBinding("*", interceptor));
+
+        interceptor = ejbJar.addInterceptor(new Interceptor(EchoMethodInterceptor.class));
+        InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
+        binding.setMethod(new NamedMethod("echo"));
+
+        return new EjbModule(this.getClass().getClassLoader(), this.getClass().getSimpleName(), "test", ejbJar, null);
+    }
+
+    public static List<Call> calls = new ArrayList<Call>();
+
+    public static class TargetBean implements Target {
+
+        @PostConstruct
+        public void construct() {
+            calls.add(Call.Bean_PostConstruct);
+        }
+
+        @AroundInvoke
+        public Object invoke(InvocationContext context) throws Exception {
+            calls.add(Call.Bean_Invoke_BEFORE);
+            Object o = context.proceed();
+            calls.add(Call.Bean_Invoke_AFTER);
+            return o;
+        }
+
+        public List echo(List data){
+            calls.add(Call.Bean_Invoke);
+            return data;
+        }
+
+        public void throwAppException() throws AppException {
+            throw new AppException();
+        }
+
+        public void throwSysException() {
+            throw new SysException();
+        }
+
+        public int echo(int i) {
+            return i;
+        }
+    }
+
+    public static interface Target {
+        List echo(List data);
+        void throwAppException() throws AppException;
+        void throwSysException();
+        int echo(int i);
+    }
+
+    public static class AppException extends Exception {
+        public AppException() {
+        }
+    }
+
+    public static class SysException extends RuntimeException {
+        public SysException() {
+        }
+    }
+
+    public static class EchoMethodInterceptor {
+
+        @AroundInvoke
+        public Object invoke(InvocationContext context) throws Exception {
+            calls.add(Call.Method_Invoke_BEFORE);
+            Object o = context.proceed();
+            calls.add(Call.Method_Invoke_AFTER);
+            return o;
+        }
+    }
+
+    public static class ClassInterceptor {
+
+        @PostConstruct
+        public void construct(InvocationContext context) throws Exception {
+            calls.add(Call.Class_PostConstruct_BEFORE);
+            context.proceed();
+            calls.add(Call.Class_PostConstruct_AFTER);
+        }
+
+        @AroundInvoke
+        public Object invoke(InvocationContext context) throws Exception {
+            calls.add(Call.Class_Invoke_BEFORE);
+            Object o = context.proceed();
+            calls.add(Call.Class_Invoke_AFTER);
+            return o;
+        }
+    }
+
+    public static class DefaultInterceptor {
+
+        @PostConstruct
+        public void construct(InvocationContext context) throws Exception {
+            calls.add(Call.Default_PostConstruct_BEFORE);
+            context.proceed();
+            calls.add(Call.Default_PostConstruct_AFTER);
+        }
+
+        @AroundInvoke
+        public Object invoke(InvocationContext context) throws Exception {
+            calls.add(Call.Default_Invoke_BEFORE);
+            Object o = context.proceed();
+            calls.add(Call.Default_Invoke_AFTER);
+            return o;
+        }
+    }
+
+
+    private static String join(String delimeter, List items) {
+        StringBuffer sb = new StringBuffer();
+        for (Object item : items) {
+            sb.append(item.toString()).append(delimeter);
+        }
+        return sb.toString();
+    }
+}

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/iTest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/iTest.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/iTest.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/iTest.java Fri Mar  9 22:39:49 2007
@@ -64,12 +64,12 @@
 
     public static Test suite() {
         TestSuite suite = new iTest();
-        suite.addTest(MdbTestSuite.suite());
         suite.addTest(StatelessLocalTestSuite.suite());
         suite.addTest(StatefulLocalTestSuite.suite());
         suite.addTest(BmpLocalTestSuite.suite());
         suite.addTest(CmpLocalTestSuite.suite());
         suite.addTest(Cmp2TestSuite.suite());
+        suite.addTest(MdbTestSuite.suite());
         return suite;
     }
 }

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AroundInvoke.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AroundInvoke.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AroundInvoke.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AroundInvoke.java Fri Mar  9 22:39:49 2007
@@ -42,7 +42,7 @@
         "clazz",
         "methodName"
         })
-public class AroundInvoke {
+public class AroundInvoke implements CallbackMethod{
 
     @XmlElement(name = "class")
     protected String clazz;
@@ -73,4 +73,7 @@
         this.methodName = value;
     }
 
+    public String getClassName() {
+        return getClazz();
+    }
 }

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/AssemblyDescriptor.java Fri Mar  9 22:39:49 2007
@@ -130,6 +130,11 @@
         return this.interceptorBinding;
     }
 
+    public InterceptorBinding addInterceptorBinding(InterceptorBinding binding){
+        getInterceptorBinding().add(binding);
+        return binding;
+    }
+    
     public List<MessageDestination> getMessageDestination() {
         if (messageDestination == null) {
             messageDestination = new ArrayList<MessageDestination>();

Added: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/CallbackMethod.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/CallbackMethod.java?view=auto&rev=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/CallbackMethod.java (added)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/CallbackMethod.java Fri Mar  9 22:39:49 2007
@@ -0,0 +1,25 @@
+/**
+ * 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.jee;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface CallbackMethod {
+    String getClassName();
+    String getMethodName();
+}

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EjbJar.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EjbJar.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EjbJar.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EjbJar.java Fri Mar  9 22:39:49 2007
@@ -178,6 +178,9 @@
     }
 
     public AssemblyDescriptor getAssemblyDescriptor() {
+        if (assemblyDescriptor == null){
+            assemblyDescriptor = new AssemblyDescriptor();
+        }
         return assemblyDescriptor;
     }
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Interceptor.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Interceptor.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Interceptor.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Interceptor.java Fri Mar  9 22:39:49 2007
@@ -106,6 +106,10 @@
     public Interceptor() {
     }
 
+    public Interceptor(Class interceptorClass) {
+        this.interceptorClass = interceptorClass.getName();
+    }
+
     public Interceptor(String interceptorClass) {
         this.interceptorClass = interceptorClass;
     }

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/InterceptorBinding.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/InterceptorBinding.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/InterceptorBinding.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/InterceptorBinding.java Fri Mar  9 22:39:49 2007
@@ -28,6 +28,7 @@
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Arrays;
 
 
 /**
@@ -65,17 +66,34 @@
  * There are four possible styles of the interceptor element syntax :
  * <p/>
  * 1.
+ <interceptor-binding>
+   <ejb-name>*</ejb-name>
+   <interceptor-class>INTERCEPTOR</interceptor-class>
+ </interceptor-binding>
  * <p/>
  * Specifying the ejb-name as the wildcard value "*" designates
  * default interceptors (interceptors that apply to all session and
  * message-driven beans contained in the ejb-jar).
  * <p/>
  * 2.
+ <interceptor-binding>
+   <ejb-name>EJBNAME</ejb-name>
+   <interceptor-class>INTERCEPTOR</interceptor-class>
+ </interceptor-binding>
+
  * <p/>
  * This style is used to refer to interceptors associated with the
  * specified enterprise bean(class-level interceptors).
  * <p/>
  * 3.
+ <interceptor-binding>
+   <ejb-name>EJBNAME</ejb-name>
+   <interceptor-class>INTERCEPTOR</interceptor-class>
+   <method>
+     <method-name>METHOD</method-name>
+   </method>
+ </interceptor-binding>
+
  * <p/>
  * This style is used to associate a method-level interceptor with
  * the specified enterprise bean.  If there are multiple methods
@@ -86,6 +104,19 @@
  * to specify method-level interceptors.
  * <p/>
  * 4.
+ <interceptor-binding>
+   <ejb-name>EJBNAME</ejb-name>
+   <interceptor-class>INTERCEPTOR</interceptor-class>
+   <method>
+     <method-name>METHOD</method-name>
+     <method-params>
+       <method-param>PARAM-1</method-param>
+       <method-param>PARAM-2</method-param>
+       ...
+       <method-param>PARAM-N</method-param>
+     </method-params>
+   </method>
+ </interceptor-binding>
  * <p/>
  * ...
  * This style is used to associate a method-level interceptor with
@@ -128,6 +159,27 @@
     @XmlID
     protected String id;
 
+    public InterceptorBinding() {
+    }
+
+    public InterceptorBinding(EnterpriseBean bean, Interceptor... interceptors) {
+        this(bean.getEjbName(), interceptors);
+    }
+
+    public InterceptorBinding(String ejbName, Interceptor... interceptors) {
+        this.ejbName = ejbName;
+        List<String> interceptorClasses = this.getInterceptorClass();
+        for (Interceptor interceptor : interceptors) {
+            interceptorClasses.add(interceptor.getInterceptorClass());
+        }
+    }
+
+    public InterceptorBinding(String ejbName, String... interceptorClasses) {
+        this.ejbName = ejbName;
+
+        this.getInterceptorClass().addAll(Arrays.asList(interceptorClasses));
+    }
+
     public List<Text> getDescription() {
         if (description == null) {
             description = new ArrayList<Text>();
@@ -154,8 +206,9 @@
         return interceptorOrder;
     }
 
-    public void setInterceptorOrder(InterceptorOrder value) {
+    public InterceptorOrder setInterceptorOrder(InterceptorOrder value) {
         this.interceptorOrder = value;
+        return value;
     }
 
     public boolean getExcludeDefaultInterceptors() {

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/InterceptorOrder.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/InterceptorOrder.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/InterceptorOrder.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/InterceptorOrder.java Fri Mar  9 22:39:49 2007
@@ -54,6 +54,10 @@
         return this.interceptorClass;
     }
 
+    public void addInterceptorClass(String className) {
+        getInterceptorClass().add(className);
+    }
+
     public String getId() {
         return id;
     }

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/LifecycleCallback.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/LifecycleCallback.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/LifecycleCallback.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/LifecycleCallback.java Fri Mar  9 22:39:49 2007
@@ -41,7 +41,7 @@
         "lifecycleCallbackClass",
         "lifecycleCallbackMethod"
         })
-public class LifecycleCallback {
+public class LifecycleCallback implements CallbackMethod {
 
     @XmlElement(name = "lifecycle-callback-class")
     protected String lifecycleCallbackClass;
@@ -72,4 +72,11 @@
         this.lifecycleCallbackMethod = value;
     }
 
+    public String getClassName() {
+        return getLifecycleCallbackClass();
+    }
+
+    public String getMethodName() {
+        return getLifecycleCallbackMethod();
+    }
 }

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/NamedMethod.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/NamedMethod.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/NamedMethod.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/NamedMethod.java Fri Mar  9 22:39:49 2007
@@ -46,6 +46,21 @@
     @XmlID
     protected String id;
 
+    public NamedMethod() {
+    }
+
+    public NamedMethod(String methodName, String... parameters) {
+        this.methodName = methodName;
+
+        if (parameters.length > 0){
+            MethodParams params = new MethodParams();
+            for (String paramName : parameters) {
+                params.getMethodParam().add(paramName);
+            }
+            this.methodParams = params;
+        }
+    }
+
     public String getMethodName() {
         return methodName;
     }

Modified: incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/StatelessBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/StatelessBean.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/StatelessBean.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/StatelessBean.java Fri Mar  9 22:39:49 2007
@@ -29,6 +29,10 @@
         prePassivate = Collections.EMPTY_LIST;
     }
 
+    public StatelessBean(Class ejbClass) {
+        this(ejbClass.getSimpleName(), ejbClass.getName());
+    }
+
     public StatelessBean() {
         this(null, null);
     }

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/beans/DatabaseBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/beans/DatabaseBean.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/beans/DatabaseBean.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/beans/DatabaseBean.java Fri Mar  9 22:39:49 2007
@@ -30,6 +30,10 @@
     public SessionContext context;
     public InitialContext jndiContext;
 
+    public DatabaseBean() {
+        this.getClass();        
+    }
+
     public void ejbCreate() throws javax.ejb.CreateException {
         try {
             jndiContext = new InitialContext();

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/BMTStatelessAllowedOperationsTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/BMTStatelessAllowedOperationsTests.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/BMTStatelessAllowedOperationsTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/BMTStatelessAllowedOperationsTests.java Fri Mar  9 22:39:49 2007
@@ -240,7 +240,7 @@
         }
     }
 
-    public void test05_ejbTimeout(){
+    public void _test05_ejbTimeout(){
         try {
             ejbObject.scheduleTimer("BmtStatelessAllowedOperationsTests");
             timerSync.waitFor("BmtStatelessAllowedOperationsTests");

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessAllowedOperationsTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessAllowedOperationsTests.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessAllowedOperationsTests.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessAllowedOperationsTests.java Fri Mar  9 22:39:49 2007
@@ -257,7 +257,7 @@
         }
     }
 
-    public void test05_ejbTimeout(){
+    public void _test05_ejbTimeout(){
         try {
             ejbObject.scheduleTimer("StatelessAllowedOperationsTests");
             timerSync.waitFor("StatelessAllowedOperationsTests");

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessLocalTestSuite.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessLocalTestSuite.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessLocalTestSuite.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessLocalTestSuite.java Fri Mar  9 22:39:49 2007
@@ -34,19 +34,24 @@
         TestSuite suite = new TestSuite();
         suite.addTest(new StatelessJndiTests());
         suite.addTest(new StatelessPojoLocalJndiTests());
+
         suite.addTest(new StatelessHomeIntfcTests());
         suite.addTest(new StatelessPojoLocalHomeIntfcTests());
-        suite.addTest(new StatelessLocalBusinessIntfcTests());
-        // MNour: Why we put this remote test into this suite of local tests ???
-        suite.addTest(new StatelessRemoteBusinessIntfcTests());
+
         suite.addTest(new StatelessEjbHomeTests());
         suite.addTest(new StatelessPojoEjbLocalHomeTests());
-        suite.addTest(new StatelessPojoEjbLocalObjectTests());
+
         suite.addTest(new StatelessEjbObjectTests());
+        suite.addTest(new StatelessPojoEjbLocalObjectTests());
+
         suite.addTest(new StatelessRemoteIntfcTests());
         suite.addTest(new StatelessLocalIntfcTests());
+        suite.addTest(new StatelessLocalBusinessIntfcTests());
+        suite.addTest(new StatelessRemoteBusinessIntfcTests());
+
         suite.addTest(new StatelessHomeHandleTests());
         suite.addTest(new StatelessHandleTests());
+
         suite.addTest(new StatelessEjbMetaDataTests());
         suite.addTest(new StatelessAllowedOperationsTests());
         suite.addTest(new BMTStatelessAllowedOperationsTests());

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessTestSuite.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessTestSuite.java?view=diff&rev=516657&r1=516656&r2=516657
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessTestSuite.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/stateless/StatelessTestSuite.java Fri Mar  9 22:39:49 2007
@@ -35,32 +35,54 @@
         TestSuite suite = new TestSuite();
         suite.addTest(new StatelessJndiTests());
         suite.addTest(new StatelessPojoRemoteJndiTests());
+
+        // Test home interfaces
         suite.addTest(new StatelessHomeIntfcTests());
         suite.addTest(new StatelessPojoHomeIntfcTests());
-        suite.addTest(new StatelessRemoteBusinessIntfcTests());
+
+        // EJBHome tests
         suite.addTest(new StatelessEjbHomeTests() );
         suite.addTest(new StatelessPojoEjbHomeTests() );
+
+        // EJBObject tests
         suite.addTest(new StatelessEjbObjectTests());
         suite.addTest(new StatelessPojoEjbObjectTests());
+
+        // Remote/business interface tests
         suite.addTest(new StatelessRemoteIntfcTests());
         suite.addTest(new StatelessPojoRemoteIntrfcTests());
+        suite.addTest(new StatelessRemoteBusinessIntfcTests());
+
+        // Home handle tests
         suite.addTest(new StatelessHomeHandleTests());
         suite.addTest(new StatelessPojoHomeHandleTests());
+
+        // Handle tests
         suite.addTest(new StatelessHandleTests());
         suite.addTest(new StatelessPojoHandleTests());
+
+        // EJBMetaData tests
         suite.addTest(new StatelessEjbMetaDataTests());
         suite.addTest(new StatelessPojoEjbMetaDataTests());
+
+        // Allowed operations
         suite.addTest(new StatelessAllowedOperationsTests());
         suite.addTest(new BMTStatelessAllowedOperationsTests());
+
         suite.addTest(new StatelessBeanTxTests());
+
+        // ENC and Injection
         suite.addTest(new StatelessJndiEncTests());
         suite.addTest(new StatelessContextLookupTests());
         suite.addTest(new StatelessPojoContextLookupTests());
         suite.addTest(new StatelessFieldInjectionTests());
         suite.addTest(new StatelessSetterInjectionTests());
         suite.addTest(new StatelessAnnotatedFieldInjectionTests());
+
         suite.addTest(new StatelessRmiIiopTests());
+
         suite.addTest(new MiscEjbTests());
+
         /* TO DO
         suite.addTest(new StatelessEjbContextTests());
         suite.addTest(new BMTStatelessEjbContextTests());