How could I implement a plugin which registers a new database provider for DAL ?
Back to ForoCurrently 4 replie(s)
Re: Re: Re: Re: How could I implement a plugin which registers a new database provider for DAL ?
Hi Cèsar,
> > In that case should I implement a SQLiteLibrary (for as you tell me "initialization and configuration of the library" )
> > with the same methods as MySQLLibrary extending AbstractLibrary ( as it already is for the SqLiteLibrary class I've
> > created yesterday )?
> Yes, you must create a SQLiteLibrary class which is loaded automatically when the application (gvSIG) is launched,
> so you can register your provider into DAL, as well as any other initializations you need.
> One question: how are you planning to access the SQLite database? through JDBC or straight through the library?
> If not through JDBC, then maybe its better not to use the JDBC based providers as example, as they extend the
> JDBC generic provider which provides most functionality. Maybe its better in that case to take a look at the
> DWG or GPE based ones, which also use a library.
The library as I've written it till now works on an higher level, not exposing the low-level methods, in a way like this:
//The Constructor
//that takes connection data as param
SqliteSpatial spFdo = new SqliteSpatial("sampleDb/sqliteFdoDB.sqlite", "userid", "passw");
//The execute method
//that executes the SQL method returning a QueryResultsCollection object (that's more or less a list of "row" result ) in case of a //SELECT query or a null if it's another SQL command
QueryResultsCollection rezFdo = spFdo.execute("SELECT Name, Geometry FROM places WHERE OGC_FID = 2");
I can change it of course but if we could use it as it is we could add this till now to gvSig and fix all the things we don't like later.
Ok, I try to do something like DWG or GPE.
Mostly I've not yet understood how I could pass the result set to a "gvSig something" class.
I look better into the two extensions above.
Any suggestion is much more than welcome.
Thanks Cèsar,
also for your patience!
Muchas Gracias,
Luca
Re: Re: Re: How could I implement a plugin which registers a new database provider for DAL ?
Hi Luca,
> I guess I've more or less understood the general approach for a basic extension (like the FortuneCookie).
> For register a new Database Provider should I implement anything like org.gvsig.fmap.dal.store.mysql ?
Yes, this one and the PostgreSQL one are examples of database providers.
>In that case should I implement a SQLiteLibrary (for as you tell me "initialization and configuration of the library" ) with the same methods as MySQLLibrary extending AbstractLibrary ( as it already is for the SqLiteLibrary class I've created yesterday )?
Yes, you must create a SQLiteLibrary class which is loaded automatically when the application (gvSIG) is launched, so you can register your provider into DAL, as well as any other initializations you need.
> For example:
> in MySQLLibrary and PostgreSQLLibrary classes I have a getJDBCUrl() method returning the string of the url for accessing the database.
> Should I have a similar method in SQLiteLibrary but working with the small library I've created ?
This is an utility method used by the PostgreSQL provider implementation. You can create it if you like that approach.
One question: how are you planning to access the SQLite database? through JDBC or straight through the library?
If not through JDBC, then maybe its better not to use the JDBC based providers as example, as they extend the JDBC generic provider which provides most functionality. Maybe its better in that case to take a look at the DWG or GPE based ones, which also use a library.
Re: Re: How could I implement a plugin which registers a new database provider for DAL ?
Hi Cèsar,
I guess I've more or less understood the general approach for a basic extension (like the FortuneCookie).
For register a new Database Provider should I implement anything like org.gvsig.fmap.dal.store.mysql ?
In that case should I implement a SQLiteLibrary (for as you tell me "initialization and configuration of the library" ) with the same methods as MySQLLibrary extending AbstractLibrary ( as it already is for the SqLiteLibrary class I've created yesterday )?
For example:
in MySQLLibrary and PostgreSQLLibrary classes I have a getJDBCUrl() method returning the string of the url for accessing the database.
Should I have a similar method in SQLiteLibrary but working with the small library I've created ?
Cheers,
Lu
Re: How could I implement a plugin which registers a new database provider for DAL ?
Hi Luca,
Sorry but we still don't have any documentation available about how to develop a new DAL provider.
Maybe you could prepare some questions about specific problems or doubts you are facing.
Just in case, take into account that you only need the gvSIG plugin to install and contain your library jar files. To register your sqlite provider into DAL you will have to use a Library [1]. You can take a look at the Library objects available in the libFMap_dalfile project as an example.
You can also take a look at the extDWG project, as it is very similar to your own project.
The libDWG project is a library to access DWG files, without any gvSIG application dependence, not even from DAL.
The extDWG project contains both the DAL provider implementation and the gvSIG plugin, as it is an old project and it still has the old project structure. If you look at the org.gvsig.dwg.DWGRegisterExtension class, it is mainly empty. All the registration process is performed into the org.gvsig.dwg.fmap.dal.store.dwg.DWGLibrary class.
We have to refactor the extDWG project, at least so it generates two jar files, one with the DAL provider and another one with the gvSIG plugin, so the DWG DAL provider could be used outside gvSIG without the plugins. In your case, with the default maven project structure created by the plugin wizard it is already separated.
Hope this helps.
[1] http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/org.gvsig.tools/2.1.0/org-gvsig-tools-library
Hi all,
I've created a org.gvsig.sqlite plugin for gvSIG 2.0 with the Plugin Creation Wizard.
I'd need to implment a plugin registering a new SQLite database provider for DAL.
Could anyone help me with some examples or with some instructions in fulfilling this task ?
Even small helps or quick hints (links to some documentation, simple coding examples, ideas, etc.) can be very very helpful.
Till now I've just found the official documentation [1] and read the code of libFMap_daldb (implementing the support for PostGreSql and MySQL). Everything looks quite clear but I could not understand how to implement the plugin we need.
I'd be very grateful for any help,
All the best,
Luca
[1] http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/crear-un-proyecto-para-gvsig/estructura-de-un-proyecto-en-gvsig