使用嵌入式驱动程序时,将过程部署​​到Neo4J [英] Deploy a Procedure to Neo4J when using the embedded driver

查看:278
本文介绍了使用嵌入式驱动程序时,将过程部署​​到Neo4J的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些逻辑需要直接节点访问neo4j,但其他应用程序使用Spring Data Neo4j(SDN)来简化。我想用@Procedure的程序,但是我不确定在使用neo4j嵌入式驱动程序和SDN4时如何使用该程序。我的配置非常准确,如下所示:

I have some logic which needs direct node access to neo4j but the rest of the app using Spring Data Neo4j (SDN) for simplicity. I thought to use a procedure with @Procedure, but I'm not sure how to use that procedure when using the neo4j embedded driver and SDN4. My configuration is very barebones as below:

@Configuration
@EnableNeo4jRepositories(basePackages = "recommender.repository")
@ComponentScan(basePackages = "recommender")
@EnableTransactionManagement
public class MyNeo4jConfiguration extends Neo4jConfiguration {

@Bean
public SessionFactory getSessionFactory() {

    System.out.println("******* GET SESSION FACTORY!!!!");
    // with domain entity base package(s)
    return new SessionFactory("recommender.model");
}

// needed for session in view in web-applications
@Bean
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Session getSession() throws Exception {
    return super.getSession();
}

这里有一个属性文件:

#EmbeddedSetup
driver=org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver
#URI=file:/neo4j/data/graph.db

使用该设置我可以在哪里放置带有@Procedure和@Context的类(用于db访问)SDN的实施在战争部署期间可以访问它。

With that setup where can I place the class with @Procedure and @Context (for the db access) where SDN's implementation has access to it during war deployment.

推荐答案

SDN本身没有管理程序的功能。
但是,有一种方法可以访问底层的GraphDatabaseService:

SDN itself has no functionality to manage procedures for you. However, there is a way to access the underlying GraphDatabaseService:

 EmbeddedDriver embeddedDriver = (EmbeddedDriver) Components.driver();
 GraphDatabaseService databaseService = embeddedDriver.getGraphDatabaseService();

使用此功能,您可以注册您的程序

Using this, you can register your procedure

((GraphDatabaseAPI) getDatabase()).getDependencyResolver().resolveDependency(Procedures.class).register(YourProcedure.class);

但是,不确定这是否适用于应用程序类路径中的过程类 - 值得尝试。

However, not really sure if this works with your procedure class in the application classpath- worth trying though.

这篇关于使用嵌入式驱动程序时,将过程部署​​到Neo4J的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆