KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ubermq > jms > client > impl > JMSInitialContext


1 package com.ubermq.jms.client.impl;
2
3 import com.ubermq.jms.client.*;
4 import java.util.*;
5 import javax.naming.*;
6
7 /**
8  * A very simple, read-only <code>InitialContext</code> implementation
9  * that uses special naming conventions to provide access to
10  * JMS administered objects. This can be done without the overhead
11  * of actually using JNDI for this purpose.<P>
12  *
13  * The PROVIDER_URL environment property indicates the URL
14  * passed to ConnectionFactory objects upon creation.<P>
15  *
16  * The following names are supported:<P>
17  *
18  * <ul>
19  * <li><code>connectionFactory</code>: creates a URLConnectionFactory object
20  * with the PROVIDER_URL environment property as a parameter. The returned
21  * factory object is a JMS 1.1 ConnectionFactory object as well as a
22  * JMS 1.0 TopicConnectionFactory and QueueConnectionFactory (where appropriate).
23  * <li><code>topic:name</code> creates a topic destination with the given name (after the
24  * topic prefix).
25  * <li><code>queue:name</code> creates a queue destination with the given name (after the
26  * prefix).
27  * </ul>
28  *
29  */

30 public final class JMSInitialContext
31     implements Context
32 {
33     public static final String JavaDoc CONNECTION_FACTORY_NAME = "connectionFactory",
34         TOPIC_PREFIX = "topic:",
35         QUEUE_PREFIX = "queue:";
36
37     private Hashtable env;
38
39     public JMSInitialContext(Hashtable env)
40     {
41         this.env = env;
42     }
43
44     public Object JavaDoc lookup(Name name) throws NamingException
45     {
46         return lookup(name.toString());
47     }
48
49     public Object JavaDoc lookup(String JavaDoc name) throws NamingException
50     {
51         if (name.equals(CONNECTION_FACTORY_NAME))
52             return new URLConnectionFactory((String JavaDoc)env.get(InitialContext.PROVIDER_URL));
53         else if (name.startsWith(TOPIC_PREFIX))
54             return new LocalTopic(name.substring(TOPIC_PREFIX.length()));
55         else if (name.startsWith(QUEUE_PREFIX))
56             return new LocalQueue(name.substring(QUEUE_PREFIX.length()));
57         else
58             throw new NamingException("not bound");
59     }
60
61     public Hashtable getEnvironment() throws NamingException
62     {
63         return env;
64     }
65
66     public Object JavaDoc removeFromEnvironment(String JavaDoc propName) throws NamingException
67     {
68         return env.remove(propName);
69     }
70
71     public Object JavaDoc addToEnvironment(String JavaDoc propName, Object JavaDoc propVal) throws NamingException
72     {
73         return env.put(propName, propVal);
74     }
75
76     public NameParser getNameParser(String JavaDoc name) throws NamingException
77     {
78         throw new UnsupportedOperationException JavaDoc();
79     }
80
81     public Context createSubcontext(Name name) throws NamingException
82     {
83         throw new UnsupportedOperationException JavaDoc();
84     }
85
86     public Name composeName(Name name, Name prefix) throws NamingException
87     {
88         throw new UnsupportedOperationException JavaDoc();
89     }
90
91     public void close() throws NamingException
92     {
93     }
94
95     public void rebind(Name name, Object JavaDoc obj) throws NamingException
96     {
97         throw new UnsupportedOperationException JavaDoc();
98     }
99
100     public NamingEnumeration list(String JavaDoc name) throws NamingException
101     {
102         throw new UnsupportedOperationException JavaDoc();
103     }
104
105     public Object JavaDoc lookupLink(Name name) throws NamingException
106     {
107         throw new UnsupportedOperationException JavaDoc();
108     }
109
110     public void rename(String JavaDoc oldName, String JavaDoc newName) throws NamingException
111     {
112         throw new UnsupportedOperationException JavaDoc();
113     }
114
115     public void bind(String JavaDoc name, Object JavaDoc obj) throws NamingException
116     {
117         throw new UnsupportedOperationException JavaDoc();
118     }
119
120     public NameParser getNameParser(Name name) throws NamingException
121     {
122         throw new UnsupportedOperationException JavaDoc();
123     }
124
125     public void rename(Name oldName, Name newName) throws NamingException
126     {
127         throw new UnsupportedOperationException JavaDoc();
128     }
129
130     public void unbind(String JavaDoc name) throws NamingException
131     {
132         throw new UnsupportedOperationException JavaDoc();
133     }
134
135     public NamingEnumeration listBindings(Name name) throws NamingException
136     {
137         throw new UnsupportedOperationException JavaDoc();
138     }
139
140     public NamingEnumeration listBindings(String JavaDoc name) throws NamingException
141     {
142         throw new UnsupportedOperationException JavaDoc();
143     }
144
145     public void destroySubcontext(Name name) throws NamingException
146     {
147         throw new UnsupportedOperationException JavaDoc();
148     }
149
150     public String JavaDoc composeName(String JavaDoc name, String JavaDoc prefix) throws NamingException
151     {
152         throw new UnsupportedOperationException JavaDoc();
153     }
154
155     public String JavaDoc getNameInNamespace() throws NamingException
156     {
157         throw new UnsupportedOperationException JavaDoc();
158     }
159
160     public void destroySubcontext(String JavaDoc name) throws NamingException
161     {
162         throw new UnsupportedOperationException JavaDoc();
163     }
164
165     public Context createSubcontext(String JavaDoc name) throws NamingException
166     {
167         throw new UnsupportedOperationException JavaDoc();
168     }
169
170     public void unbind(Name name) throws NamingException
171     {
172         throw new UnsupportedOperationException JavaDoc();
173     }
174
175     public void bind(Name name, Object JavaDoc obj) throws NamingException
176     {
177         throw new UnsupportedOperationException JavaDoc();
178     }
179
180     public void rebind(String JavaDoc name, Object JavaDoc obj) throws NamingException
181     {
182         throw new UnsupportedOperationException JavaDoc();
183     }
184
185     public NamingEnumeration list(Name name) throws NamingException
186     {
187         throw new UnsupportedOperationException JavaDoc();
188     }
189
190     public Object JavaDoc lookupLink(String JavaDoc name) throws NamingException
191     {
192         throw new UnsupportedOperationException JavaDoc();
193     }
194
195 }
196
Popular Tags