private MemoryServiceImpl getMemoryService() { // Make sure the memory service is in the catalog MemoryServiceImpl service = null; try { List<? extends IResolve> members = CatalogPlugin.getDefault().getLocalCatalog().members(new NullProgressMonitor()); for (IResolve resolve : members) { if (resolve instanceof MemoryServiceImpl) { if (URLUtils.urlEquals(resolve.getIdentifier(), MemoryServiceExtensionImpl.URL, true)) { service = (MemoryServiceImpl) resolve; break; } } } } catch (IOException e) { CatalogPlugin.log("Error finding services", e); // $NON-NLS-1$ } if (service == null) { service = new MemoryServiceImpl(MemoryServiceExtensionImpl.URL); CatalogPlugin.getDefault().getLocalCatalog().add(service); } return service; }
/** * Remove a memory datastore from the catalog, since the update is not possible (Caused by: * java.lang.UnsupportedOperationException: Schema modification not supported) * * @param typeName the name of the type to remove, if it is there */ public static synchronized void removeMemoryServiceByTypeName(String typeName) { MemoryServiceImpl service = null; try { List<? extends IResolve> members = CatalogPlugin.getDefault().getLocalCatalog().members(new NullProgressMonitor()); for (IResolve resolve : members) { if (resolve instanceof MemoryServiceImpl) { if (URLUtils.urlEquals(resolve.getIdentifier(), MemoryServiceExtensionImpl.URL, true)) { service = (MemoryServiceImpl) resolve; break; } } } if (service == null) return; MemoryDataStore ds = service.resolve(MemoryDataStore.class, new NullProgressMonitor()); if (Arrays.asList(ds.getTypeNames()).contains(typeName)) { CatalogPlugin.getDefault().getLocalCatalog().remove(service); } } catch (IOException e) { CatalogPlugin.log("Error finding services", e); // $NON-NLS-1$ } }