@Override public synchronized void configure(Configuration newConfiguration) { super.configure(newConfiguration); try { String fileStoreUri = newConfiguration.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 = createTemporaryFileStore(); } else { createPermanentFileStore(fileStoreUri); } File file = new File(new URI(fileStoreUri)); if (!file.exists()) { throw new RuntimeException("Could not create/open filestore: " + fileStoreUri); } GraphDatabaseBuilder graphDatabaseBuilder = getGraphDatabaseFactory(newConfiguration) .newEmbeddedDatabaseBuilder(file); String neo4jConfLocation = newConfiguration.getNeo4jConfLocation(); if (neo4jConfLocation != null) { URL neo4ConfUrl = ResourceUtils.getResourceUrl(neo4jConfLocation); graphDatabaseBuilder = graphDatabaseBuilder.loadPropertiesFromURL(neo4ConfUrl); } this.graphDatabaseService = graphDatabaseBuilder.newGraphDatabase(); } catch (Exception e) { throw new ConnectionException("Error connecting to embedded graph", e); } }
@Override public synchronized void configure(Configuration config) { super.configure(config); 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 = createTemporaryFileStore(); } else { createPermanentFileStore(fileStoreUri); } File file = new File(new URI(fileStoreUri)); if (!file.exists()) { throw new RuntimeException("Could not create/open filestore: " + fileStoreUri); } GraphDatabaseBuilder graphDatabaseBuilder = getGraphDatabaseFactory(configuration) .newEmbeddedDatabaseBuilder(file); String neo4jConfLocation = config.getNeo4jConfLocation(); if(neo4jConfLocation != null) { URL neo4ConfUrl = ResourceUtils.getResourceUrl(neo4jConfLocation); graphDatabaseBuilder = graphDatabaseBuilder.loadPropertiesFromURL(neo4ConfUrl); } this.graphDatabaseService = graphDatabaseBuilder.newGraphDatabase(); } catch (Exception e) { throw new ConnectionException("Error connecting to embedded graph", e); } }