简体   繁体   中英

How to inject a ConnectionFactory in a JAX-RS resource?

My team is currently in the process of repackaging Neo4j webadmin console to make it usable as a Glassfish standard JavaEE web application. We build that on top of neo4j-jca-connector .

We have already found a way to repackage the various web resources and serve them from our war. we now fight against the various REST endpoints.

Indeed, those endpoints all have their neo4j Database injected as @Context elements (see for example RestfulGraphDatabase constructor ). We can access a Neo4J database through JNDI naming and @Resource injection. But, as we don't want to change any line of code of those REST resources, how can we inject the database in that JAX-RS resource ?

Can we do something in web.xml ?

Do we have to write a JAX-RS Application class ?

In order to add custom @Context parameters, you must create a @Provider class (implementing Injectable) for each type you wish to inject. See this question for details.

我认为这是在http://docs.neo4j.org/chunked/snapshot/server-unmanaged-extensions.html中使用的,因此您可以看看如何将数据库对象插入那里, https://github.com/ neo4j /社区/树/主服务器/服务器

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM