jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Unico Homme <un...@apache.org>
Subject Re: hasProperty vs getProperty
Date Mon, 25 Jun 2012 07:23:11 GMT
On Wed, Jun 13, 2012 at 12:23 PM, Bart van der Schans <
b.vanderschans@onehippo.com> wrote:

> On Tue, Jun 12, 2012 at 5:28 PM, Julian Reschke <julian.reschke@gmx.de>
> wrote:
> > On 2012-06-12 16:40, Bart van der Schans wrote:
> >>
> >> ...
> >>
> >> It's a quite common pattern. Once the node is loaded in the
> >> BundleCache (or an item/session cache) the hasProperty and getProperty
> >> calls are not that expensive. A call to the persistence layer to fetch
> >> the node data is much more expensive. If it is a performance hit in
> >> your case, do you have some profiler logs or benchmarks?
> >> ...
> >
> >
> > I'm looking at JCR-2950 and have the impression that the pair of calls
> > causes duplicate ACL checks.
> >
> > And yes, we may want to find out why those happen.
> >
> > But in my experience the best way to optimize is to avoid unnecessary
> calls,
> > not to make doing them less expensive :-)
>
> Yes of course ;-) We have our own access manager that caches the read
> permissions quite efficiently so that might be why we have never
> noticed a performance issue.
>
> Regards,
> Bart
>

Perhaps we should provide methods such as

public static Xxx getXxxProperty(Node node, String propertyName, Xxx
default) {
  try {
    return node.getProperty(propertyName).getXxx();
  } catch (PathNotFoundException e) {
    return default;
  }
}

in JcrUtils.

So that you can write:

final Xxx x = JcrUtils.getXxxProperty(node, "prop", null);
if (x != null) {
  // etc


--
Unico

Mime
View raw message