You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jakarta.apache.org by se...@apache.org on 2010/06/22 15:11:39 UTC
svn commit: r956876 -
/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java
Author: sebb
Date: Tue Jun 22 13:11:39 2010
New Revision: 956876
URL: http://svn.apache.org/viewvc?rev=956876&view=rev
Log:
Add lookupQueue and lookupTopic utility methods
Modified:
jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java
Modified: jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java?rev=956876&r1=956875&r2=956876&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java (original)
+++ jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/Utils.java Tue Jun 22 13:11:39 2010
@@ -23,11 +23,15 @@ import java.util.Enumeration;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
+import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueSession;
+import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicPublisher;
import javax.jms.TopicSession;
+import javax.naming.Context;
+import javax.naming.NamingException;
import org.apache.log.Logger;
@@ -134,4 +138,36 @@ public final class Utils {
return sb;
}
+ /**
+ * Method will lookup a given topic using JNDI.
+ *
+ * @param context
+ * @param name the topic name
+ * @return the topic
+ * @throws NamingException if the name cannot be found as a Topic
+ */
+ public static Topic lookupTopic(Context context, String name) throws NamingException {
+ Object o = context.lookup(name);
+ if (o instanceof Topic){
+ return (Topic) o;
+ }
+ throw new NamingException("Found: "+name+"; expected Topic, but was: "+o.getClass().getName());
+ }
+
+ /**
+ * Method will lookup a given topic using JNDI.
+ *
+ * @param context
+ * @param name the Queue name
+ * @return the Queue
+ * @throws NamingException if the name cannot be found as a Queue
+ */
+ public static Queue lookupQueue(Context context, String name) throws NamingException {
+ Object o = context.lookup(name);
+ if (o instanceof Queue){
+ return (Queue) o;
+ }
+ throw new NamingException("Found: "+name+"; expected Queue, but was: "+o.getClass().getName());
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org