View Javadoc

1   /*
2    ORDI - Ontology Repository and Data Integration
3   
4    Copyright (c) 2004-2007, OntoText Lab. / SIRMA
5   
6    This library is free software; you can redistribute it and/or modify it under
7    the terms of the GNU Lesser General Public License as published by the Free
8    Software Foundation; either version 2.1 of the License, or (at your option)
9    any later version.
10   This library is distributed in the hope that it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13   details.
14   You should have received a copy of the GNU Lesser General Public License along
15   with this library; if not, write to the Free Software Foundation, Inc.,
16   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17   */
18  package com.ontotext.ordi.tripleset;
19  
20  import com.ontotext.ordi.Connection;
21  import com.ontotext.ordi.DataSource;
22  import com.ontotext.ordi.IsolationLevel;
23  import com.ontotext.ordi.exception.ORDIException;
24  
25  public abstract class ConnectionImpl extends WarningAwareImpl implements
26          Connection {
27  
28      protected final DataSource source;
29  
30      protected IsolationLevel isolationLevel;
31  
32      protected boolean isAutoCommit;
33  
34      public ConnectionImpl(DataSource source) {
35          if (source == null) {
36              throw new IllegalArgumentException();
37          }
38          this.source = source;
39      }
40  
41      public ConnectionImpl(DataSource source, IsolationLevel isolationLevel) {
42          if (source == null) {
43              throw new IllegalArgumentException();
44          }
45          this.source = source;
46          this.isolationLevel = isolationLevel;
47      }
48  
49      public DataSource getDataSource() {
50          return source;
51      }
52  
53      public IsolationLevel getTransactionIsolationLevel() {
54          return isolationLevel;
55      }
56  
57      public boolean isAutoCommit() {
58          return isAutoCommit;
59      }
60  
61      public void setAutoCommit(boolean mode) throws ORDIException {
62          isAutoCommit = mode;
63      }
64  
65      public void setTransactionIsolationLevel(IsolationLevel isolationLevel)
66              throws ORDIException {
67          this.isolationLevel = isolationLevel;
68      }
69  
70      public boolean isWrapperFor(Class<?> iface) throws ORDIException {
71          return false;
72      }
73  
74      public <T> T unwrap(Class<T> iface) throws ORDIException {
75          throw new ORDIException(
76                  "Invalid requested type to unwrap! Please use isWrappedFor method first!");
77      }
78  }