private static void shutdown(Collection collection) { try { // shutdown the database gracefully DatabaseInstanceManager manager = (DatabaseInstanceManager) collection.getService("DatabaseInstanceManager", "1.0"); manager.shutdown(); } catch (XMLDBException e) { fail(e.getMessage()); } }
/* * @see TestCase#tearDown() */ protected void tearDown() { try { Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); CollectionManagementService service = (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); service.removeCollection(TEST_COLLECTION_NAME); DatabaseManager.deregisterDatabase(database); DatabaseInstanceManager dim = (DatabaseInstanceManager) testCollection.getService("DatabaseInstanceManager", "1.0"); dim.shutdown(); database = null; testCollection = null; System.out.println("tearDown PASSED"); } catch (XMLDBException e) { fail(e.getMessage()); } }
public static void main(String args[]) throws Exception { String driver = "org.exist.xmldb.DatabaseImpl"; Class cl = Class.forName(driver); Database database = (Database) cl.newInstance(); DatabaseManager.registerDatabase(database); Collection col = DatabaseManager.getCollection("xmldb:exist:///db", "admin", ""); XPathQueryService service = (XPathQueryService) col.getService("XPathQueryService", "1.0"); service.setProperty("indent", "yes"); ResourceSet result = service.query( "for $s in //intervention/(speaker|writer)/affiliation[@EPparty ='PSE'] return data($s/../../(speech|writing)/@ref)"); ResourceIterator i = result.getIterator(); while (i.hasMoreResources()) { Resource r = i.nextResource(); System.out.println((String) r.getContent()); } // shut down the database DatabaseInstanceManager manager = (DatabaseInstanceManager) col.getService("DatabaseInstanceManager", "1.0"); manager.shutdown(); }