如何使用 spring-mvc 浏览 jackrabbit 存储库
如何使用 spring-mvc web 应用程序浏览 jackrabbit 存储库?
如何将 Spring Web 控制器中传入的 URL 请求映射到存储库中的节点?我希望用户能够通过打开如下 URL 来在 OpenOffice 或 Word 中打开 Word 文档,并通过 webdav 保存回该文档。
http://localhost:8080/my-app/my-doc.doc
预先感谢您的任何想法。
埃蒙
How do I browse a jackrabbit repository using a spring-mvc webapp?
How do I map incoming URL requests in the spring web controllers to nodes in the repository? I'd like the users to be able to open a word document in OpenOffice or Word by opening a URL like the following and save back to it via webdav.
http://localhost:8080/my-app/my-doc.doc
Thanks in advance for any ideas.
Éamonn
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Jackrabbit 存储库和 Java 内容存储库的相关 JSR 标准单独提供了相当低级别的持久性 API,您可以使用它来构建域对象的存储库,将数据映射到存储库结构(例如 JCR 节点/属性)。您将使用位于 javax.jcr.* 包中的 JCR API 来操作存储库(并获得最大的可移植性)。一句话,你可以用Jackrabbit来替换你的数据库。
快速的 google 搜索显示,确实有一些项目旨在为 JDBC 和 Hibernate 提供与您可能了解和喜爱的类似的便捷包装器,但仅适用于 JCR。例如,我发现了 Spring Modules 项目: http://java.net/projects/springmodules/ 其中不幸的是,上次更新是在大约两年前,所以它仍然是 JCR 1.0。有关示例用法,请查看 http://java.net/projects/springmodules/sources/svn/content/trunk/samples/jcr/src/org/springmodules/examples/jcr/JcrService.java?rev=2110
尽管如此,您仍然可以轻松编写自己的 JCR2Template,并使用模板方法模式封装重复性任务,例如连接和异常处理。
对于请求映射,您可以在单独的服务器上运行 JCR,就像使用关系数据库一样,并通过 RMI 连接到它。这是一个示例: http://dev.day.com /content/docs/en/crx/current/developing/accessing_jcr_connectors.html
我认为这是在 Spring MVC 应用程序中使用 JCR 的“干净”方式。
至于WebDAV保存部分...我知道Jackrabbit确实支持将存储库安装为WebDAV驱动器,但我对此没有任何经验,老实说我无法想象如何告诉Word上传文件在编辑某处...但我根本不是 Word 专家,抱歉...
现在...另一方面,Apache Sling 框架提供了一种有趣的方法来构建 RESTful 应用程序,它与存储库模型很好地集成,并且存储库结构的一些更高级别的抽象。然而,Sling 中解析 Servlet 的方式与普通 Spring MVC 完全不同(请参阅 http://dev.day.com/content/ddc/blog/2008/07/cheatsheet/_jcr_content/par/download/file),所以协调这两种方法需要做一些工作。
希望里面有一些信息你可以使用。
干杯,
约翰内斯
the Jackrabbit Repository and the associated JSR standard for Java Content Repositories alone provides a fairly low level persistency API, which you could probably use to build Repositories for Domain objects, mapping the data to repository structures such as JCR nodes/properties. You will use the JCR API located at the javax.jcr.* package to manipulate the repository (and for maximum portability). In a sentence, you can use Jackrabbit to replace your database.
A quick google search showed that there are indeed projects that aim to provide similar convenience wrappers to the ones you probably know and love for JDBC and Hibernate, only for JCRs. I found for example the Spring Modules project: http://java.net/projects/springmodules/ which was unfortunately last updated about two years ago, so it is still on JCR 1.0. For sample usage take a look at http://java.net/projects/springmodules/sources/svn/content/trunk/samples/jcr/src/org/springmodules/examples/jcr/JcrService.java?rev=2110
Still, you could probably write your own JCR2Template without a lot of effort, and encapsulate the repetitive tasks such as connection and exception handing by using the Template Method pattern.
So as for the request mapping, you can run the JCR on a separate server, just like you would with a relational database, and connect to it via RMI. Here's an example: http://dev.day.com/content/docs/en/crx/current/developing/accessing_jcr_connectors.html
I would consider this the "clean" way to use a JCR in Spring MVC applications.
As for the WebDAV saving part... I know Jackrabbit does indeed support the mounting of Repositories as WebDAV drives, but I don't really have any experience with it and I honestly can't imagine a way to tell Word to upload a file upon edit somewhere... But I am not a Word expert at all, sorry....
Now ... the Apache Sling Framework on the other hand provides an interesting approach to build RESTful applications, that integrate well with the repository model and some higher level abstractions of the Repository structure. The way Servlets are resolved in Sling, however is completely different from plain Spring MVC (see http://dev.day.com/content/ddc/blog/2008/07/cheatsheet/_jcr_content/par/download/file), so it would a bit of work to reconcile both approaches.
Hope there's some info in there you can use.
Cheers,
Johannes