1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20 package org.apache.directory.server.schema.registries;
21
22
23 import java.util.Collection;
24 import java.util.Properties;
25
26 import org.apache.directory.server.schema.bootstrap.Schema;
27
28
29 /**
30 * Loads schemas into registres.
31 *
32 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33 * @version $Rev$
34 */
35 public interface SchemaLoader
36 {
37 /**
38 * Sets listener used to notify of newly loaded schemas.
39 *
40 * @param listener the listener to notify (only one is enough for us)
41 * @note probably should have used the observer pattern here
42 */
43 public void setListener( SchemaLoaderListener listener );
44
45 /**
46 * Gets a schema object based on it's name.
47 *
48 * @param schemaName the name of the schema to load
49 * @return the Schema object associated with the name
50 * @throws NamingException if any problems while trying to find the associated Schema
51 */
52 Schema getSchema( String schemaName ) throws Exception;
53
54 /**
55 * Gets a schema object based on it's name and some properties.
56 *
57 * @param schemaName the name of the schema to load
58 * @param schemaProperties the properties associated with that schema to facilitate locating/loading it
59 * @return the Schema object associated with the name
60 * @throws NamingException if any problems while trying to find the associated Schema
61 */
62 Schema getSchema( String schemaName, Properties schemaProperties ) throws Exception;
63
64 /**
65 * Loads a collection of schemas. A best effort should be made to load the dependended
66 * schemas that these schemas may rely on even if they are not included in the collection.
67 *
68 * @param schemas the collection of schemas to load
69 * @param registries the registries to populate with these schemas
70 * @throws NamingException if any kind of problems are encountered during the load
71 */
72 void loadWithDependencies( Collection<Schema> schemas, Registries registries ) throws Exception;
73
74 /**
75 * Loads a single schema at least and possibly it's dependencies.
76 *
77 * @param schemas the schema to load
78 * @param registries the registries to populate with these schemas
79 * @throws NamingException if any kind of problems are encountered during the load
80 */
81 void loadWithDependencies( Schema schemas, Registries registries ) throws Exception;
82
83 /**
84 * Loads a single schema. Do not try to resolve dependencies while implementing this method.
85 *
86 * @param schema the schema to load
87 * @param registries the registries to populate with these schemas
88 * @param isDepLoad tells the loader if this load request is to satisfy a dependency
89 * @throws NamingException if any kind of problems are encountered during the load
90 */
91 void load( Schema schema, Registries registries, boolean isDepLoad ) throws Exception;
92 }