You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Tim Harsch <ha...@yahoo.com> on 2011/09/30 23:50:58 UTC

override DESCRIBE behavior?

I'm looking into what it would take to override the behavior of DESCRIBE.

So, I've implemented my own QueryEngine and know how to register that, so processing the WHERE clause of the DESCRIBE is easy enough.  


Unforunately though, when a QueryExecutionFactory returns the factory that creates the QueryExecution which executes the "execDescribe()" method.  It makes its way down to this method

static private QueryExecution make(Query query, Dataset dataset, Context context)
which instantiates a new QueryExecutionBase(),
so I see no way of replacing QueryExecutionBase() with another class to change the behavior.

Is there a prescribed way?  If not can we make QueryExecution get pulled from a registry or something?

Thanks,
Tim


Re: override DESCRIBE behavior?

Posted by Alexander Dutton <al...@oucs.ox.ac.uk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Tim,

The way that we're doing it¹ is to have a custom
DescribeHandlerFactory with a static block that hooks it into the
registry you talked about.

As we're using Fuseki, the class is stuck on the class path and
referenced using a 'ja:loadClass
"com.example.CustomDescribeHandlerFactory"' in the assembly file.
Here's the example code:

> package com.example;
> 
> import com.hp.hpl.jena.sparql.core.describe.DescribeHandler; import
> com.hp.hpl.jena.sparql.core.describe.DescribeHandlerFactory; import
> com.hp.hpl.jena.sparql.core.describe.DescribeHandlerRegistry;
> 
> public class CustomDescribeHandlerFactory implements
> DescribeHandlerFactory { static { DescribeHandlerRegistry registry
> = DescribeHandlerRegistry.get(); registry.clear(); registry.add(new
> CustomDescribeHandlerFactory()); } public DescribeHandler create()
> { return new CustomDescribeHandler(); } }

CustomDescribeHandler implements DescribeHandler, and needs to declare
start, describe and finish methods.

If you're doing something a bit more bespoke than just using Fuseki,
you'd probably want to grab the contents of the static block and put
it in your initialization somewhere, and forget about adding stuff to
an assembly file.

Hope this helps,

Alex

¹ Kudos to Damian Steer for telling me how in the first place!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6GR+QACgkQS0pRIabRbjAVsgCeIt35w4QH7XXFvZemYo9WW/O1
XPYAn3hbqNVZmP6eRSQCxlruE1901/Ee
=nkAB
-----END PGP SIGNATURE-----