I'm implementing a custom ActionTool working on a PostGIS layer, and I need to access the underlying DataSource from the tool implementation. I'm not sure if the following code is the best way of doing so, but with this approach, I hit a bug in PostgisSchemaFolder
ILayer layer = getContext().getSelectedLayer();
IService service = layer.getGeoResource().resolve(IService.class, null);
IResolve member = service.members(null).get(0);
boolean canResolve = member.canResolve(JDBCDataStore.class);
catch (IOException exc)
member is of class PostgisSchemaFolder. canResolve() returns true for JDBCDataStore, but resolve() only works for DataStore, not for JDBCDataStore. I locally patched the resolve() method, replacing DataStore by JDBCDataStore to make things work.