summaryrefslogtreecommitdiff
path: root/qpid/doc/book/src/Using-Qpid-with-other-JNDI-Providers.xml
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/doc/book/src/Using-Qpid-with-other-JNDI-Providers.xml')
-rw-r--r--qpid/doc/book/src/Using-Qpid-with-other-JNDI-Providers.xml215
1 files changed, 215 insertions, 0 deletions
diff --git a/qpid/doc/book/src/Using-Qpid-with-other-JNDI-Providers.xml b/qpid/doc/book/src/Using-Qpid-with-other-JNDI-Providers.xml
new file mode 100644
index 0000000000..2bd7d761ef
--- /dev/null
+++ b/qpid/doc/book/src/Using-Qpid-with-other-JNDI-Providers.xml
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+<chapter>
+
+ <title>
+ Using Qpid with other JNDI Providers
+ </title>
+
+ <section role="h2" id="UsingQpidwithotherJNDIProviders-HowtouseaJNDIProvider">
+
+ <title> How to use a JNDI Provider </title>
+
+ <para>
+ Qpid will work with any JNDI provider capable of storing Java
+ objects. We have a task to add our own initial context factory,
+ but until that's available ....
+ </para>
+
+ <para>
+ First you must select a JNDI provider to use. If you aren't
+ already using an application server (i.e. Tomcat ?) which
+ provides JNDI support you could consider using either:
+ </para>
+
+ <itemizedlist>
+ <listitem><para>Apache's <xref linkend="qpid_index"/>
+ which provides an LDAP JNDI implementation
+ </para></listitem>
+ </itemizedlist>
+
+ <itemizedlist>
+ <listitem>
+ <para>OR the SUN JNDI SPI for the FileSystem which can be
+ downloaded from <xref linkend="qpid_index"/>
+ </para>
+ <itemizedlist>
+ <listitem><para>Click : Download JNDI 1.2.1 &amp; More button
+ </para></listitem>
+ <listitem><para>Download: File System Service Provider, 1.2 Beta 3
+ </para></listitem>
+ <listitem><para>and then add the two jars in the lib dir to your class path.
+ </para></listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+
+
+ <para>
+ There are two steps to using JNDI objects.
+ </para>
+
+ <itemizedlist>
+ <listitem><para>Bind : Which stores a reference to a JMS
+ Object in the provider.</para></listitem>
+ <listitem><para>Lookup : Which tries to retrieve the
+ reference and create the JMS Object. </para></listitem>
+ </itemizedlist>
+
+ <para>
+ There are two objects that would normally be stored in JNDI.
+ </para>
+
+ <itemizedlist>
+ <listitem><para>A ConnectionFactory
+ </para></listitem>
+ <listitem><para>A Destination (Queue or Topic)
+ </para></listitem>
+ </itemizedlist>
+
+
+ <section role="h3" id="UsingQpidwithotherJNDIProviders-Binding">
+ <title>
+ Binding
+ </title>
+
+ <para>
+ Then you need to setup the values that the JNDI provider will
+ used to bind your references, something like this:
+ </para>
+
+ <example>
+ <title>Setup JNDI</title>
+
+
+ <programlisting>
+Hashtable env = new Hashtable(11);
+ env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
+ env.put(Context.PROVIDER_URL,LOCAL_FILE_PATH_FOR_STORING_BINDS_PATH_MUST_EXIST);
+</programlisting>
+</example>
+
+ <para>
+ These values are then used to create a context to bind your
+ references.
+ </para>
+
+<example>
+ <title>Perform Binding of ConnectionFactory</title>
+
+
+ <programlisting>
+try
+{
+ Context ctx = new InitialContext(env);
+
+ // Create the object to be bound in this case a ConnectionFactory
+ ConnectionFactory factory = null;
+
+ try
+ {
+ factory = new AMQConnectionFactory(CONNECTION_URL);
+ try
+ {
+ ctx.bind(binding, factory);
+ }
+ catch (NamingException e)
+ {
+ //Handle problems with binding. Such as the binding already exists.
+ }
+ }
+ catch (URLSyntaxException amqe)
+ {
+ //Handle any exception with creating ConnnectionFactory
+ }
+}
+catch (NamingException e)
+{
+ //Handle problem creating the Context.
+}
+</programlisting>
+</example>
+
+ <para>
+ To bind a queue instead simply create a AMQQueue object and use
+ that in the binding call.
+ </para>
+
+<example>
+<title> Bind a AMQQueue</title>
+ <programlisting>
+AMQQueue queue = new AMQQueue(QUEUE_URL);
+ctx.bind(binding, queue);
+</programlisting>
+</example>
+ </section>
+
+ <section role="h3" id="UsingQpidwithotherJNDIProviders-Lookup">
+ <title>
+ Lookup
+ </title>
+ <para>
+ You can then get a queue connection factory from the JNDI
+ context.
+ </para>
+
+
+<example>
+<title> Perform Binding of ConnectionFactory</title>
+
+
+ <programlisting>
+ConnectionFactory factory;
+try
+{
+ factory= (ConnectionFactory)ctx.lookup(binding);
+}
+catch (NamingException e)
+{
+ //Handle problems with lookup. Such as binding does not exist.
+}
+</programlisting>
+</example>
+
+ <para>
+ Note that you need not cast the bound object back to an
+ AMQConnectionFactory so all your current JMS apps that
+ use JNDI can start using Qpid straight away.
+ </para>
+
+ <!--h2-->
+ </section>
+
+ <section role="h2" id="UsingQpidwithotherJNDIProviders-HowtocreateaTopicConnectionFactoryandQueueConnectionFactory"><title>
+ How to create a TopicConnectionFactory and
+ QueueConnectionFactory
+ </title>
+ <para>
+ AMQConnectionFactory implements TopicConnectionFactory and
+ QueueConnectionFactory as well as the ConnectionFactory.
+ </para>
+<!--h3-->
+ </section>
+<!--h2-->
+ </section>
+</chapter>