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