Package: BasicConnectorFactory
BasicConnectorFactory
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
BasicConnectorFactory() |
|
|
|
|
|
||||||||||||||||||||
close() |
|
|
|
|
|
||||||||||||||||||||
getConnector(Configuration) |
|
|
|
|
|
||||||||||||||||||||
initConnector(Configuration) |
|
|
|
|
|
||||||||||||||||||||
isOpen() |
|
|
|
|
|
Coverage
1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.ontodriver.owlapi.connector;
14:
15: import cz.cvut.kbss.ontodriver.config.Configuration;
16: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
17: import cz.cvut.kbss.ontodriver.owlapi.exception.OwlapiDriverException;
18:
19: public class BasicConnectorFactory implements ConnectorFactory {
20:
21: private boolean open;
22:
23: private AbstractConnector connector;
24:
25: BasicConnectorFactory() {
26: this.open = true;
27: }
28:
29: @Override
30: public synchronized AbstractConnector getConnector(Configuration configuration) throws OwlapiDriverException {
31:• if (!open) {
32: throw new IllegalStateException("The factory is closed.");
33: }
34:• if (connector == null) {
35: initConnector(configuration);
36: }
37: return connector;
38: }
39:
40: private void initConnector(Configuration configuration) throws OwlapiDriverException {
41: this.connector = new BasicStorageConnector(configuration);
42: }
43:
44: @Override
45: public boolean isOpen() {
46: return open;
47: }
48:
49: @Override
50: public synchronized void close() throws OntoDriverException {
51:• if (connector != null) {
52: connector.close();
53: }
54: this.open = false;
55: }
56: }