001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.schema.registries;
021
022
023 import java.util.Collection;
024 import java.util.Properties;
025
026 import org.apache.directory.server.schema.bootstrap.Schema;
027
028
029 /**
030 * Loads schemas into registres.
031 *
032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033 * @version $Rev$
034 */
035 public interface SchemaLoader
036 {
037 /**
038 * Sets listener used to notify of newly loaded schemas.
039 *
040 * @param listener the listener to notify (only one is enough for us)
041 * @note probably should have used the observer pattern here
042 */
043 public void setListener( SchemaLoaderListener listener );
044
045 /**
046 * Gets a schema object based on it's name.
047 *
048 * @param schemaName the name of the schema to load
049 * @return the Schema object associated with the name
050 * @throws NamingException if any problems while trying to find the associated Schema
051 */
052 Schema getSchema( String schemaName ) throws Exception;
053
054 /**
055 * Gets a schema object based on it's name and some properties.
056 *
057 * @param schemaName the name of the schema to load
058 * @param schemaProperties the properties associated with that schema to facilitate locating/loading it
059 * @return the Schema object associated with the name
060 * @throws NamingException if any problems while trying to find the associated Schema
061 */
062 Schema getSchema( String schemaName, Properties schemaProperties ) throws Exception;
063
064 /**
065 * Loads a collection of schemas. A best effort should be made to load the dependended
066 * schemas that these schemas may rely on even if they are not included in the collection.
067 *
068 * @param schemas the collection of schemas to load
069 * @param registries the registries to populate with these schemas
070 * @throws NamingException if any kind of problems are encountered during the load
071 */
072 void loadWithDependencies( Collection<Schema> schemas, Registries registries ) throws Exception;
073
074 /**
075 * Loads a single schema at least and possibly it's dependencies.
076 *
077 * @param schemas the schema to load
078 * @param registries the registries to populate with these schemas
079 * @throws NamingException if any kind of problems are encountered during the load
080 */
081 void loadWithDependencies( Schema schemas, Registries registries ) throws Exception;
082
083 /**
084 * Loads a single schema. Do not try to resolve dependencies while implementing this method.
085 *
086 * @param schema the schema to load
087 * @param registries the registries to populate with these schemas
088 * @param isDepLoad tells the loader if this load request is to satisfy a dependency
089 * @throws NamingException if any kind of problems are encountered during the load
090 */
091 void load( Schema schema, Registries registries, boolean isDepLoad ) throws Exception;
092 }