You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2012/11/27 17:47:42 UTC

svn commit: r1414258 [2/2] - in /openejb/trunk/openejb: container/openejb-core/src/test/java/org/apache/openejb/ container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ container/openejb-loader/src/main/java/org/apache/openejb/loader...

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/EncMdbBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/EncMdbBean.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/EncMdbBean.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/EncMdbBean.java Tue Nov 27 16:47:37 2012
@@ -55,17 +55,19 @@ public class EncMdbBean implements EncMd
 	private MessageDrivenContext mdbContext = null;
     private MdbInvoker mdbInvoker;
 
-    public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException {
+    @Override
+    public void setMessageDrivenContext(final MessageDrivenContext ctx) throws EJBException {
         this.mdbContext = ctx;
         try {
-            ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
+            final ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
             mdbInvoker = new MdbInvoker(connectionFactory, this);
         } catch (Exception e) {
             throw new EJBException(e);
         }
     }
 
-    public void onMessage(Message message) {
+    @Override
+    public void onMessage(final Message message) {
         try {
 //            System.out.println("\n" +
 //                    "***************************************\n" +
@@ -82,16 +84,17 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupEntityBean() throws TestFailureException {
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            BasicBmpHome home = (BasicBmpHome) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/bmp_entity"), BasicBmpHome.class );
+            final BasicBmpHome home = (BasicBmpHome) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/bmp_entity"), BasicBmpHome.class );
             Assert.assertNotNull("The EJBHome looked up is null",home);
 
-            BasicBmpObject object = home.createObject("Enc Bean");
+            final BasicBmpObject object = home.createObject("Enc Bean");
             Assert.assertNotNull("The EJBObject is null", object );
             } catch (Exception e){
                 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
@@ -101,16 +104,17 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupStatefulBean() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            BasicStatefulHome home = (BasicStatefulHome) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/stateful"), BasicStatefulHome.class );
+            final BasicStatefulHome home = (BasicStatefulHome) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/stateful"), BasicStatefulHome.class );
             Assert.assertNotNull("The EJBHome looked up is null",home);
 
-            BasicStatefulObject object = home.createObject("Enc Bean");
+            final BasicStatefulObject object = home.createObject("Enc Bean");
             Assert.assertNotNull("The EJBObject is null", object );
             } catch (Exception e){
                 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
@@ -120,16 +124,17 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupStatelessBean() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            BasicStatelessHome home = (BasicStatelessHome) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/stateless"), BasicStatelessHome.class );
+            final BasicStatelessHome home = (BasicStatelessHome) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/stateless"), BasicStatelessHome.class );
             Assert.assertNotNull("The EJBHome looked up is null",home);
 
-            BasicStatelessObject object = home.createObject();
+            final BasicStatelessObject object = home.createObject();
             Assert.assertNotNull("The EJBObject is null", object );
             } catch (Exception e){
                 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
@@ -139,14 +144,15 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupStatelessBusinessLocal() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-                Object o = ctx.lookup("java:comp/env/stateless/beanReferences/stateless-business-local");
-                BasicStatelessBusinessLocal object = (BasicStatelessBusinessLocal) o;
+                final Object o = ctx.lookup("java:comp/env/stateless/beanReferences/stateless-business-local");
+                final BasicStatelessBusinessLocal object = (BasicStatelessBusinessLocal) o;
             Assert.assertNotNull("The EJB BusinessLocal is null", object );
             } catch (Exception e){
                 e.printStackTrace();
@@ -157,13 +163,14 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupStatelessBusinessRemote() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/stateless-business-remote"), BasicStatelessBusinessRemote.class );
+            final BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/stateless-business-remote"), BasicStatelessBusinessRemote.class );
             Assert.assertNotNull("The EJB BusinessRemote is null", object );
             } catch (Exception e){
                 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
@@ -173,13 +180,14 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupStatefulBusinessLocal() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/stateful-business-local"), BasicStatefulBusinessLocal.class );
+            final BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/stateful-business-local"), BasicStatefulBusinessLocal.class );
             Assert.assertNotNull("The EJB BusinessLocal is null", object );
             } catch (Exception e){
                 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
@@ -189,13 +197,14 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupStatefulBusinessRemote() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/stateful-business-remote"), BasicStatefulBusinessRemote.class );
+            final BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) javax.rmi.PortableRemoteObject.narrow( ctx.lookup("java:comp/env/stateless/beanReferences/stateful-business-remote"), BasicStatefulBusinessRemote.class );
             Assert.assertNotNull("The EJB BusinessRemote is null", object );
             } catch (Exception e){
                 Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
@@ -205,14 +214,15 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupStringEntry() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            String expected = new String("1");
-            String actual   = (String)ctx.lookup("java:comp/env/stateless/references/String");
+            final String expected = "1";
+            final String actual   = (String)ctx.lookup("java:comp/env/stateless/references/String");
 
             Assert.assertNotNull("The String looked up is null", actual );
             Assert.assertEquals(expected, actual );
@@ -225,14 +235,15 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupDoubleEntry() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            Double expected = new Double(1.0D);
-            Double actual   = (Double)ctx.lookup("java:comp/env/stateless/references/Double");
+            final Double expected = 1.0D;
+            final Double actual   = (Double)ctx.lookup("java:comp/env/stateless/references/Double");
 
             Assert.assertNotNull("The Double looked up is null", actual );
             Assert.assertEquals(expected, actual );
@@ -245,14 +256,15 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupLongEntry() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            Long expected = new Long(1L);
-            Long actual   = (Long)ctx.lookup("java:comp/env/stateless/references/Long");
+            final Long expected = 1L;
+            final Long actual   = (Long)ctx.lookup("java:comp/env/stateless/references/Long");
 
             Assert.assertNotNull("The Long looked up is null", actual );
             Assert.assertEquals(expected, actual );
@@ -265,14 +277,15 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupFloatEntry() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            Float expected = new Float(1.0F);
-            Float actual   = (Float)ctx.lookup("java:comp/env/stateless/references/Float");
+            final Float expected = 1.0F;
+            final Float actual   = (Float)ctx.lookup("java:comp/env/stateless/references/Float");
 
             Assert.assertNotNull("The Float looked up is null", actual );
             Assert.assertEquals(expected, actual );
@@ -285,14 +298,15 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupIntegerEntry() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            Integer expected = new Integer(1);
-            Integer actual   = (Integer)ctx.lookup("java:comp/env/stateless/references/Integer");
+            final Integer expected = 1;
+            final Integer actual   = (Integer)ctx.lookup("java:comp/env/stateless/references/Integer");
 
             Assert.assertNotNull("The Integer looked up is null", actual );
             Assert.assertEquals(expected, actual );
@@ -305,14 +319,15 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupShortEntry() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            Short expected = new Short((short)1);
-            Short actual   = (Short)ctx.lookup("java:comp/env/stateless/references/Short");
+            final Short expected = (short) 1;
+            final Short actual   = (Short)ctx.lookup("java:comp/env/stateless/references/Short");
 
             Assert.assertNotNull("The Short looked up is null", actual );
             Assert.assertEquals(expected, actual );
@@ -325,14 +340,15 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupBooleanEntry() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            Boolean expected = new Boolean(true);
-            Boolean actual = (Boolean)ctx.lookup("java:comp/env/stateless/references/Boolean");
+            final Boolean expected = true;
+            final Boolean actual = (Boolean)ctx.lookup("java:comp/env/stateless/references/Boolean");
 
             Assert.assertNotNull("The Boolean looked up is null", actual );
             Assert.assertEquals(expected, actual );
@@ -345,14 +361,15 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupByteEntry() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            Byte expected = new Byte((byte)1);
-            Byte actual   = (Byte)ctx.lookup("java:comp/env/stateless/references/Byte");
+            final Byte expected = (byte) 1;
+            final Byte actual   = (Byte)ctx.lookup("java:comp/env/stateless/references/Byte");
 
             Assert.assertNotNull("The Byte looked up is null", actual );
             Assert.assertEquals(expected, actual );
@@ -365,14 +382,15 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupCharacterEntry() throws TestFailureException{
         try{
             try{
-            InitialContext ctx = new InitialContext();
+            final InitialContext ctx = new InitialContext();
             Assert.assertNotNull("The InitialContext is null", ctx );
 
-            Character expected = new Character('D');
-            Character actual   = (Character)ctx.lookup("java:comp/env/stateless/references/Character");
+            final Character expected = 'D';
+            final Character actual   = (Character)ctx.lookup("java:comp/env/stateless/references/Character");
 
             Assert.assertNotNull("The Character looked up is null", actual );
             Assert.assertEquals(expected, actual );
@@ -385,12 +403,13 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupResource() throws TestFailureException{
         try{
             try{
-                InitialContext ctx = new InitialContext();
+                final InitialContext ctx = new InitialContext();
                 Assert.assertNotNull("The InitialContext is null", ctx);
-                Object obj = ctx.lookup("java:comp/env/datasource");
+                final Object obj = ctx.lookup("java:comp/env/datasource");
                 Assert.assertNotNull("The DataSource is null", obj);
                 Assert.assertTrue("Not an instance of DataSource", obj instanceof DataSource);
             } catch (Exception e){
@@ -401,27 +420,28 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupJMSConnectionFactory() throws TestFailureException{
         try{
             try{
-                InitialContext ctx = new InitialContext();
+                final InitialContext ctx = new InitialContext();
                 Assert.assertNotNull("The InitialContext is null", ctx);
                 Object obj = ctx.lookup("java:comp/env/jms");
                 Assert.assertNotNull("The JMS ConnectionFactory is null", obj);
                 Assert.assertTrue("Not an instance of ConnectionFactory", obj instanceof ConnectionFactory);
-                ConnectionFactory connectionFactory = (ConnectionFactory) obj;
+                final ConnectionFactory connectionFactory = (ConnectionFactory) obj;
                 testJmsConnection(connectionFactory.createConnection());
 
                 obj = ctx.lookup("java:comp/env/TopicCF");
                 Assert.assertNotNull("The JMS TopicConnectionFactory is null", obj);
                 Assert.assertTrue("Not an instance of TopicConnectionFactory", obj instanceof TopicConnectionFactory);
-                TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj;
+                final TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj;
                 testJmsConnection(topicConnectionFactory.createConnection());
 
                 obj = ctx.lookup("java:comp/env/QueueCF");
                 Assert.assertNotNull("The JMS QueueConnectionFactory is null", obj);
                 Assert.assertTrue("Not an instance of QueueConnectionFactory", obj instanceof QueueConnectionFactory);
-                QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
+                final QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
                 testJmsConnection(queueConnectionFactory.createConnection());
             } catch (Exception e){
                 e.printStackTrace();
@@ -432,22 +452,23 @@ public class EncMdbBean implements EncMd
         }
     }
 
-    private void testJmsConnection(javax.jms.Connection connection) throws JMSException {
-        Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-        Topic topic = session.createTopic("test");
-        MessageProducer producer = session.createProducer(topic);
+    private void testJmsConnection(final javax.jms.Connection connection) throws JMSException {
+        final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+        final Topic topic = session.createTopic("test");
+        final MessageProducer producer = session.createProducer(topic);
         producer.send(session.createMessage());
         producer.close();
         session.close();
         connection.close();
     }
 
+    @Override
     public void lookupPersistenceUnit() throws TestFailureException{
         try{
             try{
-                InitialContext ctx = new InitialContext();
+                final InitialContext ctx = new InitialContext();
                 Assert.assertNotNull("The InitialContext is null", ctx);
-                EntityManagerFactory emf = (EntityManagerFactory)ctx.lookup("java:comp/env/persistence/TestUnit");
+                final EntityManagerFactory emf = (EntityManagerFactory)ctx.lookup("java:comp/env/persistence/TestUnit");
                 Assert.assertNotNull("The EntityManagerFactory is null", emf );
 
             } catch (Exception e){
@@ -458,12 +479,13 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupPersistenceContext() throws TestFailureException{
         try{
             try{
-                InitialContext ctx = new InitialContext();
+                final InitialContext ctx = new InitialContext();
                 Assert.assertNotNull("The InitialContext is null", ctx);
-                EntityManager em = (EntityManager)ctx.lookup("java:comp/env/persistence/TestContext");
+                final EntityManager em = (EntityManager)ctx.lookup("java:comp/env/persistence/TestContext");
                 Assert.assertNotNull("The EntityManager is null", em);
 
                 // call a do nothing method to assure entity manager actually exists
@@ -476,18 +498,19 @@ public class EncMdbBean implements EncMd
         }
     }
 
+    @Override
     public void lookupMessageDrivenContext() throws TestFailureException{
         try{
             try{
-                InitialContext ctx = new InitialContext();
+                final InitialContext ctx = new InitialContext();
                 Assert.assertNotNull("The InitialContext is null", ctx);
 
                 // lookup in enc
-                MessageDrivenContext messageDrivenContext = (MessageDrivenContext)ctx.lookup("java:comp/env/mdbcontext");
+                final MessageDrivenContext messageDrivenContext = (MessageDrivenContext)ctx.lookup("java:comp/env/mdbcontext");
                 Assert.assertNotNull("The SessionContext got from java:comp/env/mdbcontext is null", messageDrivenContext );
 
                 // lookup using global name
-                EJBContext ejbCtx = (EJBContext)ctx.lookup("java:comp/EJBContext");
+                final EJBContext ejbCtx = (EJBContext)ctx.lookup("java:comp/EJBContext");
                 Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx );
 
                 // verify context was set via legacy set method
@@ -504,6 +527,11 @@ public class EncMdbBean implements EncMd
     public void ejbCreate() throws javax.ejb.CreateException{
     }
 
+    @Override
     public void ejbRemove() throws EJBException {
+
+        if(null != mdbInvoker){
+            mdbInvoker.destroy();
+        }
     }
 }

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/FieldInjectionMdbBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/FieldInjectionMdbBean.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/FieldInjectionMdbBean.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/FieldInjectionMdbBean.java Tue Nov 27 16:47:37 2012
@@ -17,36 +17,34 @@
  */
 package org.apache.openejb.test.mdb;
 
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+import org.apache.openejb.test.TestFailureException;
 import org.apache.openejb.test.entity.bmp.BasicBmpHome;
-import org.apache.openejb.test.stateful.BasicStatefulHome;
 import org.apache.openejb.test.stateful.BasicStatefulBusinessLocal;
 import org.apache.openejb.test.stateful.BasicStatefulBusinessRemote;
-import org.apache.openejb.test.stateless.BasicStatelessHome;
+import org.apache.openejb.test.stateful.BasicStatefulHome;
 import org.apache.openejb.test.stateless.BasicStatelessBusinessLocal;
 import org.apache.openejb.test.stateless.BasicStatelessBusinessRemote;
-import org.apache.openejb.test.TestFailureException;
+import org.apache.openejb.test.stateless.BasicStatelessHome;
 
-import javax.annotation.PreDestroy;
 import javax.ejb.CreateException;
 import javax.ejb.EJBException;
 import javax.ejb.MessageDrivenBean;
 import javax.ejb.MessageDrivenContext;
-import javax.sql.DataSource;
 import javax.jms.ConnectionFactory;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.TopicConnectionFactory;
 import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.QueueConnectionFactory;
 import javax.jms.Session;
 import javax.jms.Topic;
-import javax.jms.MessageProducer;
-import javax.jms.MessageListener;
-import javax.jms.Message;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityManager;
+import javax.jms.TopicConnectionFactory;
 import javax.naming.InitialContext;
-
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
 
 public class FieldInjectionMdbBean implements EncMdbObject, MessageDrivenBean, MessageListener {
     private MessageDrivenContext ejbContext;
@@ -79,17 +77,19 @@ public class FieldInjectionMdbBean imple
     private MessageDrivenContext mdbContext = null;
     private MdbInvoker mdbInvoker;
 
-    public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException {
+    @Override
+    public void setMessageDrivenContext(final MessageDrivenContext ctx) throws EJBException {
         this.mdbContext = ctx;
         try {
-            ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
+            final ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
             mdbInvoker = new MdbInvoker(connectionFactory, this);
         } catch (Exception e) {
             throw new EJBException(e);
         }
     }
 
-    public void onMessage(Message message) {
+    @Override
+    public void onMessage(final Message message) {
         try {
 //            System.out.println("\n" +
 //                    "***************************************\n" +
@@ -109,6 +109,7 @@ public class FieldInjectionMdbBean imple
     public void ejbCreate() throws CreateException {
     }
 
+    @Override
     public void lookupEntityBean() throws TestFailureException {
         try {
             Assert.assertNotNull("The EJBObject is null", bmpHome);
@@ -117,6 +118,7 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupStatefulBean() throws TestFailureException {
         try {
             Assert.assertNotNull("The EJBObject is null", statefulHome);
@@ -125,6 +127,7 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupStatelessBean() throws TestFailureException {
         try {
             Assert.assertNotNull("The EJBObject is null", statelessHome);
@@ -133,41 +136,46 @@ public class FieldInjectionMdbBean imple
         }
     }
 
-    public void lookupStatelessBusinessLocal() throws TestFailureException{
-        try{
-            Assert.assertNotNull("The EJB BusinessLocal is null", statelessBusinessLocal );
-        } catch (AssertionFailedError afe){
+    @Override
+    public void lookupStatelessBusinessLocal() throws TestFailureException {
+        try {
+            Assert.assertNotNull("The EJB BusinessLocal is null", statelessBusinessLocal);
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatelessBusinessRemote() throws TestFailureException{
-        try{
-            Assert.assertNotNull("The EJB BusinessRemote is null", statelessBusinessRemote );
-        } catch (AssertionFailedError afe){
+    @Override
+    public void lookupStatelessBusinessRemote() throws TestFailureException {
+        try {
+            Assert.assertNotNull("The EJB BusinessRemote is null", statelessBusinessRemote);
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatefulBusinessLocal() throws TestFailureException{
-        try{
-            Assert.assertNotNull("The EJB BusinessLocal is null", statefulBusinessLocal );
-        } catch (AssertionFailedError afe){
+    @Override
+    public void lookupStatefulBusinessLocal() throws TestFailureException {
+        try {
+            Assert.assertNotNull("The EJB BusinessLocal is null", statefulBusinessLocal);
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatefulBusinessRemote() throws TestFailureException{
-        try{
-            Assert.assertNotNull("The EJB BusinessRemote is null", statefulBusinessRemote );
-        } catch (AssertionFailedError afe){
+    @Override
+    public void lookupStatefulBusinessRemote() throws TestFailureException {
+        try {
+            Assert.assertNotNull("The EJB BusinessRemote is null", statefulBusinessRemote);
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
+    @Override
     public void lookupStringEntry() throws TestFailureException {
         try {
-            String expected = new String("1");
+            final String expected = "1";
             Assert.assertNotNull("The String looked up is null", striing);
             Assert.assertEquals(expected, striing);
         } catch (AssertionFailedError afe) {
@@ -175,9 +183,10 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupDoubleEntry() throws TestFailureException {
         try {
-            Double expected = new Double(1.0D);
+            final Double expected = 1.0D;
 
             Assert.assertNotNull("The Double looked up is null", doouble);
             Assert.assertEquals(expected, doouble);
@@ -187,9 +196,10 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupLongEntry() throws TestFailureException {
         try {
-            Long expected = new Long(1L);
+            final Long expected = 1L;
 
             Assert.assertNotNull("The Long looked up is null", loong);
             Assert.assertEquals(expected, loong);
@@ -198,9 +208,10 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupFloatEntry() throws TestFailureException {
         try {
-            Float expected = new Float(1.0F);
+            final Float expected = 1.0F;
 
             Assert.assertNotNull("The Float looked up is null", flooat);
             Assert.assertEquals(expected, flooat);
@@ -209,9 +220,10 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupIntegerEntry() throws TestFailureException {
         try {
-            Integer expected = new Integer(1);
+            final Integer expected = 1;
 
             Assert.assertNotNull("The Integer looked up is null", inteeger);
             Assert.assertEquals(expected, inteeger);
@@ -221,9 +233,10 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupShortEntry() throws TestFailureException {
         try {
-            Short expected = new Short((short) 1);
+            final Short expected = (short) 1;
 
             Assert.assertNotNull("The Short looked up is null", shoort);
             Assert.assertEquals(expected, shoort);
@@ -232,9 +245,10 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupBooleanEntry() throws TestFailureException {
         try {
-            Boolean expected = new Boolean(true);
+            final Boolean expected = true;
 
             Assert.assertNotNull("The Boolean looked up is null", booolean);
             Assert.assertEquals(expected, booolean);
@@ -243,9 +257,10 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupByteEntry() throws TestFailureException {
         try {
-            Byte expected = new Byte((byte) 1);
+            final Byte expected = (byte) 1;
 
             Assert.assertNotNull("The Byte looked up is null", byyte);
             Assert.assertEquals(expected, byyte);
@@ -254,9 +269,10 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupCharacterEntry() throws TestFailureException {
         try {
-            Character expected = new Character('D');
+            final Character expected = 'D';
 
             Assert.assertNotNull("The Character looked up is null", chaaracter);
             Assert.assertEquals(expected, chaaracter);
@@ -265,6 +281,7 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupResource() throws TestFailureException {
         try {
             Assert.assertNotNull("The DataSource is null", daataSource);
@@ -273,31 +290,33 @@ public class FieldInjectionMdbBean imple
         }
     }
 
-    public void lookupJMSConnectionFactory() throws TestFailureException{
-        try{
-            try{
+    @Override
+    public void lookupJMSConnectionFactory() throws TestFailureException {
+        try {
+            try {
                 testJmsConnection(coonnectionFactory.createConnection());
                 testJmsConnection(queueCoonnectionFactory.createConnection());
                 testJmsConnection(topicCoonnectionFactory.createConnection());
-            } catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    private void testJmsConnection(javax.jms.Connection connection) throws JMSException {
-        Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-        Topic topic = session.createTopic("test");
-        MessageProducer producer = session.createProducer(topic);
+    private void testJmsConnection(final javax.jms.Connection connection) throws JMSException {
+        final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+        final Topic topic = session.createTopic("test");
+        final MessageProducer producer = session.createProducer(topic);
         producer.send(session.createMessage());
         producer.close();
         session.close();
         connection.close();
     }
 
+    @Override
     public void lookupPersistenceUnit() throws TestFailureException {
         try {
             Assert.assertNotNull("The EntityManagerFactory is null", emf);
@@ -306,6 +325,7 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupPersistenceContext() throws TestFailureException {
         try {
             Assert.assertNotNull("The EntityManager is null", em);
@@ -321,6 +341,7 @@ public class FieldInjectionMdbBean imple
         }
     }
 
+    @Override
     public void lookupMessageDrivenContext() throws TestFailureException {
         try {
             Assert.assertNotNull("The MessageDrivenContext is null", ejbContext);
@@ -330,6 +351,11 @@ public class FieldInjectionMdbBean imple
 
     }
 
+    @Override
     public void ejbRemove() throws EJBException {
+
+        if (null != mdbInvoker) {
+            mdbInvoker.destroy();
+        }
     }
 }

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/InterceptorMdbBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/InterceptorMdbBean.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/InterceptorMdbBean.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/InterceptorMdbBean.java Tue Nov 27 16:47:37 2012
@@ -18,8 +18,11 @@
 
 package org.apache.openejb.test.mdb;
 
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+import org.apache.openejb.test.TestFailureException;
+
 import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
 import javax.annotation.Resource;
 import javax.ejb.ActivationConfigProperty;
 import javax.ejb.EJBException;
@@ -34,19 +37,12 @@ import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
 import javax.jms.Session;
-import javax.naming.InitialContext;
-
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
 
-import org.apache.openejb.test.TestFailureException;
-
-@Interceptors ({MdbInterceptor.class})
+@Interceptors({MdbInterceptor.class})
 @MessageDriven(activationConfig = {
-        @ActivationConfigProperty(propertyName="destinationType", propertyValue = "javax.jms.Queue"),
-        @ActivationConfigProperty(propertyName="destination", propertyValue = "InterceptorMdbBean")})
+        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+        @ActivationConfigProperty(propertyName = "destination", propertyValue = "InterceptorMdbBean")})
 public class InterceptorMdbBean implements MessageListener, MessageDrivenBean {
 
     private boolean classLevelBusinessMethodInterception = false;
@@ -57,17 +53,18 @@ public class InterceptorMdbBean implemen
     private Session session;
     private Connection connection;
     protected MdbInvoker mdbInvoker;
-    @Resource(name="jms", type=javax.jms.QueueConnectionFactory.class)
+    @Resource(name = "jms", type = javax.jms.QueueConnectionFactory.class)
     private ConnectionFactory connectionFactory;
 
-    public void onMessage(Message msg) {
+    @Override
+    public void onMessage(final Message msg) {
         try {
             classLevelBusinessMethodInterception = msg.getBooleanProperty("ClassLevelBusinessMethodInterception");
             methodLevelBusinessMethodInterception = msg.getBooleanProperty("MethodLevelBusinessMethodInterception");
             try {
                 msg.acknowledge();
             } catch (JMSException e) {
-              e.printStackTrace();
+                e.printStackTrace();
             }
             mdbInvoker.onMessage(msg);
         } catch (Throwable e) {
@@ -76,23 +73,21 @@ public class InterceptorMdbBean implemen
     }
 
     @AroundInvoke
-    public Object mdbInterceptor(InvocationContext ctx) throws Exception
-    {
-       Object[] objArr = ctx.getParameters();
-       Message msg = (Message)objArr[0];
-       msg.setBooleanProperty("MethodLevelBusinessMethodInterception",true);
-       ctx.setParameters(objArr);
-       return ctx.proceed();
+    public Object aroundInvoke(final InvocationContext ctx) throws Exception {
+        final Object[] objArr = ctx.getParameters();
+        final Message msg = (Message) objArr[0];
+        msg.setBooleanProperty("MethodLevelBusinessMethodInterception", true);
+        ctx.setParameters(objArr);
+        return ctx.proceed();
     }
 
     @PostConstruct
-    public void ejbCreate() throws EJBException
-    {
+    public void ejbCreate() throws EJBException {
         methodLevelCreateMethodInterception = true;
     }
 
 
-    public void checkMethodLevelBusinessMethodInterception() throws TestFailureException{
+    public void checkMethodLevelBusinessMethodInterception() throws TestFailureException {
         try {
             Assert.assertTrue("Method Level Business Method Interception failed for Mdb", methodLevelBusinessMethodInterception);
         } catch (AssertionFailedError afe) {
@@ -100,7 +95,7 @@ public class InterceptorMdbBean implemen
         }
     }
 
-    public void checkMethodLevelCreateMethodInterception() throws TestFailureException{
+    public void checkMethodLevelCreateMethodInterception() throws TestFailureException {
         try {
             Assert.assertTrue("Method Level Business Method Interception failed for Mdb", methodLevelCreateMethodInterception);
         } catch (AssertionFailedError afe) {
@@ -109,7 +104,7 @@ public class InterceptorMdbBean implemen
     }
 
 
-    public void checkClassLevelBusinessMethodInterception() throws TestFailureException{
+    public void checkClassLevelBusinessMethodInterception() throws TestFailureException {
         try {
             Assert.assertTrue("Class Level Business Method Interception failed for Mdb", classLevelBusinessMethodInterception);
         } catch (AssertionFailedError afe) {
@@ -117,7 +112,7 @@ public class InterceptorMdbBean implemen
         }
     }
 
-    public void checkClassLevelCreateMethodInterception() throws TestFailureException{
+    public void checkClassLevelCreateMethodInterception() throws TestFailureException {
         try {
             Assert.assertTrue("Class Level Business Method Interception failed for Mdb", classLevelCreateMethodInterception);
         } catch (AssertionFailedError afe) {
@@ -126,12 +121,17 @@ public class InterceptorMdbBean implemen
     }
 
 
+    @Override
     public void ejbRemove() throws EJBException {
         // TODO Auto-generated method stub
 
+        if (null != mdbInvoker) {
+            mdbInvoker.destroy();
+        }
     }
 
-    public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException {
+    @Override
+    public void setMessageDrivenContext(final MessageDrivenContext ctx) throws EJBException {
         this.mdbContext = ctx;
         try {
             mdbInvoker = new MdbInvoker(connectionFactory, this);

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbInvoker.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbInvoker.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbInvoker.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbInvoker.java Tue Nov 27 16:47:37 2012
@@ -19,6 +19,7 @@ package org.apache.openejb.test.mdb;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
@@ -34,37 +35,56 @@ import java.util.Map;
 import java.util.TreeMap;
 
 public class MdbInvoker implements MessageListener {
+
     private final Map<String, Method> signatures = new TreeMap<String, Method>();
+    private final ConnectionFactory connectionFactory;
     private final Object target;
+
     private Connection connection;
     private Session session;
-    private ConnectionFactory connectionFactory;
+    private MessageProducer replyProducer = null;
+
+    public MdbInvoker(final ConnectionFactory connectionFactory, final Object target) throws JMSException {
 
-    public MdbInvoker(ConnectionFactory connectionFactory, Object target) throws JMSException {
-        this.target = target;
         this.connectionFactory = connectionFactory;
-        for (Method method : target.getClass().getMethods()) {
-            String signature = MdbUtil.getSignature(method);
+        this.target = target;
+
+        for (final Method method : target.getClass().getMethods()) {
+            final String signature = MdbUtil.getSignature(method);
             signatures.put(signature, method);
         }
     }
 
+    @Override
+    protected void finalize() throws Throwable {
+
+        try {
+            this.destroy();
+        } finally {
+            super.finalize();
+        }
+    }
+
     public synchronized void destroy() {
+        MdbUtil.close(replyProducer);
         MdbUtil.close(session);
         session = null;
         MdbUtil.close(connection);
         connection = null;
     }
 
-    private synchronized Session getSession() throws JMSException{
-        connection = connectionFactory.createConnection();
-        connection.start();
+    private synchronized Session getSession() throws JMSException {
+
+        this.connection = this.connectionFactory.createConnection();
+        this.connection.start();
+
         boolean isBeanManagedTransaction = false;
 
         try {
             new InitialContext().lookup("java:comp/UserTransaction");
             isBeanManagedTransaction = true;
         } catch (NamingException e) {
+            //Ignore - Not transacted
         }
 
         if (isBeanManagedTransaction) {
@@ -72,34 +92,43 @@ public class MdbInvoker implements Messa
         } else {
             session = connection.createSession(true, Session.SESSION_TRANSACTED);
         }
+
+        this.replyProducer = this.session.createProducer(null);
+        this.replyProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
         return session;
     }
 
-    public void onMessage(Message message) {
-        if (!(message instanceof ObjectMessage)) return;
+    @Override
+    public void onMessage(final Message message) {
 
         try {
-            Session session = getSession();
+
+            if (!(message instanceof ObjectMessage)) {
+                return;
+            }
+
+            final Session session = getSession();
             if (session == null) throw new IllegalStateException("Invoker has been destroyed");
 
             if (message == null) throw new NullPointerException("request message is null");
             if (!(message instanceof ObjectMessage)) throw new IllegalArgumentException("Expected a ObjectMessage request but got a " + message.getClass().getName());
-            ObjectMessage responseMessage = (ObjectMessage) message;
-            Serializable object = responseMessage.getObject();
+            final Serializable object = ((ObjectMessage) message).getObject();
             if (object == null) throw new NullPointerException("object in ObjectMessage is null");
             if (!(object instanceof Map)) {
-                if (message instanceof ObjectMessage) throw new IllegalArgumentException("Expected a Map contained in the ObjectMessage request but got a " + object.getClass().getName());
+                if (message instanceof ObjectMessage)
+                    throw new IllegalArgumentException("Expected a Map contained in the ObjectMessage request but got a " + object.getClass().getName());
             }
-            Map request = (Map) object;
+            final Map request = (Map) object;
 
-            String signature = (String) request.get("method");
+            final String signature = (String) request.get("method");
             if (signature == null) throw new NullPointerException("method property is null");
-            Method method = signatures.get(signature);
+            final Method method = signatures.get(signature);
             if (method == null) throw new IllegalArgumentException("no such method " + signature + "; known methods are " + signatures.keySet());
-            Object[] args = (Object[]) request.get("args");
+            final Object[] args = (Object[]) request.get("args");
 
             boolean exception = false;
-            Object result = null;
+            Object result;
             try {
                 result = method.invoke(target, args);
             } catch (IllegalAccessException e) {
@@ -109,39 +138,35 @@ public class MdbInvoker implements Messa
                 result = e.getCause();
                 if (result == null) result = e;
                 exception = true;
+            } catch (Exception e) {
+                result = e.getCause();
+                if (result == null) result = e;
+                exception = true;
             }
 
-            MessageProducer producer = null;
             try {
                 // create response
-                Map<String, Object> response = new TreeMap<String, Object>();
+                final Map<String, Object> response = new TreeMap<String, Object>();
                 if (exception) {
                     response.put("exception", "true");
                 }
                 response.put("return", result);
 
                 // create response message
-                ObjectMessage resMessage = session.createObjectMessage();
-                resMessage.setJMSCorrelationID(responseMessage.getJMSCorrelationID());
+                final ObjectMessage resMessage = session.createObjectMessage();
+                resMessage.setJMSCorrelationID(message.getJMSCorrelationID());
                 resMessage.setObject((Serializable) response);
 
                 // send response message
-                producer = session.createProducer(responseMessage.getJMSReplyTo());
-                producer.send(resMessage);
-//                System.out.println("\n" +
-//                        "***************************************\n" +
-//                        "Sent response message: " + responseMessage + "\n" +
-//                        "         response map: " + response + "\n" +
-//                        "             to queue: " + message.getJMSReplyTo() + "\n" +
-//                        "***************************************\n\n");
+                replyProducer.send(message.getJMSReplyTo(), resMessage);
+
             } catch (Exception e) {
                 e.printStackTrace();
-            } finally {
-                MdbUtil.close(producer);
-                destroy();
             }
         } catch (Throwable e) {
             e.printStackTrace();
+        } finally {
+            this.destroy();
         }
     }
 }

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbProxy.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbProxy.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbProxy.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbProxy.java Tue Nov 27 16:47:37 2012
@@ -17,63 +17,65 @@
  */
 package org.apache.openejb.test.mdb;
 
+import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
 import javax.jms.JMSException;
-import javax.jms.Connection;
-import javax.jms.Session;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
-import javax.jms.Destination;
-import javax.jms.DeliveryMode;
 import javax.jms.ObjectMessage;
-import javax.jms.MessageConsumer;
-import javax.jms.Message;
+import javax.jms.Session;
+import java.io.Serializable;
 import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.UUID;
-import java.io.Serializable;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 public class MdbProxy {
     @SuppressWarnings({"unchecked"})
-    public static <T> T newProxyInstance(Class<T> type, ConnectionFactory connectionFactory, String requestQueueName) throws JMSException {
+    public static <T> T newProxyInstance(final Class<T> type, final ConnectionFactory connectionFactory, final String requestQueueName) throws JMSException {
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
         if (classLoader == null) classLoader = type.getClassLoader();
         if (classLoader == null) classLoader = ClassLoader.getSystemClassLoader();
 
-        InvocationHandler invocationHandler = new MdbInvocationHandler(connectionFactory, requestQueueName);
-        Object proxy = Proxy.newProxyInstance(classLoader, new Class[]{type}, invocationHandler);
+        final InvocationHandler invocationHandler = new MdbInvocationHandler(connectionFactory, requestQueueName);
+        final Object proxy = Proxy.newProxyInstance(classLoader, new Class[]{type}, invocationHandler);
         return (T) proxy;
     }
 
     @SuppressWarnings({"unchecked"})
-    public static <T> T newProxyInstance(Class<T> type, ConnectionFactory connectionFactory, Destination requestQueue) throws JMSException {
+    public static <T> T newProxyInstance(final Class<T> type, final ConnectionFactory connectionFactory, final Destination requestQueue) throws JMSException {
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
         if (classLoader == null) classLoader = type.getClassLoader();
         if (classLoader == null) classLoader = ClassLoader.getSystemClassLoader();
 
-        InvocationHandler invocationHandler = new MdbInvocationHandler(connectionFactory, requestQueue);
-        Object proxy = Proxy.newProxyInstance(classLoader, new Class[]{type}, invocationHandler);
+        final InvocationHandler invocationHandler = new MdbInvocationHandler(connectionFactory, requestQueue);
+        final Object proxy = Proxy.newProxyInstance(classLoader, new Class[]{type}, invocationHandler);
         return (T) proxy;
     }
 
-    public static void destroyProxy(Object proxy) {
-        InvocationHandler handler = Proxy.getInvocationHandler(proxy);
-        if (handler instanceof MdbProxy) {
-            MdbInvocationHandler mdbInvocationHandler = (MdbInvocationHandler) handler;
+    public static void destroyProxy(final Object proxy) {
+        final InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+        if (MdbProxy.class.isInstance(handler)) {
+            final MdbInvocationHandler mdbInvocationHandler = (MdbInvocationHandler) handler;
             mdbInvocationHandler.destroy();
         }
     }
 
     private static class MdbInvocationHandler implements InvocationHandler {
-        private static final int MAX_RESPONSE_WAIT = 30000;
+        private static final int MAX_RESPONSE_WAIT = Integer.parseInt(System.getProperty("max.response.wait", "45000"));
         private Connection connection;
         private Session session;
         private MessageProducer producer;
-        private Destination requestQueue;
+        private final Destination requestQueue;
 
-        public MdbInvocationHandler(ConnectionFactory connectionFactory, String requestQueueName) throws JMSException {
+        public MdbInvocationHandler(final ConnectionFactory connectionFactory, final String requestQueueName) throws JMSException {
             // open a connection
             connection = connectionFactory.createConnection();
             connection.start();
@@ -89,7 +91,7 @@ public class MdbProxy {
             producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
         }
 
-        public MdbInvocationHandler(ConnectionFactory connectionFactory, Destination requestQueue) throws JMSException {
+        public MdbInvocationHandler(final ConnectionFactory connectionFactory, final Destination requestQueue) throws JMSException {
             this.requestQueue = requestQueue;
 
             // open a connection
@@ -121,70 +123,69 @@ public class MdbProxy {
             return producer;
         }
 
-        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-            Session session = getSession();
-            if (session == null) throw new IllegalStateException("Proxy has been destroyed");
+        @Override
+        public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+            final Session tempSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            if (tempSession == null) throw new IllegalStateException("Proxy has been destroyed");
 
             // create request
-            Map<String,Object> request = new TreeMap<String,Object>();
-            String signature = MdbUtil.getSignature(method);
+            final Map<String, Object> request = new TreeMap<String, Object>();
+            final String signature = MdbUtil.getSignature(method);
             request.put("method", signature);
             request.put("args", args);
 
             // create a new temp response queue and consumer
             // this is very inefficient, but eliminates a whole class of errors
-            Destination responseQueue = session.createTemporaryQueue();
-
-            // Create a messages
-            ObjectMessage requestMessage = session.createObjectMessage();
-            requestMessage.setJMSReplyTo(responseQueue);
-            String correlationId = UUID.randomUUID().toString();
-            requestMessage.setJMSCorrelationID(correlationId);
-            requestMessage.setObject((Serializable) request);
+            final String correlationId = UUID.randomUUID().toString();
 
+            //final Destination responseQueue = tempSession.createTemporaryQueue();
+            final Destination responseQueue = tempSession.createQueue(correlationId);
 
             // create a producer and consumers used to send requests and receive response
             MessageConsumer consumer = null;
             try {
-                // Send the request
-                getProducer().send(requestMessage);
 
-//                System.out.println("\n" + "***************************************\n" +
-//                        "Sent request message: " + requestMessage + "\n" +
-//                        "         request map: " + request + "\n" +
-//                        "            to queue: " + requestQueue + "\n" +
-//                        "***************************************\n\n");
-//
                 // Wait for a message
                 // Again this is quite inefficient
-                consumer = session.createConsumer(responseQueue);
+                consumer = tempSession.createConsumer(responseQueue);
+
+                // Create a message
+                final ObjectMessage requestMessage = tempSession.createObjectMessage();
+                requestMessage.setJMSReplyTo(responseQueue);
+                requestMessage.setJMSCorrelationID(correlationId);
+                requestMessage.setObject((Serializable) request);
+
+                // Send the request
+                getProducer().send(requestMessage);
 
                 // wait for the message
-                Message message = consumer.receive(MdbProxy.MdbInvocationHandler.MAX_RESPONSE_WAIT);
+                final Message message = consumer.receive(MdbProxy.MdbInvocationHandler.MAX_RESPONSE_WAIT);
 
                 // verify message
-                if (message == null) throw new NullPointerException("Did not get a response withing " + MdbProxy.MdbInvocationHandler.MAX_RESPONSE_WAIT + "ms");
+                if (message == null) throw new NullPointerException("Did not get a response within " + MdbProxy.MdbInvocationHandler.MAX_RESPONSE_WAIT + "ms");
                 if (!correlationId.equals(message.getJMSCorrelationID())) {
                     throw new IllegalStateException("Received a response message with the wrong correlation id");
                 }
                 if (!(message instanceof ObjectMessage)) throw new IllegalArgumentException("Expected a ObjectMessage response but got a " + message.getClass().getName());
-                ObjectMessage resMessage = (ObjectMessage) message;
-                Serializable object = resMessage.getObject();
+                final ObjectMessage resMessage = (ObjectMessage) message;
+                final Serializable object = resMessage.getObject();
                 if (object == null) throw new NullPointerException("object in ObjectMessage is null");
                 if (!(object instanceof Map)) {
-                    if (message instanceof ObjectMessage) throw new IllegalArgumentException("Expected a Map contained in the ObjectMessage response but got a " + object.getClass().getName());
+                    if (ObjectMessage.class.isInstance(message))
+                        throw new IllegalArgumentException("Expected a Map contained in the ObjectMessage response but got a " + object.getClass().getName());
                 }
-                Map response = (Map) object;
+                final Map response = (Map) object;
 
                 // process results
-                boolean exception = response.containsKey("exception");
-                Object returnValue = response.get("return");
+                final boolean exception = response.containsKey("exception");
+                final Object returnValue = response.get("return");
                 if (exception) {
                     throw (Throwable) returnValue;
                 }
                 return returnValue;
             } finally {
                 MdbUtil.close(consumer);
+                MdbUtil.close(tempSession);
             }
         }
     }

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbUtil.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbUtil.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbUtil.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbUtil.java Tue Nov 27 16:47:37 2012
@@ -17,19 +17,19 @@
  */
 package org.apache.openejb.test.mdb;
 
-import javax.jms.MessageProducer;
-import javax.jms.JMSException;
+import javax.jms.Connection;
 import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
 import javax.jms.Session;
-import javax.jms.Connection;
 import java.lang.reflect.Method;
 
 public class MdbUtil {
-    public static String getSignature(Method method){
-        StringBuilder builder = new StringBuilder();
+
+    public static String getSignature(final Method method) {
+        final StringBuilder builder = new StringBuilder();
         builder.append(method.getName()).append("(");
         boolean first = true;
-        for (Class<?> type : method.getParameterTypes()) {
+        for (final Class<?> type : method.getParameterTypes()) {
             if (!first) {
                 builder.append(",");
             }
@@ -40,38 +40,49 @@ public class MdbUtil {
         return builder.toString();
     }
 
-    public static void close(MessageProducer closeable) {
+    public static void close(final MessageProducer closeable) {
         if (closeable != null) {
             try {
                 closeable.close();
-            } catch (JMSException e) {
+            } catch (Throwable e) {
+                //Ignore
             }
         }
     }
 
-    public static void close(MessageConsumer closeable) {
+    public static void close(final MessageConsumer closeable) {
         if (closeable != null) {
             try {
                 closeable.close();
-            } catch (JMSException e) {
+            } catch (Throwable e) {
+                //Ignore
             }
         }
     }
 
-    public static void close(Session closeable) {
+    public static void close(final Session closeable) {
         if (closeable != null) {
             try {
                 closeable.close();
-            } catch (JMSException e) {
+            } catch (Throwable e) {
+                //Ignore
             }
         }
     }
 
-    public static void close(Connection closeable) {
+    public static void close(final Connection closeable) {
         if (closeable != null) {
+
+            try {
+                closeable.stop();
+            } catch (Throwable e) {
+                //Ignore
+            }
+
             try {
                 closeable.close();
-            } catch (JMSException e) {
+            } catch (Throwable e) {
+                //Ignore
             }
         }
     }

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/SetterInjectionMdbBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/SetterInjectionMdbBean.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/SetterInjectionMdbBean.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/SetterInjectionMdbBean.java Tue Nov 27 16:47:37 2012
@@ -17,7 +17,17 @@
  */
 package org.apache.openejb.test.mdb;
 
-import javax.annotation.PreDestroy;
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+import org.apache.openejb.test.TestFailureException;
+import org.apache.openejb.test.entity.bmp.BasicBmpHome;
+import org.apache.openejb.test.stateful.BasicStatefulBusinessLocal;
+import org.apache.openejb.test.stateful.BasicStatefulBusinessRemote;
+import org.apache.openejb.test.stateful.BasicStatefulHome;
+import org.apache.openejb.test.stateless.BasicStatelessBusinessLocal;
+import org.apache.openejb.test.stateless.BasicStatelessBusinessRemote;
+import org.apache.openejb.test.stateless.BasicStatelessHome;
+
 import javax.ejb.CreateException;
 import javax.ejb.EJBException;
 import javax.ejb.MessageDrivenBean;
@@ -36,17 +46,6 @@ import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.sql.DataSource;
 
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
-import org.apache.openejb.test.TestFailureException;
-import org.apache.openejb.test.entity.bmp.BasicBmpHome;
-import org.apache.openejb.test.stateful.BasicStatefulBusinessLocal;
-import org.apache.openejb.test.stateful.BasicStatefulBusinessRemote;
-import org.apache.openejb.test.stateful.BasicStatefulHome;
-import org.apache.openejb.test.stateless.BasicStatelessBusinessLocal;
-import org.apache.openejb.test.stateless.BasicStatelessBusinessRemote;
-import org.apache.openejb.test.stateless.BasicStatelessHome;
-
 public class SetterInjectionMdbBean implements EncMdbObject, MessageDrivenBean, MessageListener {
     private MessageDrivenContext ejbContextField;
     private BasicBmpHome bmpHomeField;
@@ -77,28 +76,25 @@ public class SetterInjectionMdbBean impl
     private MessageDrivenContext mdbContext = null;
     private MdbInvoker mdbInvoker;
 
-    public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException {
+    @Override
+    public void setMessageDrivenContext(final MessageDrivenContext ctx) throws EJBException {
         this.mdbContext = ctx;
         try {
-            ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
+            final ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
             mdbInvoker = new MdbInvoker(connectionFactory, this);
         } catch (Exception e) {
             throw new EJBException(e);
         }
     }
 
-    public void onMessage(Message message) {
+    @Override
+    public void onMessage(final Message message) {
         try {
 //            System.out.println("\n" +
 //                    "***************************************\n" +
 //                    "Got message: " + message + "\n" +
 //                    "***************************************\n\n");
-            try {
-                message.acknowledge();
-            } catch (JMSException e) {
-                e.printStackTrace();
-            }
-            mdbInvoker.onMessage(message);
+             mdbInvoker.onMessage(message);
         } catch (Throwable e) {
             e.printStackTrace();
         }
@@ -108,7 +104,7 @@ public class SetterInjectionMdbBean impl
         return statefulBusinessLocalField;
     }
 
-    public void setStatefulBusinessLocal(BasicStatefulBusinessLocal statefulBusinessLocal) {
+    public void setStatefulBusinessLocal(final BasicStatefulBusinessLocal statefulBusinessLocal) {
         this.statefulBusinessLocalField = statefulBusinessLocal;
     }
 
@@ -116,7 +112,7 @@ public class SetterInjectionMdbBean impl
         return statefulBusinessRemoteField;
     }
 
-    public void setStatefulBusinessRemote(BasicStatefulBusinessRemote statefulBusinessRemote) {
+    public void setStatefulBusinessRemote(final BasicStatefulBusinessRemote statefulBusinessRemote) {
         this.statefulBusinessRemoteField = statefulBusinessRemote;
     }
 
@@ -124,7 +120,7 @@ public class SetterInjectionMdbBean impl
         return statelessBusinessLocalField;
     }
 
-    public void setStatelessBusinessLocal(BasicStatelessBusinessLocal statelessBusinessLocal) {
+    public void setStatelessBusinessLocal(final BasicStatelessBusinessLocal statelessBusinessLocal) {
         this.statelessBusinessLocalField = statelessBusinessLocal;
     }
 
@@ -132,7 +128,7 @@ public class SetterInjectionMdbBean impl
         return statelessBusinessRemoteField;
     }
 
-    public void setStatelessBusinessRemote(BasicStatelessBusinessRemote statelessBusinessRemote) {
+    public void setStatelessBusinessRemote(final BasicStatelessBusinessRemote statelessBusinessRemote) {
         this.statelessBusinessRemoteField = statelessBusinessRemote;
     }
 
@@ -140,7 +136,7 @@ public class SetterInjectionMdbBean impl
         return bmpHomeField;
     }
 
-    public void setBmpHome(BasicBmpHome bmpHome) {
+    public void setBmpHome(final BasicBmpHome bmpHome) {
         this.bmpHomeField = bmpHome;
     }
 
@@ -148,7 +144,7 @@ public class SetterInjectionMdbBean impl
         return boooleanField;
     }
 
-    public void setBooolean(Boolean booolean) {
+    public void setBooolean(final Boolean booolean) {
         this.boooleanField = booolean;
     }
 
@@ -156,7 +152,7 @@ public class SetterInjectionMdbBean impl
         return byyteField;
     }
 
-    public void setByyte(Byte byyte) {
+    public void setByyte(final Byte byyte) {
         this.byyteField = byyte;
     }
 
@@ -164,7 +160,7 @@ public class SetterInjectionMdbBean impl
         return chaaracterField;
     }
 
-    public void setChaaracter(Character chaaracter) {
+    public void setChaaracter(final Character chaaracter) {
         this.chaaracterField = chaaracter;
     }
 
@@ -172,7 +168,7 @@ public class SetterInjectionMdbBean impl
         return daataSourceField;
     }
 
-    public void setDaataSource(DataSource daataSource) {
+    public void setDaataSource(final DataSource daataSource) {
         this.daataSourceField = daataSource;
     }
 
@@ -180,7 +176,7 @@ public class SetterInjectionMdbBean impl
         return coonnectionFactory;
     }
 
-    public void setCoonnectionFactory(ConnectionFactory coonnectionFactory) {
+    public void setCoonnectionFactory(final ConnectionFactory coonnectionFactory) {
         this.coonnectionFactory = coonnectionFactory;
     }
 
@@ -188,7 +184,7 @@ public class SetterInjectionMdbBean impl
         return queueCoonnectionFactory;
     }
 
-    public void setQueueCoonnectionFactory(QueueConnectionFactory queueCoonnectionFactory) {
+    public void setQueueCoonnectionFactory(final QueueConnectionFactory queueCoonnectionFactory) {
         this.queueCoonnectionFactory = queueCoonnectionFactory;
     }
 
@@ -196,7 +192,7 @@ public class SetterInjectionMdbBean impl
         return topicCoonnectionFactory;
     }
 
-    public void setTopicCoonnectionFactory(TopicConnectionFactory topicCoonnectionFactory) {
+    public void setTopicCoonnectionFactory(final TopicConnectionFactory topicCoonnectionFactory) {
         this.topicCoonnectionFactory = topicCoonnectionFactory;
     }
 
@@ -204,7 +200,7 @@ public class SetterInjectionMdbBean impl
         return dooubleField;
     }
 
-    public void setDoouble(Double doouble) {
+    public void setDoouble(final Double doouble) {
         this.dooubleField = doouble;
     }
 
@@ -212,7 +208,7 @@ public class SetterInjectionMdbBean impl
         return eemField;
     }
 
-    public void setEem(EntityManager eem) {
+    public void setEem(final EntityManager eem) {
         this.eemField = eem;
     }
 
@@ -220,7 +216,7 @@ public class SetterInjectionMdbBean impl
         return ejbContextField;
     }
 
-    public void setEjbContext(MessageDrivenContext ejbContext) {
+    public void setEjbContext(final MessageDrivenContext ejbContext) {
         this.ejbContextField = ejbContext;
     }
 
@@ -228,7 +224,7 @@ public class SetterInjectionMdbBean impl
         return emField;
     }
 
-    public void setEm(EntityManager em) {
+    public void setEm(final EntityManager em) {
         this.emField = em;
     }
 
@@ -236,7 +232,7 @@ public class SetterInjectionMdbBean impl
         return emfField;
     }
 
-    public void setEmf(EntityManagerFactory emf) {
+    public void setEmf(final EntityManagerFactory emf) {
         this.emfField = emf;
     }
 
@@ -244,7 +240,7 @@ public class SetterInjectionMdbBean impl
         return flooatField;
     }
 
-    public void setFlooat(Float flooat) {
+    public void setFlooat(final Float flooat) {
         this.flooatField = flooat;
     }
 
@@ -252,7 +248,7 @@ public class SetterInjectionMdbBean impl
         return inteegerField;
     }
 
-    public void setInteeger(Integer inteeger) {
+    public void setInteeger(final Integer inteeger) {
         this.inteegerField = inteeger;
     }
 
@@ -260,7 +256,7 @@ public class SetterInjectionMdbBean impl
         return loongField;
     }
 
-    public void setLoong(Long loong) {
+    public void setLoong(final Long loong) {
         this.loongField = loong;
     }
 
@@ -268,7 +264,7 @@ public class SetterInjectionMdbBean impl
         return pemField;
     }
 
-    public void setPem(EntityManager pem) {
+    public void setPem(final EntityManager pem) {
         this.pemField = pem;
     }
 
@@ -276,7 +272,7 @@ public class SetterInjectionMdbBean impl
         return shoortField;
     }
 
-    public void setShoort(Short shoort) {
+    public void setShoort(final Short shoort) {
         this.shoortField = shoort;
     }
 
@@ -284,7 +280,7 @@ public class SetterInjectionMdbBean impl
         return statefulHomeField;
     }
 
-    public void setStatefulHome(BasicStatefulHome statefulHome) {
+    public void setStatefulHome(final BasicStatefulHome statefulHome) {
         this.statefulHomeField = statefulHome;
     }
 
@@ -292,7 +288,7 @@ public class SetterInjectionMdbBean impl
         return statelessHomeField;
     }
 
-    public void setStatelessHome(BasicStatelessHome statelessHome) {
+    public void setStatelessHome(final BasicStatelessHome statelessHome) {
         this.statelessHomeField = statelessHome;
     }
 
@@ -300,13 +296,14 @@ public class SetterInjectionMdbBean impl
         return striingField;
     }
 
-    public void setStriing(String striing) {
+    public void setStriing(final String striing) {
         this.striingField = striing;
     }
 
     public void ejbCreate() throws CreateException {
     }
 
+    @Override
     public void lookupEntityBean() throws TestFailureException {
         try {
             Assert.assertNotNull("The EJBObject is null", bmpHomeField);
@@ -315,6 +312,7 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupStatefulBean() throws TestFailureException {
         try {
             Assert.assertNotNull("The EJBObject is null", statefulHomeField);
@@ -323,6 +321,7 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupStatelessBean() throws TestFailureException {
         try {
             Assert.assertNotNull("The EJBObject is null", statelessHomeField);
@@ -331,42 +330,47 @@ public class SetterInjectionMdbBean impl
         }
     }
 
-    public void lookupStatelessBusinessLocal() throws TestFailureException{
-        try{
-            Assert.assertNotNull("The EJB BusinessLocal is null", statelessBusinessLocalField );
-        } catch (AssertionFailedError afe){
+    @Override
+    public void lookupStatelessBusinessLocal() throws TestFailureException {
+        try {
+            Assert.assertNotNull("The EJB BusinessLocal is null", statelessBusinessLocalField);
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatelessBusinessRemote() throws TestFailureException{
-        try{
-            Assert.assertNotNull("The EJB BusinessRemote is null", statelessBusinessRemoteField );
-        } catch (AssertionFailedError afe){
+    @Override
+    public void lookupStatelessBusinessRemote() throws TestFailureException {
+        try {
+            Assert.assertNotNull("The EJB BusinessRemote is null", statelessBusinessRemoteField);
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatefulBusinessLocal() throws TestFailureException{
-        try{
-            Assert.assertNotNull("The EJB BusinessLocal is null", statefulBusinessLocalField );
-        } catch (AssertionFailedError afe){
+    @Override
+    public void lookupStatefulBusinessLocal() throws TestFailureException {
+        try {
+            Assert.assertNotNull("The EJB BusinessLocal is null", statefulBusinessLocalField);
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatefulBusinessRemote() throws TestFailureException{
-        try{
-            Assert.assertNotNull("The EJB BusinessRemote is null", statefulBusinessRemoteField );
-        } catch (AssertionFailedError afe){
+    @Override
+    public void lookupStatefulBusinessRemote() throws TestFailureException {
+        try {
+            Assert.assertNotNull("The EJB BusinessRemote is null", statefulBusinessRemoteField);
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
 
+    @Override
     public void lookupStringEntry() throws TestFailureException {
         try {
-            String expected = new String("1");
+            final String expected = "1";
             Assert.assertNotNull("The String looked up is null", striingField);
             Assert.assertEquals(expected, striingField);
         } catch (AssertionFailedError afe) {
@@ -374,9 +378,10 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupDoubleEntry() throws TestFailureException {
         try {
-            Double expected = new Double(1.0D);
+            final Double expected = 1.0D;
 
             Assert.assertNotNull("The Double looked up is null", dooubleField);
             Assert.assertEquals(expected, dooubleField);
@@ -386,9 +391,10 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupLongEntry() throws TestFailureException {
         try {
-            Long expected = new Long(1L);
+            final Long expected = 1L;
 
             Assert.assertNotNull("The Long looked up is null", loongField);
             Assert.assertEquals(expected, loongField);
@@ -397,9 +403,10 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupFloatEntry() throws TestFailureException {
         try {
-            Float expected = new Float(1.0F);
+            final Float expected = 1.0F;
 
             Assert.assertNotNull("The Float looked up is null", flooatField);
             Assert.assertEquals(expected, flooatField);
@@ -408,9 +415,10 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupIntegerEntry() throws TestFailureException {
         try {
-            Integer expected = new Integer(1);
+            final Integer expected = 1;
 
             Assert.assertNotNull("The Integer looked up is null", inteegerField);
             Assert.assertEquals(expected, inteegerField);
@@ -420,9 +428,10 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupShortEntry() throws TestFailureException {
         try {
-            Short expected = new Short((short) 1);
+            final Short expected = (short) 1;
 
             Assert.assertNotNull("The Short looked up is null", shoortField);
             Assert.assertEquals(expected, shoortField);
@@ -431,9 +440,10 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupBooleanEntry() throws TestFailureException {
         try {
-            Boolean expected = new Boolean(true);
+            final Boolean expected = true;
 
             Assert.assertNotNull("The Boolean looked up is null", boooleanField);
             Assert.assertEquals(expected, boooleanField);
@@ -442,9 +452,10 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupByteEntry() throws TestFailureException {
         try {
-            Byte expected = new Byte((byte) 1);
+            final Byte expected = (byte) 1;
 
             Assert.assertNotNull("The Byte looked up is null", byyteField);
             Assert.assertEquals(expected, byyteField);
@@ -453,9 +464,10 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupCharacterEntry() throws TestFailureException {
         try {
-            Character expected = new Character('D');
+            final Character expected = 'D';
 
             Assert.assertNotNull("The Character looked up is null", chaaracterField);
             Assert.assertEquals(expected, chaaracterField);
@@ -464,6 +476,7 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupResource() throws TestFailureException {
         try {
             Assert.assertNotNull("The DataSource is null", daataSourceField);
@@ -472,31 +485,33 @@ public class SetterInjectionMdbBean impl
         }
     }
 
-    public void lookupJMSConnectionFactory() throws TestFailureException{
-        try{
-            try{
+    @Override
+    public void lookupJMSConnectionFactory() throws TestFailureException {
+        try {
+            try {
                 testJmsConnection(coonnectionFactory.createConnection());
                 testJmsConnection(queueCoonnectionFactory.createConnection());
                 testJmsConnection(topicCoonnectionFactory.createConnection());
-            } catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    private void testJmsConnection(javax.jms.Connection connection) throws JMSException {
-        Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-        Topic topic = session.createTopic("test");
-        MessageProducer producer = session.createProducer(topic);
+    private void testJmsConnection(final javax.jms.Connection connection) throws JMSException {
+        final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+        final Topic topic = session.createTopic("test");
+        final MessageProducer producer = session.createProducer(topic);
         producer.send(session.createMessage());
         producer.close();
         session.close();
         connection.close();
     }
 
+    @Override
     public void lookupPersistenceUnit() throws TestFailureException {
         try {
             Assert.assertNotNull("The EntityManagerFactory is null", emfField);
@@ -505,6 +520,7 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupPersistenceContext() throws TestFailureException {
         try {
             Assert.assertNotNull("The EntityManager is null", emField);
@@ -520,6 +536,7 @@ public class SetterInjectionMdbBean impl
         }
     }
 
+    @Override
     public void lookupMessageDrivenContext() throws TestFailureException {
         try {
             Assert.assertNotNull("The MessageDrivenContext is null", mdbContext);
@@ -529,6 +546,10 @@ public class SetterInjectionMdbBean impl
 
     }
 
+    @Override
     public void ejbRemove() throws EJBException {
+        if (null != mdbInvoker) {
+            mdbInvoker.destroy();
+        }
     }
 }

Modified: openejb/trunk/openejb/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/ActiveMqLocalTestJms.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/ActiveMqLocalTestJms.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/ActiveMqLocalTestJms.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/ActiveMqLocalTestJms.java Tue Nov 27 16:47:37 2012
@@ -25,9 +25,12 @@ import java.util.Properties;
  * @version $Rev: 637368 $ $Date: 2008-03-15 00:04:30 -0700 (Sat, 15 Mar 2008) $
  */
 public class ActiveMqLocalTestJms implements TestJms {
-    public void init(Properties props) {
+
+    @Override
+    public void init(final Properties props) {
     }
 
+    @Override
     public ConnectionFactory getConnectionFactory() {
         return new ActiveMQConnectionFactory("vm://localhost?async=true");
     }

Modified: openejb/trunk/openejb/tomee/apache-tomee-deb-package/src/main/java/org/apache/tomee/debian/PackageBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/tomee/apache-tomee-deb-package/src/main/java/org/apache/tomee/debian/PackageBuilder.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/tomee/apache-tomee-deb-package/src/main/java/org/apache/tomee/debian/PackageBuilder.java (original)
+++ openejb/trunk/openejb/tomee/apache-tomee-deb-package/src/main/java/org/apache/tomee/debian/PackageBuilder.java Tue Nov 27 16:47:37 2012
@@ -146,7 +146,7 @@ public class PackageBuilder {
 
         if (file.isDirectory()) {
             final File[] children = file.listFiles();
-            for (File child : children) {
+            if (null != children) for (File child : children) {
                 tar(baseDir, checksumWriter, child, os, modeMappings);
             }
         }
@@ -231,7 +231,7 @@ public class PackageBuilder {
 
         final int baseDirLength = baseDir.getAbsolutePath().length();
         final File[] files = baseDir.listFiles();
-        for (File entry : files) {
+        if (null != files) for (File entry : files) {
             final String basePath = entry.getAbsolutePath().substring(baseDirLength).replaceAll("\\\\", "/");
 
             final String dest = dirMappings.get(basePath);
@@ -314,7 +314,9 @@ public class PackageBuilder {
     ) {
         final File expandedTarGz = expandTarGz(sourceTarGz);
 
-        final File dataTarGzFolder = buildDataTarGzFolder(expandedTarGz.listFiles()[0], dirMapping);
+        final File[] files = expandedTarGz.listFiles();
+        final File root = (null != files ? files[0] : expandedTarGz);
+        final File dataTarGzFolder = buildDataTarGzFolder(files[0], dirMapping);
 
         final File md5sums = new File(sourceTarGz.getParent(), "md5sums");
         final File data = compressTarGz(