StaticContext context = new StaticContext(session.getUser());
broker = pool.get(session.getUser()); StaticContext context = new StaticContext(broker);
	public org.exist.soap.QueryResponse query(String sessionId, java.lang.String query)		throws java.rmi.RemoteException {		Session session = SessionManager.getInstance().getSession(sessionId);		if (!(query.startsWith("document(") || query.startsWith("collection(")))			query = "document()" + query;		QueryResponse resp = new QueryResponse();		resp.setHits(0);		try {			StaticContext context = new StaticContext(session.getUser());			XPathLexer2 lexer = new XPathLexer2(new StringReader(query));			XPathParser2 parser = new XPathParser2(lexer);			XPathTreeParser2 treeParser = new XPathTreeParser2(pool, context);			parser.xpath();			if (parser.foundErrors()) {				throw new RemoteException(parser.getErrorMessage());			}			AST ast = parser.getAST();			LOG.debug("generated AST: " + ast.toStringTree());			PathExpr expr = new PathExpr(pool);			treeParser.xpath(ast, expr);			if (treeParser.foundErrors()) {				throw new EXistException(treeParser.getErrorMessage());			}			LOG.info("query: " + expr.pprint());			long start = System.currentTimeMillis();			DocumentSet ndocs = expr.preselect();			if (ndocs.getLength() == 0)				return resp;			Value value = expr.eval(context, ndocs, null, null);			QueryResponseCollection[] collections = null;			if (value.getType() == Value.isNodeList)				collections = collectQueryInfo(scanResults(value.getNodeList()));			session.addQueryResult(value);			resp.setCollections(collections);			resp.setHits(value.getNodeList().getLength());			resp.setQueryTime(System.currentTimeMillis() - start);		} catch (Exception e) {			throw new RemoteException("query execution failed: " + e.getMessage());		}		return resp;	}