JCR 签入/结账操作
我刚刚开始使用 JCR (apache jackrabbit),我想问一个简单的问题(因为我找不到好的教程): 那么我需要 Node.checkout 和 Node.checkin 方法做什么? 它们是什么意思?
谢谢
I'm just starting to work with JCR (apache jackrabbit), i want to ask simple question (because i coudn't find good tutorial for it):
So for what do i need Node.checkout and Node.checkin methods?
What do they mean?
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“签入”和“签出”方法与 JCR 存储库跟踪内容版本的方式有关。 “checkout”方法向存储库发出信号,表明您的客户端应用程序(可能)将修改某些版本控制的内容。 “签入”方法向存储库发出信号,表明您的客户端应用程序已对版本控制内容进行了更改,并且存储库应在版本历史记录中记录这些更改(例如,新版本)。
例如,假设我们要在“/a/b/c”处创建一个可版本控制的节点。这是使用类似以下代码的内容来完成的:
要创建内容,您只需在节点上设置“mix:versionable”mixin(或使用从“mix:versionable”继承的mixin或主节点类型),然后保存更改。此时,存储库将初始化该节点(或子图)的版本历史记录。
在“session.save()”上,存储库将记录“mix:versionable”mixin,并将初始化“/a/b/c”处内容的版本历史记录。从此时起,您的客户端应用程序使用“签出”和“签入”将新版本添加到历史记录中。
当调用“checkin”时,存储库将获取“/a/b/c”的当前状态并将其添加到版本历史记录中。当然,每次您想要对版本控制节点进行更改时,都会重复此过程。
The 'checkin' and 'checkout' methods have to do with how a JCR repository tracks the versions of content. The 'checkout' method signals to the repository that your client application is (likely) going to be modifying some versionable content. The 'checkin' methods signals to the repository that your client application has made changes to the versionable content, and that the repository should record those changes (e.g., the new version) in the version history.
For example, let's imagine that we want to create a node at '/a/b/c' that is versionable. This is done using something like the following code:
To create content, you simply set the 'mix:versionable' mixin (or use a mixin or primary node type that inherits from 'mix:versionable') on a node and then save your changes. At that point, the repository will initialize the version history for that node (or subgraph).
Upon 'session.save()', the repository will note the 'mix:versionable' mixin and will initialize the version history for the content at '/a/b/c'. From this point on, your client application uses 'checkout' and 'checkin' to add new versions to the history.
When 'checkin' is called, the repository will take the current state of '/a/b/c' and will add it to the version history. Of course, this process is repeated each time you want to make changes to versionable nodes.
在 Jackrabbit 2.x 中,Node 上的方法为 已弃用。相反,请使用 VersionManager.checkout / checkin (它们在 Jackrabbit 1.x 中也可用)。这是一些示例代码:
In Jackrabbit 2.x, the methods on Node are deprecated. Instead, use VersionManager.checkout / checkin (they are available in Jackrabbit 1.x as well). Here is some sample code: