[jboss-cvs] JBoss Messaging SVN: r6311 - in trunk: examples/jms/browser and 26 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 3 18:36:13 EDT 2009


Author: clebert.suconic at jboss.com
Date: 2009-04-03 18:36:12 -0400 (Fri, 03 Apr 2009)
New Revision: 6311

Modified:
   trunk/.classpath
   trunk/examples/jms/browser/readme.html
   trunk/examples/jms/browser/src/org/jboss/jms/example/QueueBrowserExample.java
   trunk/examples/jms/clustered-queue/
   trunk/examples/jms/clustered-queue/readme.html
   trunk/examples/jms/clustered-queue/src/org/jboss/jms/example/ClusteredQueueExample.java
   trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java
   trunk/examples/jms/dead-letter/readme.html
   trunk/examples/jms/dead-letter/src/org/jboss/jms/example/DeadLetterExample.java
   trunk/examples/jms/durable/readme.html
   trunk/examples/jms/durable/src/org/jboss/jms/example/DurableSubscriberExample.java
   trunk/examples/jms/expiry/readme.html
   trunk/examples/jms/expiry/src/org/jboss/jms/example/ExpiryExample.java
   trunk/examples/jms/paging/readme.html
   trunk/examples/jms/paging/src/org/jboss/jms/example/PagingExample.java
   trunk/examples/jms/queue-requestor/readme.html
   trunk/examples/jms/queue-requestor/src/org/jboss/jms/example/QueueRequestorExample.java
   trunk/examples/jms/queue/readme.html
   trunk/examples/jms/queue/src/org/jboss/jms/example/QueueExample.java
   trunk/examples/jms/request-reply/readme.html
   trunk/examples/jms/request-reply/src/org/jboss/jms/example/RequestReplyExample.java
   trunk/examples/jms/temp-queue/readme.html
   trunk/examples/jms/temp-queue/src/org/jboss/jms/example/TemporaryQueueExample.java
   trunk/examples/jms/topic-selector/build.xml
   trunk/examples/jms/topic-selector/readme.html
   trunk/examples/jms/topic-selector/src/org/jboss/jms/example/TopicSelectorExample.java
   trunk/examples/jms/topic/readme.html
   trunk/examples/jms/topic/src/org/jboss/jms/example/TopicExample.java
   trunk/examples/jms/transactional/readme.html
   trunk/examples/jms/transactional/src/org/jboss/jms/example/TransactionalExample.java
Log:
Tidy up on examples (boolean property on method run + initialContext.close())

Modified: trunk/.classpath
===================================================================
--- trunk/.classpath	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/.classpath	2009-04-03 22:36:12 UTC (rev 6311)
@@ -15,6 +15,7 @@
 	<classpathentry kind="src" path="tests/joram-tests/config"/>
 	<classpathentry kind="src" path="examples/jms/browser/src"/>
 	<classpathentry kind="src" path="examples/jms/common/src"/>
+	<classpathentry kind="src" path="examples/jms/clustered-queue/src"/>
 	<classpathentry kind="src" path="examples/jms/dead-letter/src"/>
 	<classpathentry kind="src" path="examples/jms/durable/src"/>
 	<classpathentry kind="src" path="examples/jms/expiry/src"/>

Modified: trunk/examples/jms/browser/readme.html
===================================================================
--- trunk/examples/jms/browser/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/browser/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -103,11 +103,15 @@
            System.out.println("Received message: " + messageReceived.getText());</code>
         </pre>
         
-        <li>And finally, <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
            <code>finally
            {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
               if (connection != null)
               {
                  connection.close();

Modified: trunk/examples/jms/browser/src/org/jboss/jms/example/QueueBrowserExample.java
===================================================================
--- trunk/examples/jms/browser/src/org/jboss/jms/example/QueueBrowserExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/browser/src/org/jboss/jms/example/QueueBrowserExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -49,13 +49,14 @@
    }
 
    @Override
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
+      InitialContext initialContext = null;
       try
       {
          // Step 1. Create an initial context to perform the JNDI lookup.
-         InitialContext initialContext = getContext();
+         initialContext = getContext();
 
          // Step 2. Perfom a lookup on the queue
          Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
@@ -107,10 +108,16 @@
          messageReceived = (TextMessage)messageConsumer.receive(5000);
          System.out.println("Received message: " + messageReceived.getText());
          
+         return true;
+         
       }
       finally
       {
          // Step 15. Be sure to close our JMS resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
          if (connection != null)
          {
             connection.close();


Property changes on: trunk/examples/jms/clustered-queue
___________________________________________________________________
Name: svn:ignore
   + build


Modified: trunk/examples/jms/clustered-queue/readme.html
===================================================================
--- trunk/examples/jms/clustered-queue/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/clustered-queue/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -69,20 +69,20 @@
            <code>TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);</code>
         </pre>
 
-        <li>And finally, <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
-           <code>
-
-      finally
-      {
-         if (connection != null)
-         {
-            // Step 12. Be sure to close our JMS resources!
-            connection.close();
-         }
-      }
-           </code>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
         </pre>
 
 

Modified: trunk/examples/jms/clustered-queue/src/org/jboss/jms/example/ClusteredQueueExample.java
===================================================================
--- trunk/examples/jms/clustered-queue/src/org/jboss/jms/example/ClusteredQueueExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/clustered-queue/src/org/jboss/jms/example/ClusteredQueueExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -44,13 +44,14 @@
       new ClusteredQueueExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
+      InitialContext initialContext = null;
       try
       {
          //Step 1. Create an initial context to perform the JNDI lookup.
-         InitialContext initialContext = getContext();
+         initialContext = getContext();
 
          //Step 2. Perfom a lookup on the queue
          Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");
@@ -85,6 +86,8 @@
          TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
 
          System.out.println("Received message: " + messageReceived.getText());
+         
+         return true;
       }
       finally
       {
@@ -93,6 +96,10 @@
          {
             connection.close();
          }
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
       }
    }
 

Modified: trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java
===================================================================
--- trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/common/src/org/jboss/jms/example/JMSExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -43,7 +43,7 @@
 
    private boolean failure = false;
 
-   public abstract void runExample() throws Exception;
+   public abstract boolean runExample() throws Exception;
 
    protected void run(String[] args)
    {
@@ -58,7 +58,10 @@
          {
             startServer(getServerNames(args), logServerOutput);
          }
-         runExample();
+         if (!runExample())
+         {
+            failure = true;
+         }
       }
       catch (Throwable e)
       {

Modified: trunk/examples/jms/dead-letter/readme.html
===================================================================
--- trunk/examples/jms/dead-letter/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/dead-letter/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -182,11 +182,15 @@
         </pre>
 
         </p>    
-        <li>And finally, <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
            <code>finally
            {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
               if (connection != null)
               {
                  connection.close();

Modified: trunk/examples/jms/dead-letter/src/org/jboss/jms/example/DeadLetterExample.java
===================================================================
--- trunk/examples/jms/dead-letter/src/org/jboss/jms/example/DeadLetterExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/dead-letter/src/org/jboss/jms/example/DeadLetterExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -43,13 +43,15 @@
       new DeadLetterExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
+      InitialContext initialContext = null;
+      
       try
       {
          // Step 1. Create an initial context to perform the JNDI lookup.
-         InitialContext initialContext = getContext();
+         initialContext = getContext();
 
          // Step 2. Perfom a lookup on the queue
          Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
@@ -132,12 +134,16 @@
 
          // Step 23. This time, we commit the session, the delivery from the dead letter queue is successful!
          session.commit();
-
-         initialContext.close();
+         
+         return true;
       }
       finally
       {
          // Step 24. Be sure to close our JMS resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
          if (connection != null)
          {
             connection.close();

Modified: trunk/examples/jms/durable/readme.html
===================================================================
--- trunk/examples/jms/durable/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/durable/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -112,25 +112,20 @@
            <code>session.unsubscribe("subscriber-1");</code>
         </pre>
 
-	<li>And finally (no pun intended), <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its session, consumer, producer and browser objects. Also remember to close the JNDI initial context.</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
-           <code>
-
-      finally
-      {
-         if (connection != null)
-         {
-            //Step 19. Be sure to close our JMS resources!
-            connection.close();
-         }
-         if (initialContext != null)
-         {
-            //Step 20. Also close the initialContext!
-            initialContext.close();
-         }
-      }
-           </code>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
         </pre>
 
 

Modified: trunk/examples/jms/durable/src/org/jboss/jms/example/DurableSubscriberExample.java
===================================================================
--- trunk/examples/jms/durable/src/org/jboss/jms/example/DurableSubscriberExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/durable/src/org/jboss/jms/example/DurableSubscriberExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -42,7 +42,7 @@
       new DurableSubscriberExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
       InitialContext initialContext = null;
@@ -115,6 +115,8 @@
 
          // Step 18. Delete the durable subscription
          session.unsubscribe("subscriber-1");
+         
+         return true;
       }
       finally
       {

Modified: trunk/examples/jms/expiry/readme.html
===================================================================
--- trunk/examples/jms/expiry/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/expiry/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -160,11 +160,15 @@
         </pre>
 
         </p>    
-        <li>And finally, <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
            <code>finally
            {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
               if (connection != null)
               {
                  connection.close();
@@ -173,7 +177,6 @@
         </pre>
 
 
-
      </ol>
   </body>
 </html>
\ No newline at end of file

Modified: trunk/examples/jms/expiry/src/org/jboss/jms/example/ExpiryExample.java
===================================================================
--- trunk/examples/jms/expiry/src/org/jboss/jms/example/ExpiryExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/expiry/src/org/jboss/jms/example/ExpiryExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -43,13 +43,14 @@
       new ExpiryExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
+      InitialContext initialContext = null;
       try
       {
          // Step 1. Create an initial context to perform the JNDI lookup.
-         InitialContext initialContext = getContext();
+         initialContext = getContext();
 
          // Step 2. Perfom a lookup on the queue
          Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
@@ -121,10 +122,16 @@
          System.out.println("*Actual expiration time* of the expired message: " + messageReceived.getLongProperty("_JBM_ACTUAL_EXPIRY"));
 
          initialContext.close();
+         
+         return true;
       }
       finally
       {
          // Step 22. Be sure to close our JMS resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
          if (connection != null)
          {
             connection.close();

Modified: trunk/examples/jms/paging/readme.html
===================================================================
--- trunk/examples/jms/paging/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/paging/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -141,22 +141,21 @@
          }
          </pre></code>
 
-        <li>And finally, <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
-         <pre><code>
-      }
-      finally
-      {
-         if (initialContext != null)
-         {
-            initialContext.close();
-         }
-         
-         if(connection != null)
-         {
-            connection.close();
-         }
-      }
+        <pre>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
+        </pre>
 
      </ol>
   </body>

Modified: trunk/examples/jms/paging/src/org/jboss/jms/example/PagingExample.java
===================================================================
--- trunk/examples/jms/paging/src/org/jboss/jms/example/PagingExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/paging/src/org/jboss/jms/example/PagingExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -43,7 +43,7 @@
       new PagingExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
       
@@ -137,7 +137,7 @@
          }
          
 
-         
+         return true;
 
       }
       finally

Modified: trunk/examples/jms/queue/readme.html
===================================================================
--- trunk/examples/jms/queue/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/queue/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -69,20 +69,20 @@
            <code>TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);</code>
         </pre>
 
-        <li>And finally, <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
-           <code>
-
-      finally
-      {
-         if (connection != null)
-         {
-            // Step 12. Be sure to close our JMS resources!
-            connection.close();
-         }
-      }
-           </code>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
         </pre>
 
 

Modified: trunk/examples/jms/queue/src/org/jboss/jms/example/QueueExample.java
===================================================================
--- trunk/examples/jms/queue/src/org/jboss/jms/example/QueueExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/queue/src/org/jboss/jms/example/QueueExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -42,13 +42,14 @@
       new QueueExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
+      InitialContext initialContext = null;
       try
       {
          //Step 1. Create an initial context to perform the JNDI lookup.
-         InitialContext initialContext = getContext();
+         initialContext = getContext();
 
          //Step 2. Perfom a lookup on the queue
          Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");
@@ -85,10 +86,16 @@
          System.out.println("Received message: " + messageReceived.getText());
 
          initialContext.close();
+         
+         return true;
       }
       finally
       {
          //Step 12. Be sure to close our JMS resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
          if(connection != null)
          {
             connection.close();

Modified: trunk/examples/jms/queue-requestor/readme.html
===================================================================
--- trunk/examples/jms/queue-requestor/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/queue-requestor/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -95,14 +95,17 @@
            <code>reverserService.close()</code>
         </pre>
 
-	<li>and finally <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its session, consumer, producer and browser objects</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
            <code>finally
-           { 
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
               if (connection != null)
               {
-                 // Be sure to close our JMS resources!
                  connection.close();
               }
            }</code>

Modified: trunk/examples/jms/queue-requestor/src/org/jboss/jms/example/QueueRequestorExample.java
===================================================================
--- trunk/examples/jms/queue-requestor/src/org/jboss/jms/example/QueueRequestorExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/queue-requestor/src/org/jboss/jms/example/QueueRequestorExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -43,13 +43,14 @@
       new QueueRequestorExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       QueueConnection connection = null;
+      InitialContext initialContext = null;
       try
       {
          // Step 1. Create an initial context to perform the JNDI lookup.
-         InitialContext initialContext = getContext();
+         initialContext = getContext();
 
          // Step 2. Perfom a lookup on the queue
          Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
@@ -87,6 +88,8 @@
 
          // Step 13. close the text reverser service
          reverserService.close();
+         
+         return true;
       }
       finally
       {
@@ -102,6 +105,12 @@
                e.printStackTrace();
             }
          }
+         
+         if (initialContext != null)
+         {
+            // Also the InitialContext
+            initialContext.close();
+         }
       }
    }
 }

Modified: trunk/examples/jms/request-reply/readme.html
===================================================================
--- trunk/examples/jms/request-reply/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/request-reply/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -112,25 +112,20 @@
            <code>server.shutdown();</code>
         </pre>
         
-        <li>And finally, <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects. Also remember close the JNDI initial context.</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
-           <code>
-
-      finally
-      {
-         if (connection != null)
-         {
-            // Step 20. Be sure to close our JMS resources!
-            connection.close();
-         }
-         //Step 21. Also close the initialContext!
-         if (initialContext != null)
-         {
-            initialContext.close();
-         }
-      }
-           </code>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
         </pre>
      </ol>
 

Modified: trunk/examples/jms/request-reply/src/org/jboss/jms/example/RequestReplyExample.java
===================================================================
--- trunk/examples/jms/request-reply/src/org/jboss/jms/example/RequestReplyExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/request-reply/src/org/jboss/jms/example/RequestReplyExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -52,7 +52,7 @@
       new RequestReplyExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
       InitialContext initialContext = null;
@@ -127,6 +127,7 @@
          //Step 19. Shutdown the request server
          server.shutdown();
          
+         return true;
       }
       finally
       {

Modified: trunk/examples/jms/temp-queue/readme.html
===================================================================
--- trunk/examples/jms/temp-queue/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/temp-queue/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -114,25 +114,20 @@
            </code>
         </pre>
 
-	<li>and finally (no pun intended), <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its session, consumer, producer and browser objects. Also remember to close the initial context</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
-           <code>
-
-      finally
-      {
-         if (connection != null)
-         {
-            //Step 20. Be sure to close our JMS resources!
-            connection.close();
-         }
-         if (initialContext != null)
-         {
-            //Step 21. Also close the initialContext!
-            initialContext.close();
-         }
-      }
-           </code>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
         </pre>
 
 

Modified: trunk/examples/jms/temp-queue/src/org/jboss/jms/example/TemporaryQueueExample.java
===================================================================
--- trunk/examples/jms/temp-queue/src/org/jboss/jms/example/TemporaryQueueExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/temp-queue/src/org/jboss/jms/example/TemporaryQueueExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -43,7 +43,7 @@
       new TemporaryQueueExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
       InitialContext initialContext = null;
@@ -120,6 +120,7 @@
             System.out.println("Exception got when trying to access a temp queue outside its scope: " + e);
          }
          
+         return true;
       }
       finally
       {

Modified: trunk/examples/jms/topic/readme.html
===================================================================
--- trunk/examples/jms/topic/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/topic/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -79,20 +79,20 @@
            <code>messageReceived = (TextMessage) messageConsumer2.receive();</code>
         </pre>
         
-        <li>And finally, <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
-           <code>
-
-      finally
-      {
-         if (connection != null)
-         {
-            // Step 14. Be sure to close our JMS resources!
-            connection.close();
-         }
-      }
-           </code>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
         </pre>
 
 

Modified: trunk/examples/jms/topic/src/org/jboss/jms/example/TopicExample.java
===================================================================
--- trunk/examples/jms/topic/src/org/jboss/jms/example/TopicExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/topic/src/org/jboss/jms/example/TopicExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -46,13 +46,14 @@
       new TopicExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
+      InitialContext initialContext = null;
       try
       {
          ///Step 1. Create an initial context to perform the JNDI lookup.
-         InitialContext initialContext = getContext();
+         initialContext = getContext();
 
          //Step 2. perform a lookup on the topic
          Topic topic = (Topic) initialContext.lookup("/topic/exampleTopic");
@@ -95,14 +96,22 @@
          messageReceived = (TextMessage) messageConsumer2.receive();
 
          System.out.println("Consumer 2 Received message: " + messageReceived.getText());
+         
+         return true;
       }
       finally
       {
          //Step 14. Be sure to close our JMS resources!
-         if(connection != null)
+         if (connection != null)
          {
             connection.close();
          }
+         
+         // Also the initialContext
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
       }
    }
 }

Modified: trunk/examples/jms/topic-selector/build.xml
===================================================================
--- trunk/examples/jms/topic-selector/build.xml	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/topic-selector/build.xml	2009-04-03 22:36:12 UTC (rev 6311)
@@ -34,13 +34,13 @@
 
    <target name="run">
       <antcall target="runExample">
-         <param name="example.classname" value="org.jboss.jms.example.TopicSelector"/>
+         <param name="example.classname" value="org.jboss.jms.example.TopicSelectorExample"/>
       </antcall>
    </target>
 
    <target name="runRemote">
       <antcall target="runExample">
-         <param name="example.classname" value="org.jboss.jms.example.TopicSelector"/>
+         <param name="example.classname" value="org.jboss.jms.example.TopicSelectorExample"/>
          <param name="jbm.example.runServer" value="false"/>
       </antcall>
    </target>

Modified: trunk/examples/jms/topic-selector/readme.html
===================================================================
--- trunk/examples/jms/topic-selector/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/topic-selector/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -134,25 +134,20 @@
         <pre><code>session.unsubscribe("sub-a1");</code></pre>
 		<pre><code>session.unsubscribe("sub-a2");</code></pre>
         
-        <li>And finally, <b>always</b> remember to close your JMS connections or any other resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
+         <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
-           <code>
-
-      finally
-      {
-         if (initialContext != null)
-         {
-            initialContext.close();
-         }
-      
-         if (connection != null)
-         {
-            // Step 14. Be sure to close our JMS resources!
-            connection.close();
-         }
-      }
-           </code>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
         </pre>
 
 

Modified: trunk/examples/jms/topic-selector/src/org/jboss/jms/example/TopicSelectorExample.java
===================================================================
--- trunk/examples/jms/topic-selector/src/org/jboss/jms/example/TopicSelectorExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/topic-selector/src/org/jboss/jms/example/TopicSelectorExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -42,7 +42,7 @@
       new TopicSelectorExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
       
@@ -153,17 +153,19 @@
          messageConsumer1.close();
          messageConsumer2.close();
          messageConsumer3.close();
+         
+         return true;
 
       }
       finally
       {
+         // Step 15. Be sure to close our JMS resources!
          if (initialContext != null)
          {
             initialContext.close();
          }
          if (connection != null)
          {
-            // Step 15. Be sure to close our JMS resources!
             connection.close();
          }
       }

Modified: trunk/examples/jms/transactional/readme.html
===================================================================
--- trunk/examples/jms/transactional/readme.html	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/transactional/readme.html	2009-04-03 22:36:12 UTC (rev 6311)
@@ -103,25 +103,20 @@
         </pre>
 
 
-	<li>And finally (no pun intended), <b>always</b> remember to close your JMS connections after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its session, consumer, producer and browser objects. Also remember to close the initial context</li>
+        <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
 
         <pre>
-           <code>
-
-      finally
-      {
-         if(connection != null)
-         {
-            // Step 18. Be sure to close our JMS resources!
-            connection.close();
-         }
-         if(initialContext != null)
-         {
-            // Step 19. Also close initial context!
-            initialContext.close();
-         }
-      }
-           </code>
+           <code>finally
+           {
+              if (initialContext != null)
+              {
+                initialContext.close();
+              }
+              if (connection != null)
+              {
+                 connection.close();
+              }
+           }</code>
         </pre>
          
      </ol>

Modified: trunk/examples/jms/transactional/src/org/jboss/jms/example/TransactionalExample.java
===================================================================
--- trunk/examples/jms/transactional/src/org/jboss/jms/example/TransactionalExample.java	2009-04-03 21:58:38 UTC (rev 6310)
+++ trunk/examples/jms/transactional/src/org/jboss/jms/example/TransactionalExample.java	2009-04-03 22:36:12 UTC (rev 6311)
@@ -42,7 +42,7 @@
       new TransactionalExample().run(args);
    }
 
-   public void runExample() throws Exception
+   public boolean runExample() throws Exception
    {
       Connection connection = null;
       InitialContext initialContext = null;
@@ -118,8 +118,16 @@
          //Step 17. Receive the message again. Nothing should be received.
          receivedMessage = (TextMessage) messageConsumer.receive(5000);
          
+         if (receivedMessage != null)
+         {
+            // This was not supposed to happen
+            return false;
+         }
+         
          System.out.println("Message received after receive commit: " + receivedMessage);
          
+         return true;
+         
       }
       finally
       {




More information about the jboss-cvs-commits mailing list