001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2010 Sun Microsystems, Inc.
025 *      Portions copyright 2011 ForgeRock AS
026 */
027
028package org.forgerock.opendj.ldap;
029
030import org.forgerock.opendj.ldap.schema.Schema;
031
032/**
033 * Schema resolvers are included with a set of {@code DecodeOptions} in order to
034 * allow application to control how {@code Schema} instances are selected when
035 * decoding requests and responses.
036 * <p>
037 * Implementations must be thread safe. More specifically, any schema caching
038 * performed by the implementation must be capable of handling multiple
039 * concurrent schema requests.
040 *
041 * @see Schema
042 * @see DecodeOptions
043 */
044public interface SchemaResolver {
045    /**
046     * A schema resolver which always returns the current default schema as
047     * returned by {@link Schema#getDefaultSchema()}.
048     */
049    SchemaResolver DEFAULT = new SchemaResolver() {
050
051        public Schema resolveSchema(String dn) {
052            return Schema.getDefaultSchema();
053        }
054    };
055
056    /**
057     * Finds the appropriate schema for use with the provided distinguished
058     * name.
059     * <p>
060     * Schema resolution must always succeed regardless of any errors that
061     * occur.
062     *
063     * @param dn
064     *            The string representation of a distinguished name associated
065     *            with an entry whose schema is to be located.
066     * @return The appropriate schema for use with the provided distinguished
067     *         name.
068     */
069    Schema resolveSchema(String dn);
070}