1 package org.apache.torque.generator.configuration;
2
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 import java.io.InputStream;
23 import java.util.Collection;
24
25 /**
26 * Defines how the configuration for a generation unit can be accessed.
27 * Implementing classes provide InputStreams to access the various parts
28 * of the configuration.
29 */
30 public interface ConfigurationProvider
31 {
32 /**
33 * Creates a reader to access the control configuration.
34 * It is the callers responsibility to close the reader after use.
35 *
36 * @return a reader to access the control configuration, never null.
37 *
38 * @throws ConfigurationException if the reader can not be created.
39 */
40 InputStream getControlConfigurationInputStream()
41 throws ConfigurationException;
42
43 /**
44 * Returns the location of the control configuration as human readable
45 * String for debugging and error tracking purposes.
46 *
47 * @return the location of the control configuration, not null.
48 *
49 * @throws ConfigurationException if the location name can not be created.
50 */
51 // The control configuration location is important if loading the control
52 // file fails for a project with multiple units of generation.
53 // Using the location in the error messages helps finding out which
54 // control configuration contains the error.
55 String getControlConfigurationLocation() throws ConfigurationException;
56
57 /**
58 * Creates a reader to access a template.
59 * It is the callers responsibility to close the reader after use.
60 *
61 * @param name the name (==path to) of the template.
62 *
63 * @return a reader to access a template, never null.
64 *
65 * @throws ConfigurationException if the reader can not be created.
66 */
67 InputStream getTemplateInputStream(String name)
68 throws ConfigurationException;
69
70 /**
71 * Returns a list of all found outlet configuration files in the
72 * generation unit.
73 *
74 * @return a list with the generation configuration files, not null.
75 *
76 * @throws ConfigurationException if the configuration can not be read.
77 */
78 Collection<String> getOutletConfigurationNames()
79 throws ConfigurationException;
80
81 /**
82 * Creates a reader to access the configuration for one outlet.
83 * It is the callers responsibility to close the reader after use.
84 *
85 * @param name the name (==path to) of the outlet configuration.
86 *
87 * @return a reader to access the outlet configuration, never null.
88 *
89 * @throws ConfigurationException if the reader can not be created.
90 */
91 InputStream getOutletConfigurationInputStream(String name)
92 throws ConfigurationException;
93
94 /**
95 * Creates a reader to access an options file.
96 * It is the callers responsibility to close the reader after use.
97 *
98 * @param name the name (==path to) of the options file.
99 *
100 * @return a reader to access the options file, never null.
101 *
102 * @throws ConfigurationException if the reader can not be created.
103 */
104 InputStream getOptionsInputStream(String name)
105 throws ConfigurationException;
106
107
108 /**
109 * Creates a reader to access a resource file.
110 * It is the callers responsibility to close the reader after use.
111 *
112 * @param path the path to of the resource file.
113 *
114 * @return a reader to access the options file, never null.
115 *
116 * @throws ConfigurationException if the reader can not be created.
117 */
118 InputStream getResourceInputStream(String path)
119 throws ConfigurationException;
120 }