I see the difficulty; let me try and help.

You are correct that a new PostGISServiceImpl would be created here; what
you need to do is:
1. ask this instance for its ID
2. lookup that ID in the catalog
3. if found use what you found; if not you can add the instance you just
made to the catalog and continue

I need to think of a smoother way to generate an ID for a set of parameters
:-( On the bright side the PostGISServiceImpl will not do anything until you
try and call the resolve method for the first time.

Jody

On Tue, Feb 17, 2009 at 3:20 AM, Alessandro Sferrazza <
[email protected]> wrote:

>
> Hi to all,
>
> I need PostGISServiceImpl to execute some query from my postgis db.
>
> I tried this:
>
> PostgisDataStore database;
>
> java.util.Map<String, Serializable> params = new java.util.HashMap<String,
> Serializable>();
> params.put(PostgisDataStoreFactory.DBTYPE.key, "postgis");
> params.put(PostgisDataStoreFactory.HOST.key, "localhost");
> params.put(PostgisDataStoreFactory.PORT.key, 5432);
> params.put(PostgisDataStoreFactory.SCHEMA.key, "public");
> params.put(PostgisDataStoreFactory.DATABASE.key, "xxx");
> params.put(PostgisDataStoreFactory.USER.key, "XXX");
> params.put(PostgisDataStoreFactory.PASSWD.key, "XXX");
>
> IServiceFactory factory = CatalogPlugin.getDefault().getServiceFactory();
> for (IService service : factory.createService(params)) {
>        if (service.canResolve(PostgisDataStore.class)) {
>                try {
>                        database = service.resolve(PostgisDataStore.class,
> new
> NullProgressMonitor());
>                } catch (Exception e) {
>                        e.printStackTrace();
>                }
>        }
> }
>
> and this
>
> PostgisDataStoreFactory dsf = new PostgisDataStoreFactory();
> if (dsf.canProcess(params)) {
> try {
>        ds = (PostgisDataStore) dsf.createDataStore(params);
> } catch (IOException e) {
>      msg = e;
>      throw e;
> }
>
> but that will create a new connection, while I would like to continue using
> udig connection.
>
> Thanks in advance for any replies.
> --
> View this message in context:
> http://www.nabble.com/Get-PostGISServiceImpl-tp22040381p22040381.html
> Sent from the udig-devel mailing list archive at Nabble.com.
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
>
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to