jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Diephouse <dan.diepho...@mulesource.com>
Subject Re: Enforcing constraints; Sessions and Threading
Date Mon, 05 Nov 2007 21:42:35 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Jukka Zitting wrote:
<blockquote
 cite="mid:510143ac0711051312j6cffc05br81f284724d9eea9a@mail.gmail.com"
 type="cite">
  <pre wrap="">Hi,

On 11/5/07, Dan Diephouse <a class="moz-txt-link-rfc2396E"
 href="mailto:dan.diephouse@mulesource.com">&lt;dan.diephouse@mulesource.com&gt;</a>
wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">This is probably a horrendously stupid question, but I'm hoping someone
can help me figure out how to enforce constraints nodes. I'm writing a
JCR store for Abdera to store Atom entries. I'm creating a node for each
entry and one of the properties on the node is the "resource name".
(I.e. what's in the HTTP URL - /my_entry.atom). I don't ever want to
have multiple nodes with the same resource name property. Whats the best
way to enforce this so I can never have two threads create the same
resource at the same time?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
There's nothing like a UNIQUE constraint in JCR or Jackrabbit (though
it might be good to have at least a Jackrabbit feature request in Jira
for that), so the closest you can get probably to make the "resource
name" be the name of the entry node and have all the entries stored as
children of a parent node that doesn't allow same-name-siblings.

  </pre>
</blockquote>
OK that could work!<br>
<blockquote
 cite="mid:510143ac0711051312j6cffc05br81f284724d9eea9a@mail.gmail.com"
 type="cite">
  <pre wrap="">Alternatively you need to implement that constraint in your code.
Whenever creating a new node (or modifying the "resource name"
property) you could lock the subtree (or just a separate lock node)
and check that the constraint isn't being violated before saving the
changes.</pre>
</blockquote>
I really don't want to lock the whole collection of entries though.
That would mean I would get a LockException if another thread tried
writing to that node, which 99.9999% of the time won't cause a
conflict. <br>
<br>
Cheers,<br>
- Dan<br>
<pre class="moz-signature" cols="72">-- 
Dan Diephouse
MuleSource
<a class="moz-txt-link-freetext" href="http://mulesource.com">http://mulesource.com</a>
| <a
 class="moz-txt-link-freetext" href="http://netzooid.com/blog">http://netzooid.com/blog</a></pre>
</body>
</html>

Mime
View raw message