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 de.smartics.properties.api.core.app.PropertyRootException;
19  
20  /**
21   * Signals problems with accessing a data source.
22   */
23  public class DataSourceException extends PropertyRootException
24  {
25    // ********************************* Fields *********************************
26  
27    // --- constants ------------------------------------------------------------
28  
29    /**
30     * The class version identifier.
31     * <p>
32     * The value of this constant is {@value}.
33     */
34    private static final long serialVersionUID = 1L;
35  
36    // --- members --------------------------------------------------------------
37  
38    /**
39     * The identifier of the data source. Usually this is the connection URL plus
40     * any other identifying information.
41     *
42     * @serial
43     */
44    private final String dataSourceId;
45  
46    // ****************************** Initializer *******************************
47  
48    // ****************************** Constructors ******************************
49  
50    /**
51     * Convenience constructor without a root cause.
52     *
53     * @param message the detail message (which is saved for later retrieval by
54     *          the {@link #getMessage()} method).
55     * @param dataSourceId the identifier of the data source.
56     */
57    public DataSourceException(final String message, final String dataSourceId)
58    {
59      this(message, null, dataSourceId);
60    }
61  
62    /**
63     * Convenience constructor without a message.
64     *
65     * @param cause the cause (which is saved for later retrieval by the
66     *          {@link #getCause()} method). (A <tt>null</tt> value is permitted,
67     *          and indicates that the cause is nonexistent or unknown.)
68     * @param dataSourceId the identifier of the data source.
69     */
70    public DataSourceException(final Throwable cause, final String dataSourceId)
71    {
72      this(null, cause, dataSourceId);
73    }
74  
75    /**
76     * Constructor.
77     *
78     * @param message the detail message (which is saved for later retrieval by
79     *          the {@link #getMessage()} method).
80     * @param cause the cause (which is saved for later retrieval by the
81     *          {@link #getCause()} method). (A <tt>null</tt> value is permitted,
82     *          and indicates that the cause is nonexistent or unknown.)
83     * @param dataSourceId the identifier of the data source.
84     */
85    public DataSourceException(final String message, final Throwable cause,
86        final String dataSourceId)
87    {
88      super(message, cause);
89      this.dataSourceId = dataSourceId;
90    }
91  
92    // ****************************** Inner Classes *****************************
93  
94    // ********************************* Methods ********************************
95  
96    // --- init -----------------------------------------------------------------
97  
98    // --- get&set --------------------------------------------------------------
99  
100   /**
101    * Returns the identifier of the data source. Usually this is the connection
102    * URL plus any other identifying information.
103    *
104    * @return the identifier of the data source.
105    */
106   public final String getDataSourceId()
107   {
108     return dataSourceId;
109   }
110 
111   // --- business -------------------------------------------------------------
112 
113   // --- object basics --------------------------------------------------------
114 
115 }