@Override public GraphDatabaseBuilder loadPropertiesFromURL( URL url ) throws IllegalArgumentException { actual.loadPropertiesFromURL( url ); return this; }
/** * Load a Properties file from a given file, and add the settings to * the builder. * * @param fileName Filename of properties file to use * @return the builder * @throws IllegalArgumentException if the builder was unable to load from the given filename */ public GraphDatabaseBuilder loadPropertiesFromFile( String fileName ) throws IllegalArgumentException { try { return loadPropertiesFromURL( new File( fileName ).toURI().toURL() ); } catch ( MalformedURLException e ) { throw new IllegalArgumentException( "Illegal filename:" + fileName, e ); } }
private void setConfigurationFromLocation(GraphDatabaseBuilder builder, URL cfgLocation) { if ( cfgLocation != null ) { builder.loadPropertiesFromURL( cfgLocation ); } } }
@Override public GraphDatabaseBuilder loadPropertiesFromURL( URL url ) throws IllegalArgumentException { actual.loadPropertiesFromURL( url ); return this; }
/** * Load a Properties file from a given file, and add the settings to * the builder. * * @param fileName Filename of properties file to use * @return the builder * @throws IllegalArgumentException if the builder was unable to load from the given filename */ public GraphDatabaseBuilder loadPropertiesFromFile( String fileName ) throws IllegalArgumentException { try { return loadPropertiesFromURL( new File( fileName ).toURI().toURL() ); } catch ( MalformedURLException e ) { throw new IllegalArgumentException( "Illegal filename:" + fileName, e ); } }
@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); } }