View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.properties.spi.config.ds;
17  
18  import java.io.PrintStream;
19  import java.util.List;
20  
21  /**
22   * Interface to connect to a database to persist properties and to allow the
23   * management of the database infrastructure. That is
24   * <ol>
25   * <li>Create and drop the properties table.</li>
26   * <li>Fill table with properties initially.</li>
27   * </ol>
28   */
29  public interface PropertiesDataSourceManager extends
30      PropertiesDataSourceDescriptor
31  {
32    // ********************************* Fields *********************************
33  
34    // --- constants ------------------------------------------------------------
35  
36    // ****************************** Initializer *******************************
37  
38    // ****************************** Inner Classes *****************************
39  
40    // ********************************* Methods ********************************
41  
42    // --- get&set --------------------------------------------------------------
43  
44    /**
45     * Returns a reference to the data source proxy used to connect to the data
46     * source.
47     *
48     * @return a reference to the data source proxy used to connect to the data
49     *         source.
50     */
51    DataSourceProxy getDataSourceProxy();
52  
53    // --- business -------------------------------------------------------------
54  
55    /**
56     * Creates the configuration on the referenced data source.
57     *
58     * @throws DataSourceException on any problem accessing the data source.
59     */
60    void createConfigTable() throws DataSourceException;
61  
62    /**
63     * Drops the configuration table from the referenced data source.
64     *
65     * @throws DataSourceException on any problem accessing the data source.
66     */
67    void dropConfigTable() throws DataSourceException;
68  
69    /**
70     * Returns the list of distinct data source keys.
71     *
72     * @return the list of distinct data source keys.
73     * @throws DataSourceException on any problem fetching the keys.
74     */
75    List<String> getConfigurationKeys() throws DataSourceException;
76  
77    /**
78     * Returns the SQL statement to insert or update a value in the table,
79     * dependent on if the value is already in the database or not.
80     *
81     * @return the SQL statement to insert or update a value in the table,
82     *         dependent on if the value is already in the database or not.
83     */
84    String getInsertOrUpdateSqlStatementTemplate();
85  
86    /**
87     * Prints the contents of the data source to the given stream. Useful for
88     * debugging.
89     *
90     * @param out the stream to write to.
91     * @throws NullPointerException if {@code out} is <code>null</code>.
92     * @throws DataSourceException on any problem accessing the data source.
93     */
94    void print(final PrintStream out) throws NullPointerException,
95      DataSourceException;
96  
97    // --- object basics --------------------------------------------------------
98  
99  }