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.Serializable;
19  
20  import de.smartics.properties.api.config.domain.Property;
21  import de.smartics.properties.api.config.domain.PropertyProvider;
22  
23  /**
24   * Interface to access property information from a data source.
25   */
26  public interface PropertiesDataSourceAccessor extends Serializable
27  {
28    // ********************************* Fields *********************************
29  
30    // --- constants ------------------------------------------------------------
31  
32    // ****************************** Initializer *******************************
33  
34    // ****************************** Inner Classes *****************************
35  
36    // ********************************* Methods ********************************
37  
38    // --- get&set --------------------------------------------------------------
39  
40    /**
41     * Reads the property with the given name from the data source.
42     *
43     * @param config the name of the configuration the property is part of.
44     * @param name the name of the property to fetch.
45     * @return the property or <code>null</code>, if no such property is stored in
46     *         the data source.
47     * @throws NullPointerException if {@code config} or {@code name} is
48     *           <code>null</code>.
49     * @throws IllegalArgumentException if {@code config} or {@code name} is
50     *           blank.
51     * @throws DataSourceException on any problem accessing the data source.
52     */
53    Property getProperty(String config, String name) throws NullPointerException,
54      IllegalArgumentException, DataSourceException;
55  
56    /**
57     * Sets the property to the given name and value.
58     *
59     * @param config the name of the configuration the property is part of.
60     * @param name the name of the property to set.
61     * @param value the value of the property.
62     * @throws NullPointerException if {@code config} or {@code name} is
63     *           <code>null</code>.
64     * @throws IllegalArgumentException if {@code config} or {@code name} is
65     *           blank.
66     * @throws DataSourceException on any problem accessing the data source.
67     */
68    void setProperty(String config, String name, String value)
69      throws NullPointerException, IllegalArgumentException, DataSourceException;
70  
71    /**
72     * Stores all properties provided by the given provider.
73     *
74     * @param provider the provider of properties to store.
75     * @throws NullPointerException if {@code provider} is <code>null</code>.
76     * @throws DataSourceException on any problem accessing the data source.
77     */
78    void setProperties(PropertyProvider provider) throws NullPointerException,
79      DataSourceException;
80  
81    /**
82     * Deletes the property from the store.
83     *
84     * @param config the name of the configuration the property is part of.
85     * @param name the name of the property to delete.
86     * @throws NullPointerException if {@code config} or {@code name} is
87     *           <code>null</code>.
88     * @throws IllegalArgumentException if {@code config} or {@code name} is
89     *           blank.
90     * @throws DataSourceException on any problem accessing the data source.
91     */
92    void deleteProperty(String config, String name) throws NullPointerException,
93      IllegalArgumentException, DataSourceException;
94  
95    // --- business -------------------------------------------------------------
96  
97    // --- object basics --------------------------------------------------------
98  
99  }