@Override public IPersistenceService createPersistenceService(NEConfiguration configuration) { // the cache providers ArrayList<CacheProvider> cacheList = new ArrayList<CacheProvider>(); System.out.println("Creating db configuration"); cacheList.add(new WeakCacheProvider()); // the kernel extensions LuceneKernelExtensionFactory lucene = new LuceneKernelExtensionFactory(); List<KernelExtensionFactory<?>> extensions = new ArrayList<KernelExtensionFactory<?>>(); extensions.add(lucene); // Map<String,String> config = new HashMap<String,String>(); // config.put("cache_type", "weak"); // the database setup GraphDatabaseFactory gdbf = new GraphDatabaseFactory(); gdbf.setKernelExtensions(extensions); gdbf.setCacheProviders(cacheList); GraphDatabaseService db = null; try { // db = gdbf.newEmbeddedDatabase(configuration.path().getAbsolutePath()); db = gdbf.newEmbeddedDatabaseBuilder(configuration.path().getAbsolutePath()) .setConfig(GraphDatabaseSettings.cache_type, WeakCacheProvider.NAME) .newGraphDatabase(); } catch (Exception e) { e.printStackTrace(); } IPersistenceService service = new PersistenceService(db, configuration); registerShutdownHook(db); return service; }
/* * Helper method to get an instance of the graph database api * * */ private static GraphDatabaseAPI GET_GRAPH_DATABASE_API() { GraphDatabaseFactory gdbf = new GraphDatabaseFactory(); GraphDatabaseBuilder edbb = gdbf.newEmbeddedDatabaseBuilder("target/neo4jTestDb"); edbb.setConfig(ShellSettings.remote_shell_enabled, Settings.TRUE); return (GraphDatabaseAPI) edbb.newGraphDatabase(); }