<%@ page session="true" isThreadSafe="true" isErrorPage="false"%><%@ page import="java.util.ArrayList" %> <%@ page import="org.xmldb.api.*" %> <%@ page import="org.xmldb.api.base.*" %> <%@ page import="org.xmldb.api.modules.*" %> <%@ page import="org.w3c.dom.*" %> <%@ page import="org.exist.xmldb.XQueryService" %> <%@ page import="org.exist.security.MD5" %> <%@ page contentType="text/html; charset=UTF-8" %> <%! // Declarations String URICache = "xmldb:cache:///db/"; String URIRepos = "xmldb:exist://localhost:8080/exist/xmlrpc"; public void initDBManager(String configpath ) throws Exception { String driver = "org.exist.xmldb.DatabaseImpl"; Class cl = Class.forName(driver); // Repository Database dbrepository = (Database)cl.newInstance(); DatabaseManager.registerDatabase(dbrepository); // Cache System.out.println("Initialising db from:"+configpath); Database dbcache = (Database)cl.newInstance(); dbcache.setProperty("create-database", "true"); dbcache.setProperty("configuration", configpath); dbcache.setProperty("database-id", "cache"); DatabaseManager.registerDatabase(dbcache); } %><% // Instream code try { String testxml = "Hello there"; //Session session = request.getSession(true); String sid = session.getId(); long t0 = System.currentTimeMillis(); String CACHE_HOME = pageContext.getServletContext().getRealPath("/WEB-INF"); initDBManager(CACHE_HOME+"/conf.xml"); System.out.println("Done initDBManager,t="+(System.currentTimeMillis() - t0)); System.out.println("calling getCollection URICache:"+URICache); Collection root = DatabaseManager.getCollection(URICache); System.out.println("got root,t="+(System.currentTimeMillis() - t0)); CollectionManagementService mgtService = (CollectionManagementService)root.getService("CollectionManagementService", "1.0"); Collection colsess = mgtService.createCollection("mycol"); System.out.println("Created collection,t="+(System.currentTimeMillis() - t0)); XMLResource doc = (XMLResource)colsess.createResource("1~1", "XMLResource"); System.out.println("Created doc,t="+(System.currentTimeMillis() - t0)); doc.setContent(testxml); colsess.storeResource(doc); System.out.println("stored doc,t="+(System.currentTimeMillis() - t0)); XQueryService service = (XQueryService) colsess.getService("XQueryService", "1.0"); service.setProperty("indent", "yes"); service.setProperty("highlight-matches", "none"); System.out.println("got query service,t="+(System.currentTimeMillis() - t0)); String q1 = "//SearchRecord[DocId &= '1~1']"; ResourceSet q1rs = service.query(q1); System.out.println("q1rs:"+q1rs); XMLResource q1res = (XMLResource) q1rs.getResource( (long) 0 ); System.out.println("q1res:"+q1res); System.out.println("done query service,t="+(System.currentTimeMillis() - t0)); } catch (Throwable e) { e.printStackTrace(); } %>

Test

OK