[Geoserver-devel] Plug-in Datasource

I noticed that in 0.96 shapefiles are now supported as a “plug-in”. The documentation says that additional data sources may be added by using the AbstractDataSource class from geotools. One question I have is now does geoserver know how to instantiate the data source? I would expect some kind of DataSource class definition in the info.xml file, but I don’t see it. Am I missing something?

David R Robison

Open Roads Consulting, Inc.

http://www.openroadsconsulting.com

The datasource class definition is basically provided in the
DatasourceParams element. The way it works is that a properly
implemented geotools plug in datasource will provide a datasource
factory class the implements the service provider interface. The META-
INF of the jar will have a file pointing to that datasource factory.
Each of those factories is registered, and then to invoke a geotools
datasource you just call it with the right params. This is why we
switched to the DatasourceParams from the old style of just specifying
host, user, password, ect. The DatasourceParams should be the correct
params to invoke the datasource you want to use. For postgis this is
done by having each of the appropriate params (check the
PostgisDatasourceFactory class for more info on how this done...I don't
have the link right now, but it's in the postgis geotools module),
including a dbtype='postgis'. For shapefiles it checks that there is a
param named url which has a file ending in .shp. Geoserver also
provides a 'filename' param, which will construct a url in the
featureType directory, so that if you put a road.shp in
featureTypes/road, then you just need to specify the filename as
road.shp, and the right url will be passed to the datasource
factories. Other file based datasources may look for the appropriate
file type suffix, or rbdm may also look for a dbtype and the presence
of the appropriate host, password, user, tablename, ect. It depends on
how the implementor decides to do it. Shapefile is
not currently truly plug-in, as we're rolling the jar ourselves. But
it could easily be a seperate jar. So the thing that you're missing is
the specification of the appropriate params for each datasource. As
people provide new datasources they need to implement the factory and
then let users know what parameters are needed to invoke the new
datasource. Does this make sense? I'll add some notes to the
documentation to make this clearer. I've also been meaning to write
something for geotools on 'how to implement a new datasource', that
will explain all the nitty gritty details past 'you just extend
abstract datasource'. If anyone is interested in implementing a new
geotools datasource let me know and I'll motivate to get that out to
you and up on geotools.

     thanks,

          Chris

Quoting David R Robison <drrobison@anonymised.com>:

I noticed that in 0.96 shapefiles are now supported as a "plug-in".
The
documentation says that additional data sources may be added by
using
the AbstractDataSource class from geotools. One question I have is
now
does geoserver know how to instantiate the data source? I would
expect
some kind of DataSource class definition in the info.xml file, but I
don't see it. Am I missing something?

David R Robison
Open Roads Consulting, Inc.
http://www.openroadsconsulting.com

-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/