Skip to content

Package: ConnectionFactoryImpl

ConnectionFactoryImpl

nameinstructionbranchcomplexitylinemethod
ConnectionFactoryImpl(StorageConnector)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
ConnectionFactoryImpl(StorageConnector, ConnectionFactoryConfig)
M: 0 C: 17
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
close()
M: 1 C: 13
93%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 1 C: 5
83%
M: 0 C: 1
100%
createStorageConnection()
M: 8 C: 13
62%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 3
75%
M: 0 C: 1
100%
ensureOpen()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
isOpen()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setRepository(Repository)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2023 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.rdf4j.connector;
19:
20: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
21: import org.eclipse.rdf4j.common.transaction.IsolationLevel;
22: import org.eclipse.rdf4j.repository.Repository;
23:
24: public final class ConnectionFactoryImpl implements ConnectionFactory {
25:
26: private boolean open;
27:
28: private final StorageConnector connector;
29: private final boolean isGraphDB;
30: private final IsolationLevel txIsolationLevel;
31:
32: public ConnectionFactoryImpl(StorageConnector connector) {
33: this(connector, new ConnectionFactoryConfig(false, null));
34: }
35:
36: public ConnectionFactoryImpl(StorageConnector connector, ConnectionFactoryConfig config) {
37: this.open = true;
38: this.connector = connector;
39: this.isGraphDB = config.isGraphDB();
40: this.txIsolationLevel = config.txIsolationLevel();
41: }
42:
43: @Override
44: public RepoConnection createStorageConnection() {
45: ensureOpen();
46:• if (isGraphDB) {
47: return new GraphDBStorageConnection(connector, txIsolationLevel);
48: } else {
49: return new StorageConnection(connector, txIsolationLevel);
50: }
51: }
52:
53: private void ensureOpen() {
54:• if (!open) {
55: throw new IllegalStateException("The factory is closed!");
56: }
57: }
58:
59: @Override
60: public void setRepository(Repository repository) {
61: ensureOpen();
62: connector.setRepository(repository);
63: }
64:
65: @Override
66: public synchronized void close() throws OntoDriverException {
67:• if (!open) {
68: return;
69: }
70:• if (connector != null) {
71: connector.close();
72: }
73: this.open = false;
74: }
75:
76: @Override
77: public boolean isOpen() {
78: return open;
79: }
80: }