001: /*
002: * Copyright (c) 1998-2002 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.naming;
030:
031: import com.caucho.log.Log;
032: import com.caucho.util.L10N;
033:
034: import javax.naming.Name;
035: import javax.naming.NamingEnumeration;
036: import javax.naming.directory.Attributes;
037: import javax.naming.directory.DirContext;
038: import javax.naming.directory.ModificationItem;
039: import javax.naming.directory.SearchControls;
040: import java.util.Hashtable;
041: import java.util.logging.Logger;
042:
043: /**
044: * Resin's implementation of the JNDI <code>DirContext</code>.
045: * The actual storage
046: * of the persistent data is in the <code>AbstractModel</code>.
047: *
048: * <p>The <code>DirContextImpl</code> is just a Visitor around
049: * the <code>AbstractModel</code> which also encapsulate
050: * the JNDI environment.
051: *
052: * <p>In JNDI, each <code>Context</code> is a <model, env> pair.
053: * Each client might pass a different environment
054: * to the <code>InitialContext</code> so each <code>ContextImpl</code>
055: * must be unique for each client. (Granted, this is a bit wasteful of
056: * space which is why JNDI values should be cached.)
057: *
058: * <p>Applications which want a different model can still use
059: * <code>ContextImpl</code> and specify the root
060: * object for <code>AbstractModel</code>. <code>ContextImpl</code> will
061: * take care of the JNDI API for the model.
062: */
063: public class DirContextImpl extends ContextImpl implements DirContext {
064: protected static L10N L = new L10N(DirContextImpl.class);
065: protected static Logger log = Log.open(DirContextImpl.class);
066:
067: /**
068: * Creates a <code>DirContextImpl</code>.
069: *
070: * @param model The underlying storage node.
071: * @param env The client's JNDI environment.
072: */
073: public DirContextImpl(AbstractModel model, Hashtable env) {
074: super (model, env);
075: }
076:
077: /**
078: * Creates a <code>DirContextImpl</code>.
079: *
080: * @param name JNDI name, used for error messages, etc.
081: * @param model The underlying storage node.
082: * @param env The client's JNDI environment.
083: */
084: public DirContextImpl(String name, AbstractModel model,
085: Hashtable env) {
086: super (name, model, env);
087: }
088:
089: /**
090: * Creates a new instance of the <code>ContextImpl</code>. Subclasses will
091: * override this method to return a new instance of the subclass.
092: *
093: * @param name the JNDI name for the new context
094: * @param model the underlying storage node
095: * @param env the client's JNDI environment.
096: *
097: * @return a new instance of the implementing class.
098: */
099: protected ContextImpl create(String name, AbstractModel model,
100: Hashtable env) {
101: return new DirContextImpl(name, model, env);
102: }
103:
104: // stubs for now
105:
106: public void bind(Name name, Object obj, Attributes attrs) {
107: throw new UnsupportedOperationException();
108: }
109:
110: public void bind(String name, Object obj, Attributes attrs) {
111: throw new UnsupportedOperationException();
112: }
113:
114: public DirContext createSubcontext(Name name, Attributes attrs) {
115: throw new UnsupportedOperationException();
116: }
117:
118: public DirContext createSubcontext(String name, Attributes attrs) {
119: throw new UnsupportedOperationException();
120: }
121:
122: public Attributes getAttributes(Name name) {
123: throw new UnsupportedOperationException();
124: }
125:
126: public Attributes getAttributes(String name) {
127: throw new UnsupportedOperationException();
128: }
129:
130: public Attributes getAttributes(Name name, String[] attrIds) {
131: throw new UnsupportedOperationException();
132: }
133:
134: public Attributes getAttributes(String name, String[] attrIds) {
135: throw new UnsupportedOperationException();
136: }
137:
138: public DirContext getSchema(Name name) {
139: throw new UnsupportedOperationException();
140: }
141:
142: public DirContext getSchema(String name) {
143: throw new UnsupportedOperationException();
144: }
145:
146: public DirContext getSchemaClassDefinition(Name name) {
147: throw new UnsupportedOperationException();
148: }
149:
150: public DirContext getSchemaClassDefinition(String name) {
151: throw new UnsupportedOperationException();
152: }
153:
154: public void modifyAttributes(Name name, int mod_op, Attributes attrs) {
155: throw new UnsupportedOperationException();
156: }
157:
158: public void modifyAttributes(String name, int mod_op,
159: Attributes attrs) {
160: throw new UnsupportedOperationException();
161: }
162:
163: public void modifyAttributes(Name name, ModificationItem[] mods) {
164: throw new UnsupportedOperationException();
165: }
166:
167: public void modifyAttributes(String name, ModificationItem[] mods) {
168: throw new UnsupportedOperationException();
169: }
170:
171: public void rebind(Name name, Object obj, Attributes attrs) {
172: throw new UnsupportedOperationException();
173: }
174:
175: public void rebind(String name, Object obj, Attributes attrs) {
176: throw new UnsupportedOperationException();
177: }
178:
179: public NamingEnumeration search(Name name, Attributes attrs) {
180: throw new UnsupportedOperationException();
181: }
182:
183: public NamingEnumeration search(String name, Attributes attrs) {
184: throw new UnsupportedOperationException();
185: }
186:
187: public NamingEnumeration search(Name name, Attributes attrs,
188: String[] args) {
189: throw new UnsupportedOperationException();
190: }
191:
192: public NamingEnumeration search(String name, Attributes attrs,
193: String[] args) {
194: throw new UnsupportedOperationException();
195: }
196:
197: public NamingEnumeration search(Name name, String filterExpr,
198: Object[] filterArgs, SearchControls cons) {
199: throw new UnsupportedOperationException();
200: }
201:
202: public NamingEnumeration search(String name, String filterExpr,
203: Object[] filterArgs, SearchControls cons) {
204: throw new UnsupportedOperationException();
205: }
206:
207: public NamingEnumeration search(Name name, String filterExpr,
208: SearchControls cons) {
209: throw new UnsupportedOperationException();
210: }
211:
212: public NamingEnumeration search(String name, String filterExpr,
213: SearchControls cons) {
214: throw new UnsupportedOperationException();
215: }
216:
217: /**
218: * Returns a string value.
219: */
220: public String toString() {
221: return "[DirContextImpl " + _name + "]";
222: }
223: }
|