/** * This constructor allows the user to pass in an existing * Graph database service, e.g. if user code is running as an extension inside * an existing Neo4j server * * @param graphDatabaseService the embedded database instance */ public EmbeddedDriver(GraphDatabaseService graphDatabaseService) { this.graphDatabaseService = graphDatabaseService; registerShutdownHook(); }
@Override public synchronized void configure(DriverConfiguration config) { super.configure(config); close(); // force any existing graph database to shutdown try { String fileStoreUri = config.getURI(); // if no URI is set, create a temporary folder for the graph db // that will persist only for the duration of the JVM // This is effectively what the ImpermanentDatabase does. if (fileStoreUri == null) { fileStoreUri = createTemporaryEphemeralFileStore(); } File file = new File(new URI(fileStoreUri)); graphDatabaseService = new GraphDatabaseFactory().newEmbeddedDatabase(file); registerShutdownHook(); } catch (Exception e) { throw new RuntimeException(e); } }