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.impl.config.ds.hsql;
17  
18  import javax.sql.DataSource;
19  
20  import de.smartics.properties.spi.config.ds.JndiDataSourceProxy;
21  import de.smartics.util.lang.Arg;
22  
23  /**
24   * Implementation based on a JNDI data source.
25   */
26  public final class HSqlJndiDataSourceProxy extends AbstractHSqlDataSourceProxy
27  {
28    // ********************************* Fields *********************************
29  
30    // --- constants ------------------------------------------------------------
31  
32    /**
33     * The class version identifier.
34     */
35    private static final long serialVersionUID = 1L;
36  
37    // --- members --------------------------------------------------------------
38  
39    /**
40     * The data source proxy.
41     *
42     * @serial
43     */
44    private final JndiDataSourceProxy dataSource;
45  
46    // ****************************** Initializer *******************************
47  
48    // ****************************** Constructors ******************************
49  
50    /**
51     * Default constructor.
52     *
53     * @param dataSource the data source proxy.
54     * @throws NullPointerException if {@code dataSource} is <code>null</code>.
55     */
56    public HSqlJndiDataSourceProxy(final JndiDataSourceProxy dataSource)
57      throws NullPointerException
58    {
59      this.dataSource = Arg.checkNotNull("dataSource", dataSource);
60    }
61  
62    // ****************************** Inner Classes *****************************
63  
64    // ********************************* Methods ********************************
65  
66    // --- init -----------------------------------------------------------------
67  
68    // --- get&set --------------------------------------------------------------
69  
70    @Override
71    public String getDataSourceId()
72    {
73      return dataSource.getDataSourceId();
74    }
75  
76    @Override
77    public DataSource getDataSource()
78    {
79      return dataSource.getDataSource();
80    }
81  
82    // --- business -------------------------------------------------------------
83  
84    // --- object basics --------------------------------------------------------
85  
86    @Override
87    public String toString()
88    {
89      return "(HSQL) " + dataSource.toString();
90    }
91  }