David F. Barrero <david DOT barrero AT rediris DOT es>
In some cases you will need to use Searchy with some information support that Searchy cannot deal with, for example some data base, or you will want to implement some specific information retrieval algorithm. In those cases you will have to develop a custom provider.
Searchy has been designed to be quite flexible, and new providers may be easily developed. You will not need to deal with SOAP details and other nasty stuff, you will deal just with your algorithm, with your business logic and all the things you like to deal with (at least I hope you like them ;-)).
A provider may perform any task you want, there is only one limitation: is receives a query encapsulated in a Dublin Core element (see the Quick Uses's Guide to see a complete list of DC elements) and it must return its results also in Dublin Core. Do not worry about it, this stuff is done in two or three lines of code. Well, actually another limitation is that it have to be implemented in Java, but I do not thing it is a great problem. In a future new providers may be implemented in Python and other languages with a Java wrapper.
A provider may access any information support, using any retrieval algorithm, using any technology. The range of potential applications is huge, just use your imagination!.
The develop of a new provider is as easy as implement a Java interface, and a simple one.
A provider must perform at least two tasks, initialise itself with the config info given by the Searchy core, and attend queries. Those tasks are done thought the two methods in the Provider interface.
The provider will be created only one time when Searchy is starting, and Searchy will create as many instances of the provider as defined in the config file. Each time a request is received it launches the query in a thread, but you do not have to worry about it.
You can prepare your class to be a Searchy class with only four simple steps:
ProviderConfig is basically a hash table that keeps the config info given in agent.xml. You can retrieval a parameter with the method getParameter(String). All the checks about parameters should be done here, if there is a parameter not given, you should raise an exception. Searchy will do the rest of the job.
ProviderConfig also keeps the map, that is needed to perform the mapping to Dublin Core.
An example may clarify all this. Following you can find the setConfig method used in the Google provider.
4.- while (rs.next()) {
5.- HashMap resultHash = new HashMap(15);
6.-
7.- for (int i=1; i<meta.getColumnCount()+1; i++) {
8.- String valour = rs.getString(i);
9.- String key = meta.getColumnName(i);
10.- resultHash.put(key, valour);
11.- }
12.-
13.- result.add(this.map.mapResponse(resultHash));
14.- }
15.-
16.- rs.close();
17.- return result;
Once you have programmed your provider, it is time to execute it. Edit the config file (usually it is conf/agent.xml) and in the provider section, insert a new provider of type custom. Set a class label with the name of the class that implements your provider and any other label to set the provider parameters as it needs. Those parameters will be the ones given in the ProvideConfig object.
At least, if you use the init scripts, they must be modified to include your class and its dependences in the CLASSPATH. Extra .jar files in the scripts may be placed in the indicated place, so, it is quite easy to modify.
If you are going to use your provider in production, using a logging system is highly recommended. Searchy uses log4j, a logging system developed by the Apache team.
Using log4j in you provider is extremely simple, just import class org.apache.log4j.Logger, and insert this line in your class, it is usually the first line after the class declaration.
logger.info(message);
logger.warn(message);
logger.error(message);
logger.fatal(message);
In a future, our intention is to add Searchy RDF full support, with any vocabulary. If this feature is added, the providers interface may change. The general idea may not change, but backwards compatibility may be broken, so small changes to providers may be done in order to be used in future versions of Searchy.
If you have any question, or there are something you want to comment, please, do not dub and contact us thought the mailing lists, the forum or directly by email.
Any contribution to this project will be welcomed. It you have created a provider and you think that is may useful to anyone, let we know to make it part of Searchy.
This document was generated using the LaTeX2HTML translator Version 2002 (1.62)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -no_subdir -split 0 -no_navigation providersGuide.tex
The translation was initiated by on 2004-06-16