KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > util > naming > ReadOnlyContext


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22
23 package org.jboss.util.naming;
24
25 import java.util.Hashtable JavaDoc;
26 import javax.naming.Context JavaDoc;
27 import javax.naming.NamingException JavaDoc;
28 import javax.naming.Name JavaDoc;
29 import javax.naming.NameParser JavaDoc;
30 import javax.naming.NamingEnumeration JavaDoc;
31 import javax.naming.OperationNotSupportedException JavaDoc;
32
33 /**
34  A JNDI context wrapper implementation that delegates read-only methods to
35  its delegate Context, and throws OperationNotSupportedException for any
36  method with a side-effect.
37
38  @author Scott.Stark@jboss.org
39  @version $Revision: 1958 $
40  */

41 public class ReadOnlyContext implements Context JavaDoc
42 {
43    /** The actual context we impose the read-only behavior on */
44    private Context JavaDoc delegate;
45
46    public ReadOnlyContext(Context JavaDoc delegate)
47    {
48       this.delegate = delegate;
49    }
50
51 // Supported methods -----------------------------------------------------------
52
public void close()
53       throws NamingException JavaDoc
54    {
55       delegate.close();
56    }
57
58    public String JavaDoc composeName(String JavaDoc name, String JavaDoc prefix)
59       throws NamingException JavaDoc
60    {
61       return delegate.composeName(name, prefix);
62    }
63
64    public Name JavaDoc composeName(Name JavaDoc name, Name JavaDoc prefix)
65       throws NamingException JavaDoc
66    {
67       return delegate.composeName(name, prefix);
68    }
69
70    public String JavaDoc getNameInNamespace()
71       throws NamingException JavaDoc
72    {
73       return delegate.getNameInNamespace();
74    }
75
76    public Hashtable JavaDoc getEnvironment()
77       throws NamingException JavaDoc
78    {
79       return delegate.getEnvironment();
80    }
81
82    public Object JavaDoc lookup(String JavaDoc name)
83       throws NamingException JavaDoc
84    {
85       return delegate.lookup(name);
86    }
87
88    public Object JavaDoc lookupLink(String JavaDoc name)
89       throws NamingException JavaDoc
90    {
91       return delegate.lookupLink(name);
92    }
93
94    public Object JavaDoc lookup(Name JavaDoc name)
95       throws NamingException JavaDoc
96    {
97       return delegate.lookup(name);
98    }
99
100    public Object JavaDoc lookupLink(Name JavaDoc name)
101       throws NamingException JavaDoc
102    {
103       return delegate.lookupLink(name);
104    }
105
106    public NameParser JavaDoc getNameParser(String JavaDoc name)
107       throws NamingException JavaDoc
108    {
109       return delegate.getNameParser(name);
110    }
111
112    public NameParser JavaDoc getNameParser(Name JavaDoc name)
113       throws NamingException JavaDoc
114    {
115       return delegate.getNameParser(name);
116    }
117
118    public NamingEnumeration JavaDoc list(String JavaDoc name)
119       throws NamingException JavaDoc
120    {
121       return delegate.list(name);
122    }
123
124    public NamingEnumeration JavaDoc listBindings(String JavaDoc name)
125       throws NamingException JavaDoc
126    {
127       return delegate.listBindings(name);
128    }
129
130    public NamingEnumeration JavaDoc list(Name JavaDoc name)
131       throws NamingException JavaDoc
132    {
133       return delegate.list(name);
134    }
135
136    public NamingEnumeration JavaDoc listBindings(Name JavaDoc name)
137       throws NamingException JavaDoc
138    {
139       return delegate.listBindings(name);
140    }
141
142 // Unsupported methods ---------------------------------------------------------
143

144    public Object JavaDoc addToEnvironment(String JavaDoc propName, Object JavaDoc propVal)
145       throws NamingException JavaDoc
146    {
147       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
148    }
149
150    public void bind(String JavaDoc name, Object JavaDoc obj)
151       throws NamingException JavaDoc
152    {
153       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
154    }
155    public void bind(Name JavaDoc name, Object JavaDoc obj)
156       throws NamingException JavaDoc
157    {
158       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
159    }
160
161    public Context JavaDoc createSubcontext(String JavaDoc name)
162       throws NamingException JavaDoc
163    {
164       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
165    }
166
167    public Context JavaDoc createSubcontext(Name JavaDoc name)
168       throws NamingException JavaDoc
169    {
170       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
171    }
172
173    public void destroySubcontext(String JavaDoc name)
174       throws NamingException JavaDoc
175    {
176       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
177    }
178
179    public void destroySubcontext(Name JavaDoc name)
180       throws NamingException JavaDoc
181    {
182       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
183    }
184
185    public Object JavaDoc removeFromEnvironment(String JavaDoc propName)
186       throws NamingException JavaDoc
187    {
188       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
189    }
190
191    public void rebind(String JavaDoc name, Object JavaDoc obj)
192       throws NamingException JavaDoc
193    {
194       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
195    }
196
197    public void rebind(Name JavaDoc name, Object JavaDoc obj)
198       throws NamingException JavaDoc
199    {
200       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
201    }
202
203    public void rename(String JavaDoc oldName, String JavaDoc newName)
204       throws NamingException JavaDoc
205    {
206       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
207    }
208
209    public void rename(Name JavaDoc oldName, Name JavaDoc newName)
210       throws NamingException JavaDoc
211    {
212       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
213    }
214
215    public void unbind(String JavaDoc name)
216       throws NamingException JavaDoc
217    {
218       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
219    }
220    public void unbind(Name JavaDoc name)
221       throws NamingException JavaDoc
222    {
223       throw new OperationNotSupportedException JavaDoc("This is a read-only Context");
224    }
225
226 }
227
Popular Tags