KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > walend > somnifugi > SomniQueueContextFactory


1 package net.walend.somnifugi;
2
3 import java.util.Hashtable JavaDoc;
4 import javax.naming.Context JavaDoc;
5 import javax.naming.spi.InitialContextFactory JavaDoc;
6
7 /**
8 SomniQueueContextFactory is a ContextFactory for shortcutting JNDI. Use it where you want to be able to reconfigure to use JNDI without thinking too hard about it, then configure.
9
10 <code>
11 <pre>
12                 //set things up in JNDI
13                 Hashtable env = new Hashtable(3);
14
15                 env.put(Context.INITIAL_CONTEXT_FACTORY,"net.walend.somnifugi.SomniQueueContextFactory");
16                 env.put(Context.PROVIDER_URL,"http://www.walend.net");
17
18                 // Create the initial context
19                 Context ctx = new InitialContext(env);
20                 
21                 //get the parts
22                 QueueConnection connection = (QueueConnection)ctx.lookup("Connection");
23                 Queue queue = (Queue)ctx.lookup("hotStartTest");
24
25                 ctx.close();
26 </pre>
27 </code>
28
29 @author <a HREF="http://www.jumpi.org">Peter Klauser</a> <a HREF="mailto:klp@users.sourceforge.net">klp@users.sourceforge.net</a>
30 @author <a HREF="http://walend.net">David Walend</a> <a HREF="mailto:david@walend.net">david@walend.net</a>
31 */

32
33 public class SomniQueueContextFactory
34     implements InitialContextFactory JavaDoc
35 {
36     public SomniQueueContextFactory()
37     {
38     }
39 @SuppressWarnings JavaDoc("unchecked")
40     public Context JavaDoc getInitialContext(Hashtable JavaDoc<?,?> environment)
41     {
42         String JavaDoc contextName = (String JavaDoc)environment.get(SomniProperties.QUEUECONTEXTNAMEKEY);
43
44         if(contextName==null)
45             {
46                 contextName = SomniProperties.QUEUEDEFAULTCONTEXTNAME;
47             }
48
49         return new SomniQueueContext(contextName,(Hashtable JavaDoc<Object JavaDoc,Object JavaDoc>)environment);
50     }
51 }
52
53 /*
54 Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 David Walend
55 All rights reserved.
56
57 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
58
59 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
60
61 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
62
63 Neither the name of the SomnifugiJMS Project, walend.net, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission from David Walend.
64
65 Credits in redistributions in source or binary forms must include a link to http://somnifugi.sourceforge.net .
66
67 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 The net.walend.somnifugi.sql92 package is modified code from the openmq project, https://mq.dev.java.net/ , Copyright (c) of Sun, and carries the CDDL license, repeated here: You can obtain a copy of the license at https://glassfish.dev.java.net/public/CDDLv1.0.html. See the License for the specific language governing permissions and limitations under the License.
69
70 =================================================================================
71
72 For more information and the latest version of this software, please see http://somnifugi.sourceforge.net and http://walend.net or email <a HREF="mailto:david@walend.net">david@walend.net</a>.
73
74 */

75
Popular Tags