View Javadoc

1   /*
2    * $Id: DefinitionsReader.java 537196 2007-05-11 14:07:35Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  package org.apache.tiles.definition;
23  
24  import java.util.Map;
25  
26  import org.apache.tiles.Definition;
27  
28  /***
29   * Interface for reading <code>{@link Definition}</code> from a source.
30   * <p/>
31   * <p>This interface provides a standard way to read
32   * <code>{@link Definition}</code> objects from a source.  Implementations
33   * should define what the source is, whether it be a persistent store such as a
34   * configuration file or database, or something like a web service.  The
35   * DefinitionsReader is responsible for reading from a single location.  It does
36   * not perform any internationalization duties or inheritance of Definitions.
37   * It only reads from the source and returns a Map of objects read.</p>
38   *
39   * @version $Rev: 537196 $ $Date: 2007-05-11 16:07:35 +0200 (Fri, 11 May 2007) $
40   */
41  public interface DefinitionsReader {
42  
43      /***
44       * Initializes the <code>DefinitionsReader</code> object.
45       * <p/>
46       * This method must be called before the {@link #read(java.lang.Object)} method is called.
47       *
48       * @param params A map of properties used to set up the reader.
49       * @throws DefinitionsFactoryException if required properties are not
50       *                                     passed in or the initialization fails.
51       */
52      void init(Map<String, String> params) throws DefinitionsFactoryException;
53  
54      /***
55       * Reads <code>{@link Definition}</code> objects from a source.
56       * <p/>
57       * Implementations should publish what type of source object is expected.
58       *
59       * @param source The source from which definitions will be read.
60       * @return a Map of <code>Definition</code> objects read from
61       *         the source.
62       * @throws DefinitionsFactoryException if the source is invalid or
63       *                                     an error occurs when reading definitions.
64       */
65      Map<String, Definition> read(Object source) throws DefinitionsFactoryException;
66  
67  }