You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by "Marian Schedenig (qs)" <Ma...@qualysoft.com> on 2009/03/09 17:42:32 UTC

Computed properties

Hi!

I'm trying to implement dependencies between resources ("files") in my JCR,
more or less resembling a directed graph. Each file can have a number of
dependency subnodes which contain the path of a resource the property owner
depends on. This resource does not have to exist at the time the dependency
is set, but if it does, a reverseDependency subnode should automatically be
created on it pointing back to the resource containing the dependency node.
If the dependency target does not yet exist, the reverseDependency should be
created as soon as the target is created. For this, I have to keep a list of
"broken dependencies" somewhere, e.g. a system directory. A broken
dependency should be automatically created when a reverseDependency cannot
be set or when the owner of a reverseDependency is removed, and it should be
automatically deleted when the target comes into existence (and gets its
reverseDependency node). Likewise, deleting a node with dependencies should
remove all corresponding broken dependencies and reverseDependencies. The
respository is accessed through WebDAV.

My sample implementation so far creates/updates these nodes in a custom
PropertyHandler (I'm using fake properties called "setDependency" and
"removeDependency" to trigger these updates - the properties themselves are
never created; not a solution I'm happy with, but the only one I could think
of so far). Even though it's not forseeable that our JCR will ever be
accessed through other means than WebDAV, I don't like the fact that this
logic resides in the DAV layer, and anyway, I don't see how I could react on
newly created or deleted target nodes there.

So my idea was to use workspace observers to maintain correct reverse
dependencies. But after browsing the mailing list archives, I've come to
believe that asynchronous observers aren't guaranteed to be called
"immediately", making reverse dependency queries unreliable. And according
to [1], synchronous listeners aren't allowed to make workspace updates
themselves.

So now I'm somewhat stumped. What would be the reasonable way to implement
this scenario?

Cheers,
Marian.

[1]
http://www.nabble.com/Synchronous-event-listener-td17209309.html#a17225492

-- 
View this message in context: http://www.nabble.com/Computed-properties-tp22413688p22413688.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Computed properties

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Mon, Mar 16, 2009 at 4:47 PM, Marian Schedenig (qs)
<Ma...@qualysoft.com> wrote:
> Jukka Zitting wrote:
>> Do you actually need to have these "reverseDependency" nodes? A query
>> for "all nodes with a dependency to this node" might give you the same
>> functionality.
>
> I need it in WebDAV at least (the only way we access the JCR at the moment).
> As I haven't found a way so far to compute only those WebDAV properties
> actually requested by the client on the fly, I'd have to do the reverse
> dependency search each time a node is accessed - which sounds rather costly
> to me?

Does your client application need the reverse dependencies every time
you access a node? If not, you could drop the explicit reverse
dependency properties, and get the information with a DASL query only
when your client actually needs it.

Anyway, the kind of "virtual properties" you were thinking of are not
currently supported by Jackrabbit. You'll need to implement them on
the application layer either as a part of the save() operation (like
you currently do in the DAV layer you've customized), in an event
listener using observation (with the asynchronous processing you
noticed), or as a separate batch process (again with the
asynchronity).

BR,

Jukka Zitting

Re: Computed properties

Posted by "Marian Schedenig (qs)" <Ma...@qualysoft.com>.

Jukka Zitting wrote:
> 
> Do you actually need to have these "reverseDependency" nodes? A query
> for "all nodes with a dependency to this node" might give you the same
> functionality.
> 

I need it in WebDAV at least (the only way we access the JCR at the moment).
As I haven't found a way so far to compute only those WebDAV properties
actually requested by the client on the fly, I'd have to do the reverse
dependency search each time a node is accessed - which sounds rather costly
to me?

Thx,
Marian.

-- 
View this message in context: http://www.nabble.com/Computed-properties-tp22413688p22541037.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Computed properties

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Mon, Mar 9, 2009 at 5:42 PM, Marian Schedenig (qs)
<Ma...@qualysoft.com> wrote:
> I'm trying to implement dependencies between resources ("files") in my JCR,
> more or less resembling a directed graph. Each file can have a number of
> dependency subnodes which contain the path of a resource the property owner
> depends on. This resource does not have to exist at the time the dependency
> is set, but if it does, a reverseDependency subnode should automatically be
> created on it pointing back to the resource containing the dependency node.

Do you actually need to have these "reverseDependency" nodes? A query
for "all nodes with a dependency to this node" might give you the same
functionality.

BR,

Jukka Zitting

Re: Computed properties

Posted by "Marian Schedenig (qs)" <Ma...@qualysoft.com>.
A somewhat alternate approach would be to keep the necessary data anywhere
(in the JCR or outside). This would require "virtual" properties, where
setting a property only triggers a custom method for storing the data, and
getting it would call another method that computers the property value.

I'm not sure this is possible with Jackrabbit though?

-- 
View this message in context: http://www.nabble.com/Computed-properties-tp22413688p22539455.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.