Skip to content

Commit f0bef2b

Browse files
committed
chore: update graph database
Signed-off-by: Otavio Santana <[email protected]>
1 parent 36ec685 commit f0bef2b

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
*/
15+
package org.eclipse.jnosql.databases.tinkerpop.mapping.configuration;
16+
17+
import org.apache.tinkerpop.gremlin.structure.Graph;
18+
import org.eclipse.jnosql.communication.Settings;
19+
import org.eclipse.jnosql.communication.semistructured.DatabaseConfiguration;
20+
import org.eclipse.jnosql.communication.semistructured.DatabaseManager;
21+
import org.eclipse.jnosql.communication.semistructured.DatabaseManagerFactory;
22+
import org.eclipse.jnosql.databases.tinkerpop.communication.TinkerpopGraphDatabaseManager;
23+
24+
import java.util.Objects;
25+
import java.util.logging.Logger;
26+
27+
public abstract class AbstractTinkerpopConfiguration implements DatabaseConfiguration {
28+
29+
private static final Logger LOGGER = Logger.getLogger(AbstractTinkerpopConfiguration.class.getName());
30+
31+
32+
abstract Graph graph(Settings settings);
33+
34+
@Override
35+
public DatabaseManagerFactory apply(Settings settings) {
36+
LOGGER.fine(() -> "Creating graph database manager");
37+
Graph graph = graph(settings);
38+
Objects.requireNonNull(graph, "Graph cannot be null");
39+
return new GraphDatabaseManagerFactory(graph);
40+
}
41+
42+
static class GraphDatabaseManagerFactory implements DatabaseManagerFactory {
43+
44+
private final Graph graph;
45+
46+
GraphDatabaseManagerFactory(Graph graph) {
47+
this.graph = graph;
48+
}
49+
50+
@Override
51+
public void close() {
52+
53+
}
54+
55+
@Override
56+
public DatabaseManager apply(String database) {
57+
LOGGER.fine(() -> "Creating graph database manager where we will ignore the database name: " + database);
58+
return TinkerpopGraphDatabaseManager.of(graph);
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)