public Engine(Collection<Index> indexes, Map<String, TEClassLoader> classLoaders, int cacheSize) throws Exception { this(); this.classLoaders = classLoaders; if (cacheSize > 0) { this.cacheSize = cacheSize; } addFunctionLibrary(indexes); }
loadedExecutables.put(key, executable); } catch (OutOfMemoryError e) { boolean freed = freeExecutable(); if (!freed) { throw e; boolean freed = freeExecutable(); if (!freed) { break;
public int execute_test(String testName, List<String> params, XdmNode contextNode) throws Exception { if (LOGR.isLoggable( FINE)) { String logMsg = String.format( "Preparing test %s for execution, using params:%n %s", testName, params); LOGR.fine(logMsg); } TestEntry test = index.getTest(testName); if (test == null) { throw new Exception("Error: Test " + testName + " not found."); } XdmNode paramsNode = engine.getBuilder().build( new StreamSource(new StringReader(getParamsXML(params)))); if (contextNode == null && test.usesContext()) { String contextNodeXML = "<context><value>" + test.getContext() + "</value></context>"; contextNode = engine.getBuilder().build( new StreamSource(new StringReader(contextNodeXML))); } XPathContext context = getXPathContext(test, opts.getSourcesName(), contextNode); return executeTest(test, paramsNode, context); }
Engine engine = new Engine(masterIndex, setupOpts.getSourcesName(), defaultLoader); TECore ctlRunner = new TECore(engine, masterIndex, runOpts);
/** * Loads all of the XSL executables. This is a time consuming operation. * * @param index * @param sourcesName * A stylesheet reference. * @throws Exception * If the stylesheet fail to compile. */ public void preload(Index index, String sourcesName) throws Exception { for (String key : index.getTestKeys()) { TestEntry te = index.getTest(key); loadExecutable(te, sourcesName); } for (String key : index.getFunctionKeys()) { List<FunctionEntry> functions = index.getFunctions(key); for (FunctionEntry fe : functions) { if (!fe.isJava()) { loadExecutable(fe, sourcesName); } } } }
if (instance == null) { try { TEClassLoader cl = engine.getClassLoader(opts .getSourcesName()); instance = Misc.makeInstance(pe.getClassName(), TEClassLoader cl = engine.getClassLoader(opts.getSourcesName()); method = Misc.getMethod(pe.getClassName(), pe.getMethod(), cl, 3, 4);
XsltTransformer formTransformer = engine.getFormExecutable().load(); formTransformer.setSource(new DOMSource(ctlForm)); formTransformer.setParameter(new QName("title"), new XdmAtomicValue(
Engine engine = new Engine(masterIndex, setupOpts.getSourcesName(), defaultLoader); TECore ctlRunner = new TECore(engine, masterIndex, runOpts);
/** * Loads all of the XSL executables. This is a time consuming operation. * * @param index * @param sourcesName * A stylesheet reference. * @throws Exception * If the stylesheet fail to compile. */ public void preload(Index index, String sourcesName) throws Exception { for (String key : index.getTestKeys()) { TestEntry te = index.getTest(key); loadExecutable(te, sourcesName); } for (String key : index.getFunctionKeys()) { List<FunctionEntry> functions = index.getFunctions(key); for (FunctionEntry fe : functions) { if (!fe.isJava()) { loadExecutable(fe, sourcesName); } } } }
if (instance == null) { try { TEClassLoader cl = engine.getClassLoader(opts .getSourcesName()); instance = Misc.makeInstance(pe.getClassName(), TEClassLoader cl = engine.getClassLoader(opts.getSourcesName()); method = Misc.getMethod(pe.getClassName(), pe.getMethod(), cl, 3, 4);
XsltTransformer formTransformer = engine.getFormExecutable().load(); formTransformer.setSource(new DOMSource(ctlForm)); formTransformer.setParameter(new QName("title"), new XdmAtomicValue(
public int execute_test(String testName, List<String> params, XdmNode contextNode) throws Exception { if (LOGR.isLoggable( FINE)) { String logMsg = String.format( "Preparing test %s for execution, using params:%n %s", testName, params); LOGR.fine(logMsg); } TestEntry test = index.getTest(testName); if (test == null) { throw new Exception("Error: Test " + testName + " not found."); } XdmNode paramsNode = engine.getBuilder().build( new StreamSource(new StringReader(getParamsXML(params)))); if (contextNode == null && test.usesContext()) { String contextNodeXML = "<context><value>" + test.getContext() + "</value></context>"; contextNode = engine.getBuilder().build( new StreamSource(new StringReader(contextNodeXML))); } XPathContext context = getXPathContext(test, opts.getSourcesName(), contextNode); return executeTest(test, paramsNode, context); }
XPathContext getXPathContext(TestEntry test, String sourcesName, XdmNode contextNode) throws Exception { XPathContext context = null; if (test.usesContext()) { XsltExecutable xe = engine.loadExecutable(test, sourcesName); Executable ex = xe.getUnderlyingCompiledStylesheet() .getExecutable(); context = new XPathContextMajor(contextNode.getUnderlyingNode(), ex); } return context; }
int argCount = paramElements.size(); if (fe.getMinArgs() >= argCount && fe.getMaxArgs() <= argCount) { TEClassLoader cl = engine.getClassLoader(opts .getSourcesName()); Method method = Misc.getMethod(fe.getClassName(),
public Engine(Collection<Index> indexes, Map<String, TEClassLoader> classLoaders, int cacheSize) throws Exception { this(); this.classLoaders = classLoaders; if (cacheSize > 0) { this.cacheSize = cacheSize; } addFunctionLibrary(indexes); }
loadedExecutables.put(key, executable); } catch (OutOfMemoryError e) { boolean freed = freeExecutable(); if (!freed) { throw e; boolean freed = freeExecutable(); if (!freed) { break;
String testId = LogUtils.getTestIdFromLog(log); TestEntry test = index.getTest(testId); net.sf.saxon.s9api.DocumentBuilder builder = engine.getBuilder(); XdmNode paramsNode = LogUtils.getParamsFromLog(builder, log); XdmNode contextNode = LogUtils.getContextFromLog(builder, log);
XPathContext getXPathContext(TestEntry test, String sourcesName, XdmNode contextNode) throws Exception { XPathContext context = null; if (test.usesContext()) { XsltExecutable xe = engine.loadExecutable(test, sourcesName); Executable ex = xe.getUnderlyingCompiledStylesheet() .getExecutable(); context = new XPathContextMajor(contextNode.getUnderlyingNode(), ex); } return context; }