33 lines
917 B
Java
33 lines
917 B
Java
package com.stktrk.app.db;
|
|
|
|
import com.arcadedb.gremlin.ArcadeGraph;
|
|
import com.arcadedb.gremlin.ArcadeGraphFactory;
|
|
import com.stktrk.app.configuration.GraphDbConfig;
|
|
import org.apache.commons.configuration2.Configuration;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
@Component
|
|
public class ConnectionPool {
|
|
static ArcadeGraphFactory pool;
|
|
|
|
@Autowired
|
|
GraphDbConfig graphDbConfig;
|
|
|
|
@PostConstruct
|
|
void init () {
|
|
try {
|
|
pool = ArcadeGraphFactory.withRemote(graphDbConfig.getHost(), graphDbConfig.getHttpPort(), graphDbConfig.getGraphName(), graphDbConfig.getUser(), graphDbConfig.getPassword());
|
|
|
|
} catch (Exception e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
public static ArcadeGraph getGraph() {
|
|
return pool.get();
|
|
}
|
|
}
|