[jboss-cvs] JBoss Messaging SVN: r6526 - trunk/examples/javaee/hajndi/src/org/jboss/javaee/example.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 22 12:04:10 EDT 2009
Author: timfox
Date: 2009-04-22 12:04:10 -0400 (Wed, 22 Apr 2009)
New Revision: 6526
Modified:
trunk/examples/javaee/hajndi/src/org/jboss/javaee/example/HAJNDIExample.java
Log:
some tweaks to example
Modified: trunk/examples/javaee/hajndi/src/org/jboss/javaee/example/HAJNDIExample.java
===================================================================
--- trunk/examples/javaee/hajndi/src/org/jboss/javaee/example/HAJNDIExample.java 2009-04-22 15:54:12 UTC (rev 6525)
+++ trunk/examples/javaee/hajndi/src/org/jboss/javaee/example/HAJNDIExample.java 2009-04-22 16:04:10 UTC (rev 6526)
@@ -28,6 +28,11 @@
import javax.naming.InitialContext;
/**
+ *
+ * This example demonstrates the use of HA-JNDI to look-up JMS Connection Factories from JNDI.
+ *
+ * For more information please see the readme.html file.
+ *
* @author <a href="mailto:csuconic at jboss.org">Clebert Suconic</a>
*/
public class HAJNDIExample
@@ -36,46 +41,46 @@
{
Connection connection = null;
InitialContext initialContext = null;
+
try
{
-
-
- //Step 1. Create an initial context to perform the JNDI lookup.
- // This JNDI is performing auto-discovery of the servers, by using the default UDP properties.
- // You will find more information at the JBoss Application Server Documentation:
- // http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Clustering_Guide/5/html/clustering-jndi.html
-
- Hashtable jndiParameters = new Hashtable();
+ // Step 1. Create an initial context to perform the JNDI lookup.
+ // This JNDI is performing auto-discovery of the servers, by using the default UDP properties.
+ // You will find more information at the JBoss Application Server Documentation:
+ // http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Clustering_Guide/5/html/clustering-jndi.html
+
+ Hashtable<String, String> jndiParameters = new Hashtable<String, String>();
jndiParameters.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
jndiParameters.put("java.naming.factory.url.pkgs=", "org.jboss.naming:org.jnp.interfaces");
-
+
initialContext = new InitialContext(jndiParameters);
for (int i = 0; i < 100; i++)
{
- //Step 2. Perform a lookup on the Connection Factory
- ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
-
- //Step 3. Create a JMS Connection
+ // Step 2. Perform a lookup on the Connection Factory
+ ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
+
+ // Step 3. Create a JMS Connection
connection = cf.createConnection();
connection.close();
-
- //Step 4. Kill any of the servers. The Lookups will still be performed ok as long as you keep at least one server alive.
- System.out.println("Connection " + i + " was created. If you kill any of the servers now, the lookup operation on Step 2 will still work fine");
+
+ // Step 4. Kill any of the servers. The Lookups will still be performed ok as long as you keep at least one
+ // server alive.
+ System.out.println("Connection " + i +
+ " was created. If you kill any of the servers now, the lookup operation on Step 2 will still work fine");
Thread.sleep(5000);
}
-
+
System.out.println("Done");
-
}
finally
{
- //Step 5. Be sure to close our JMS resources!
+ // Step 5. Be sure to close our JMS resources!
if (initialContext != null)
{
initialContext.close();
}
- if(connection != null)
+ if (connection != null)
{
connection.close();
}
More information about the jboss-cvs-commits
mailing list