0N/A/*
2362N/A * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.jndi.toolkit.ctx;
0N/A
0N/Aimport javax.naming.*;
0N/Aimport javax.naming.directory.*;
0N/A
0N/Aimport javax.naming.spi.ResolveResult;
0N/A
0N/A/* Direct subclasses of ComponentDirContext must provide implementations for
0N/A * the abstract c_ DirContext methods, and override the c_ Context methods
0N/A * (which are no longer abstract because they have been overriden by
0N/A * AtomicContext, the direct superclass of PartialDSCompositeContext).
0N/A *
0N/A * If the subclass is supports implicit nns, it must override all the
0N/A * c_*_nns methods corresponding to those in DirContext and Context.
0N/A * See ComponentContext for details.
0N/A *
0N/A * @author Rosanna Lee
0N/A */
0N/A
0N/Apublic abstract class ComponentDirContext extends PartialCompositeDirContext {
0N/A
0N/A protected ComponentDirContext () {
0N/A _contextType = _COMPONENT;
0N/A }
0N/A
0N/A// ------ Abstract methods whose implementations are provided by subclass
0N/A
0N/A /* Equivalent to methods in DirContext */
0N/A protected abstract Attributes c_getAttributes(Name name,
0N/A String[] attrIds,
0N/A Continuation cont)
0N/A throws NamingException;
0N/A
0N/A protected abstract void c_modifyAttributes(Name name, int mod_op,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException;
0N/A
0N/A protected abstract void c_modifyAttributes(Name name,
0N/A ModificationItem[] mods,
0N/A Continuation cont)
0N/A throws NamingException;
0N/A
0N/A protected abstract void c_bind(Name name, Object obj,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException;
0N/A
0N/A protected abstract void c_rebind(Name name, Object obj,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException;
0N/A
0N/A protected abstract DirContext c_createSubcontext(Name name,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException;
0N/A
0N/A protected abstract NamingEnumeration c_search(Name name,
0N/A Attributes matchingAttributes,
0N/A String[] attributesToReturn,
0N/A Continuation cont)
0N/A throws NamingException;
0N/A
0N/A protected abstract NamingEnumeration c_search(Name name,
0N/A String filter,
0N/A SearchControls cons,
0N/A Continuation cont)
0N/A throws NamingException;
0N/A
0N/A protected abstract NamingEnumeration c_search(Name name,
0N/A String filterExpr,
0N/A Object[] filterArgs,
0N/A SearchControls cons,
0N/A Continuation cont)
0N/A throws NamingException;
0N/A
0N/A protected abstract DirContext c_getSchema(Name name, Continuation cont)
0N/A throws NamingException;
0N/A
0N/A protected abstract DirContext c_getSchemaClassDefinition(Name name,
0N/A Continuation cont)
0N/A throws NamingException;
0N/A
0N/A// ------- default implementations of c_*_nns methods from DirContext
0N/A
0N/A // The following methods are called when the DirContext methods
0N/A // are invoked with a name that has a trailing slash.
0N/A // For naming systems that support implicit nns,
0N/A // the trailing slash signifies the implicit nns.
0N/A // For such naming systems, override these c_*_nns methods.
0N/A //
0N/A // For naming systems that support junctions (explicit nns),
0N/A // the trailing slash is meaningless because a junction does not
0N/A // have an implicit nns. The default implementation here
0N/A // throws a NameNotFoundException for such names.
0N/A // If a context wants to accept a trailing slash as having
0N/A // the same meaning as the same name without a trailing slash,
0N/A // then it should override these c_*_nns methods.
0N/A
0N/A // See ComponentContext for details.
0N/A
0N/A protected Attributes c_getAttributes_nns(Name name,
0N/A String[] attrIds,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A return null;
0N/A }
0N/A
0N/A protected void c_modifyAttributes_nns(Name name,
0N/A int mod_op,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A }
0N/A
0N/A protected void c_modifyAttributes_nns(Name name,
0N/A ModificationItem[] mods,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A }
0N/A
0N/A protected void c_bind_nns(Name name,
0N/A Object obj,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A }
0N/A
0N/A protected void c_rebind_nns(Name name,
0N/A Object obj,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A }
0N/A
0N/A protected DirContext c_createSubcontext_nns(Name name,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A return null;
0N/A }
0N/A
0N/A protected NamingEnumeration c_search_nns(Name name,
0N/A Attributes matchingAttributes,
0N/A String[] attributesToReturn,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A return null;
0N/A }
0N/A
0N/A protected NamingEnumeration c_search_nns(Name name,
0N/A String filter,
0N/A SearchControls cons,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A return null;
0N/A }
0N/A
0N/A protected NamingEnumeration c_search_nns(Name name,
0N/A String filterExpr,
0N/A Object[] filterArgs,
0N/A SearchControls cons,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A return null;
0N/A }
0N/A
0N/A protected DirContext c_getSchema_nns(Name name, Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A return null;
0N/A }
0N/A
0N/A protected DirContext c_getSchemaClassDefinition_nns(Name name, Continuation cont)
0N/A throws NamingException {
0N/A c_processJunction_nns(name, cont);
0N/A return null;
0N/A }
0N/A
0N/A// ------- implementations of p_ DirContext methods using corresponding
0N/A// ------- DirContext c_ and c_*_nns methods
0N/A
0N/A /* Implements for abstract methods declared in PartialCompositeDirContext */
0N/A protected Attributes p_getAttributes(Name name,
0N/A String[] attrIds,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A Attributes answer = null;
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A answer = c_getAttributes_nns(res.getHead(), attrIds, cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A answer = c_getAttributes(res.getHead(), attrIds, cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A return answer;
0N/A }
0N/A
0N/A protected void p_modifyAttributes(Name name, int mod_op,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A c_modifyAttributes_nns(res.getHead(), mod_op, attrs, cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A c_modifyAttributes(res.getHead(), mod_op, attrs, cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A }
0N/A protected void p_modifyAttributes(Name name,
0N/A ModificationItem[] mods,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A c_modifyAttributes_nns(res.getHead(), mods, cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A c_modifyAttributes(res.getHead(), mods, cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A }
0N/A
0N/A protected void p_bind(Name name,
0N/A Object obj,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A c_bind_nns(res.getHead(), obj, attrs, cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A c_bind(res.getHead(), obj, attrs, cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A }
0N/A
0N/A protected void p_rebind(Name name, Object obj,
0N/A Attributes attrs, Continuation cont)
0N/A throws NamingException {
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A c_rebind_nns(res.getHead(), obj, attrs, cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A c_rebind(res.getHead(), obj, attrs, cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A }
0N/A
0N/A protected DirContext p_createSubcontext(Name name,
0N/A Attributes attrs,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A DirContext answer = null;
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A answer = c_createSubcontext_nns(res.getHead(), attrs, cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A answer = c_createSubcontext(res.getHead(), attrs, cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A return answer;
0N/A }
0N/A
0N/A protected NamingEnumeration p_search(Name name,
0N/A Attributes matchingAttributes,
0N/A String[] attributesToReturn,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A NamingEnumeration answer = null;
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A answer = c_search_nns(res.getHead(), matchingAttributes,
0N/A attributesToReturn, cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A answer = c_search(res.getHead(), matchingAttributes,
0N/A attributesToReturn, cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A return answer;
0N/A }
0N/A
0N/A protected NamingEnumeration p_search(Name name,
0N/A String filter,
0N/A SearchControls cons, Continuation cont)
0N/A throws NamingException {
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A NamingEnumeration answer = null;
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A answer = c_search_nns(res.getHead(), filter, cons, cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A answer = c_search(res.getHead(), filter, cons, cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A return answer;
0N/A }
0N/A
0N/A protected NamingEnumeration p_search(Name name,
0N/A String filterExpr,
0N/A Object[] filterArgs,
0N/A SearchControls cons,
0N/A Continuation cont)
0N/A throws NamingException {
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A NamingEnumeration answer = null;
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A answer = c_search_nns(res.getHead(),
0N/A filterExpr, filterArgs, cons, cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A answer = c_search(res.getHead(), filterExpr, filterArgs, cons, cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A return answer;
0N/A }
0N/A
0N/A protected DirContext p_getSchema(Name name, Continuation cont)
0N/A throws NamingException {
0N/A DirContext answer = null;
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A answer = c_getSchema_nns(res.getHead(), cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A answer = c_getSchema(res.getHead(), cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A return answer;
0N/A }
0N/A
0N/A protected DirContext p_getSchemaClassDefinition(Name name, Continuation cont)
0N/A throws NamingException {
0N/A DirContext answer = null;
0N/A HeadTail res = p_resolveIntermediate(name, cont);
0N/A switch (res.getStatus()) {
0N/A case TERMINAL_NNS_COMPONENT:
0N/A answer = c_getSchemaClassDefinition_nns(res.getHead(), cont);
0N/A break;
0N/A
0N/A case TERMINAL_COMPONENT:
0N/A answer = c_getSchemaClassDefinition(res.getHead(), cont);
0N/A break;
0N/A
0N/A default:
0N/A /* USE_CONTINUATION */
0N/A /* cont already set or exception thrown */
0N/A break;
0N/A }
0N/A return answer;
0N/A }
0N/A}