001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2014-2016 ForgeRock AS.
015 */
016package org.opends.server.schema;
017
018import java.util.List;
019
020import org.forgerock.i18n.LocalizableMessage;
021import org.forgerock.opendj.config.server.ConfigException;
022import org.forgerock.opendj.ldap.schema.SchemaBuilder;
023import org.forgerock.opendj.server.config.server.SchemaProviderCfg;
024import org.opends.server.core.ServerContext;
025import org.opends.server.types.InitializationException;
026
027/**
028 * Provides some schema elements to load at startup.
029 * <p>
030 * A schema provider must be able to update the provided {@code SchemaBuilder}
031 * at initialization and to use the provided {@code SchemaUpdater} to update the
032 * schema on further configuration changes.
033 *
034 * @param <T>
035 *          The type of provider configuration.
036 */
037public interface SchemaProvider<T extends SchemaProviderCfg>
038{
039  /**
040   * Initialize the schema provider from provided configuration and schema
041   * builder.
042   *
043   * @param serverContext
044   *            The server context.
045   * @param configuration
046   *          Configuration of the provider.
047   * @param initialSchemaBuilder
048   *          Schema builder to update during initialization phase.
049   * @throws ConfigException
050   *           If a configuration problem arises in the process of performing
051   *           the initialization.
052   * @throws InitializationException
053   *           If a problem that is not configuration-related occurs during
054   *           initialization.
055   */
056  void initialize(ServerContext serverContext, T configuration, SchemaBuilder initialSchemaBuilder)
057      throws ConfigException, InitializationException;
058
059  /**
060   * Finalize the provider.
061   */
062  void finalizeProvider();
063
064  /**
065   * Indicates whether the provided configuration is acceptable for this
066   * provider.
067   *
068   * @param configuration
069   *          The provider configuration for which to make the determination.
070   * @param unacceptableReasons
071   *          A list that may be used to hold the reasons that the provided
072   *          configuration is not acceptable.
073   * @return {@code true} if the provided configuration is acceptable for this
074   *         provider, or {@code false} if not.
075   */
076  boolean isConfigurationAcceptable(T configuration, List<LocalizableMessage> unacceptableReasons);
077
078}