@Override public void sourceAdded(SourceEvent e) { String name = e.getName(); SourceManager sm = dsf.getSourceManager(); if (e.isWellKnownName() && !sm.getSource(name).isSystemTableSource() && !layerMap.containsKey(name)) { try { Layer layer = new Layer(); layer.setName(name); layer.setTitle(name); // Setting the bounding box data DataSource ds = dsf.getDataSource(name); ds.open(); Envelope env = ds.getFullExtent(); CoordinateReferenceSystem crs = ds.getCRS(); ds.close(); BoundingBox bBox = getBoundingBox(env, crs); if (bBox == null) { return; } layer.getCRS().add(bBox.getCRS()); layer.getBoundingBox().add(bBox); layer.setEXGeographicBoundingBox(getGeographicBoundingBox(env, bBox.getCRS())); layer.setQueryable(true); if (layerStyles.containsKey(name)) { String[] lStyles = layerStyles.get(name); for (int i = 0; i < lStyles.length; i++) { Style style = new Style(); String styleName = lStyles[i]; style.setName(styleName); style.setTitle(styleName); layer.getStyle().add(style); } } layerMap.put(name, layer); } catch (NoSuchTableException ex) { } catch (DataSourceCreationException ex) { } catch (DriverException ex) { } } }