Deploy a Procedure to Neo4J when using the embedded driver

一曲冷凌霜 提交于 2019-12-21 20:08:59

问题


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();
}

With a property file here:

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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/38665465/deploy-a-procedure-to-neo4j-when-using-the-embedded-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!