KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > jbi > transport > mock > MockInitialContext


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: MockInitialContext.java 11:00:16 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.jbi.transport.mock;
23
24 import java.util.Hashtable JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import javax.naming.Binding JavaDoc;
28 import javax.naming.Context JavaDoc;
29 import javax.naming.InitialContext JavaDoc;
30 import javax.naming.Name JavaDoc;
31 import javax.naming.NameClassPair JavaDoc;
32 import javax.naming.NameParser JavaDoc;
33 import javax.naming.NamingException JavaDoc;
34
35 /**
36  *
37  * @author ddesjardins - eBMWebsourcing
38  */

39 public class MockInitialContext extends InitialContext JavaDoc {
40
41     protected boolean unbind;
42
43     private MockContext context;
44
45     public MockInitialContext() throws NamingException JavaDoc {
46         super();
47         context = new MockContext();
48     }
49
50     public Object JavaDoc addToEnvironment(String JavaDoc propName, Object JavaDoc propVal)
51         throws NamingException JavaDoc {
52         return context.addToEnvironment(propName, propVal);
53     }
54
55     public void bind(Name JavaDoc name, Object JavaDoc obj) throws NamingException JavaDoc {
56         context.bind(name, obj);
57     }
58
59     public void bind(String JavaDoc name, Object JavaDoc obj) throws NamingException JavaDoc {
60         context.bind(name, obj);
61     }
62
63     public void close() throws NamingException JavaDoc {
64         context.close();
65     }
66
67     public Name JavaDoc composeName(Name JavaDoc name, Name JavaDoc prefix) throws NamingException JavaDoc {
68         return context.composeName(name, prefix);
69     }
70
71     public String JavaDoc composeName(String JavaDoc name, String JavaDoc prefix)
72         throws NamingException JavaDoc {
73         return context.composeName(name, prefix);
74     }
75
76     public Context JavaDoc createSubcontext(Name JavaDoc name) throws NamingException JavaDoc {
77         return context.createSubcontext(name);
78     }
79
80     public Context JavaDoc createSubcontext(String JavaDoc name) throws NamingException JavaDoc {
81         return context.createSubcontext(name);
82     }
83
84     public void destroySubcontext(Name JavaDoc name) throws NamingException JavaDoc {
85         context.destroySubcontext(name);
86     }
87
88     public void destroySubcontext(String JavaDoc name) throws NamingException JavaDoc {
89         context.destroySubcontext(name);
90     }
91
92     public boolean equals(Object JavaDoc obj) {
93         return context.equals(obj);
94     }
95
96     public Map JavaDoc<String JavaDoc, Object JavaDoc> getBindings() {
97         return context.getBindings();
98     }
99
100     public Hashtable JavaDoc<?, ?> getEnvironment() throws NamingException JavaDoc {
101         return context.getEnvironment();
102     }
103
104     public String JavaDoc getNameInNamespace() throws NamingException JavaDoc {
105         return context.getNameInNamespace();
106     }
107
108     public NameParser JavaDoc getNameParser(Name JavaDoc name) throws NamingException JavaDoc {
109         return context.getNameParser(name);
110     }
111
112     public NameParser JavaDoc getNameParser(String JavaDoc name) throws NamingException JavaDoc {
113         return context.getNameParser(name);
114     }
115
116     public int hashCode() {
117         return context.hashCode();
118     }
119
120     public boolean isUnbind() {
121         return unbind;
122     }
123
124     public MockNamingEnumeration<NameClassPair JavaDoc> list(Name JavaDoc name)
125         throws NamingException JavaDoc {
126         return context.list(name);
127     }
128
129     public MockNamingEnumeration<NameClassPair JavaDoc> list(String JavaDoc name)
130         throws NamingException JavaDoc {
131         return context.list(name);
132     }
133
134     public MockNamingEnumeration<Binding JavaDoc> listBindings(Name JavaDoc name)
135         throws NamingException JavaDoc {
136         return context.listBindings(name);
137     }
138
139     public MockNamingEnumeration<Binding JavaDoc> listBindings(String JavaDoc name)
140         throws NamingException JavaDoc {
141         return context.listBindings(name);
142     }
143
144     public Object JavaDoc lookup(Name JavaDoc name) throws NamingException JavaDoc {
145         return context.lookup(name);
146     }
147
148     public Object JavaDoc lookup(String JavaDoc name) throws NamingException JavaDoc {
149         return context.lookup(name);
150     }
151
152     public Object JavaDoc lookupLink(Name JavaDoc name) throws NamingException JavaDoc {
153         return context.lookupLink(name);
154     }
155
156     public Object JavaDoc lookupLink(String JavaDoc name) throws NamingException JavaDoc {
157         return context.lookupLink(name);
158     }
159
160     public void rebind(Name JavaDoc name, Object JavaDoc obj) throws NamingException JavaDoc {
161         context.rebind(name, obj);
162     }
163
164     public void rebind(String JavaDoc name, Object JavaDoc obj) throws NamingException JavaDoc {
165         context.rebind(name, obj);
166     }
167
168     public Object JavaDoc removeFromEnvironment(String JavaDoc propName) throws NamingException JavaDoc {
169         return context.removeFromEnvironment(propName);
170     }
171
172     public void rename(Name JavaDoc oldName, Name JavaDoc newName) throws NamingException JavaDoc {
173         context.rename(oldName, newName);
174     }
175
176     public void rename(String JavaDoc oldName, String JavaDoc newName) throws NamingException JavaDoc {
177         context.rename(oldName, newName);
178     }
179
180     public void setBindings(Map JavaDoc<String JavaDoc, Object JavaDoc> bindings) {
181         context.setBindings(bindings);
182     }
183
184     public void setUnbind(boolean unbind) {
185         this.unbind = unbind;
186     }
187
188     public String JavaDoc toString() {
189         return context.toString();
190     }
191
192     public void unbind(Name JavaDoc name) throws NamingException JavaDoc {
193         context.unbind(name);
194     }
195
196     protected boolean throwsException;
197
198     public void unbind(String JavaDoc name) throws NamingException JavaDoc {
199         if (throwsException) {
200             throw new NamingException JavaDoc();
201         }
202         context.unbind(name);
203         unbind = true;
204     }
205
206     public boolean isThrowsException() {
207         return throwsException;
208     }
209
210     public void setThrowsException(boolean throwsException) {
211         this.throwsException = throwsException;
212     }
213
214     public MockContext getContext() {
215         return context;
216     }
217
218     public void setContext(MockContext context) {
219         this.context = context;
220     }
221
222 }
223
Popular Tags