Neo4j 嵌入 OSGi

发布于 2024-12-27 09:58:31 字数 188 浏览 4 评论 0原文

我想在嵌入模式下使用 neo4j。正如我所见,不可能在不同的进程中共享 GraphDatabase 实例。现在我的想法是使用嵌入在 OSGi 容器中的 neo4j 为不同组件共享相同的数据库。编写一个 BundleActivator 来创建 GraphDB 并将其通过服务公开给其他 OSGi 包是个好主意吗?

I want to use neo4j in embedded mode. As I have seen it's not possible to share the GraphDatabase instance in different processes. Now my idea was to use the neo4j embedded in an OSGi container to share the same db for different components. Is it a good idea to write a BundleActivator which creates the GraphDB and exposes it to other OSGi bundles with a service?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

网名女生简单气质 2025-01-03 09:58:31

一个带有测试的示例模板设置,它使用 neo4j 相关组件制作了一个超级包。尝试让我们知道进展如何。请参阅 这里是一个典型的激活器。

there is An example template setup with tests making a super-bundle out of the neo4j-related components. Try and let us know how it goes. See here for a typical Activator.

眼眸印温柔 2025-01-03 09:58:31

现在您可以使用适当的 DI 来实例化数据库,例如 http:// /docs.neo4j.org/chunked/snapshot/tutorials-java-embedded-osgi.html

    //the cache providers
    ArrayList<CacheProvider> cacheList = new ArrayList<CacheProvider>();
    cacheList.add( new SoftCacheProvider() );

    //the index providers
    IndexProvider lucene = new LuceneIndexProvider();
    ArrayList<IndexProvider> provs = new ArrayList<IndexProvider>();
    provs.add( lucene );
    ListIndexIterable providers = new ListIndexIterable();
    providers.setIndexProviders( provs );

    //the database setup
    GraphDatabaseFactory gdbf = new GraphDatabaseFactory();
    gdbf.setIndexProviders( providers );
    gdbf.setCacheProviders( cacheList );
    db = gdbf.newEmbeddedDatabase( "target/db" );

Now you can use proper DI to instantiate the DB, like http://docs.neo4j.org/chunked/snapshot/tutorials-java-embedded-osgi.html

    //the cache providers
    ArrayList<CacheProvider> cacheList = new ArrayList<CacheProvider>();
    cacheList.add( new SoftCacheProvider() );

    //the index providers
    IndexProvider lucene = new LuceneIndexProvider();
    ArrayList<IndexProvider> provs = new ArrayList<IndexProvider>();
    provs.add( lucene );
    ListIndexIterable providers = new ListIndexIterable();
    providers.setIndexProviders( provs );

    //the database setup
    GraphDatabaseFactory gdbf = new GraphDatabaseFactory();
    gdbf.setIndexProviders( providers );
    gdbf.setCacheProviders( cacheList );
    db = gdbf.newEmbeddedDatabase( "target/db" );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文