本文整理汇总了Java中net.sf.saxon.lib.ExtensionFunctionDefinition类的典型用法代码示例。如果您正苦于以下问题:Java ExtensionFunctionDefinition类的具体用法?Java ExtensionFunctionDefinition怎么用?Java ExtensionFunctionDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtensionFunctionDefinition类属于net.sf.saxon.lib包,在下文中一共展示了ExtensionFunctionDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compile
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
public CrigttXsltExecutable compile(Source src, @Nullable ExtensionFunctionDefinition ... extFuncs) throws SaxonApiException {
CrigttProcessor proc = this.getProcessor();
CompilerInfo compilerInfo = this.getUnderlyingCompilerInfo();
if (!ArrayUtils.isEmpty(extFuncs)) {
IntegratedFunctionLibrary extFuncLib = new IntegratedFunctionLibrary();
Stream.of(extFuncs).forEach(extFuncLib::registerFunction);
compilerInfo.setExtensionFunctionLibrary(extFuncLib);
}
try {
PreparedStylesheet preparedStylesheet = Compilation.compileSingletonPackage(proc.getUnderlyingConfiguration(), compilerInfo, src);
return new CrigttXsltExecutable(proc, preparedStylesheet, compilerInfo);
} catch (XPathException e) {
throw new SaxonApiException(e);
}
}
示例2: registerEXPathFunction
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
private void registerEXPathFunction(ExtensionFunctionDefinition function, Configuration configuration) {
if (function instanceof EXPathFunctionDefinition) {
((EXPathFunctionDefinition) function).setConfiguration(configuration);
}
configuration.registerExtensionFunction(function);
functionClassNames.add(function.getClass().getName());
}
示例3: addFunction
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
@Override
@SuppressWarnings({ CompilerWarnings.UNCHECKED })
public T addFunction(ExtensionFunctionDefinition func) {
this.funcs.add(func);
return ((T) this);
}
示例4: setFunctions
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
@Override
@SuppressWarnings({ CompilerWarnings.UNCHECKED })
public T setFunctions(@Nullable List<ExtensionFunctionDefinition> funcs) {
this.funcs.clear();
if (!CollectionUtils.isEmpty(funcs)) {
this.funcs.addAll(funcs);
}
return ((T) this);
}
示例5: registerExtensions
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
static void registerExtensions(Configuration config, Collection<Library> libraries) {
for (Library lib: libraries) {
for (Function func: lib.getFunctions()) {
try {
ExtensionFunctionDefinition efd = new StaticFunctionExtension(func, config);
logger.trace("registerExtensions; funtion {} registered as {}", func.toString(), efd.getFunctionQName());
config.registerExtensionFunction(efd);
} catch (Exception ex) {
logger.warn("registerExtensions; error registering function {}: {}; skipped", func.toString(), ex.getMessage());
}
}
}
}
示例6: close
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
public void close() throws Exception {
if (isClosed) {
return;
}
isClosed = true;
logger.info(String.format("Closing webapp \"%s\" ...", name));
logger.info("Stopping file alteration monitor ...");
monitor.stop();
if (scheduler != null) {
logger.info("Shutting down Quartz scheduler ...");
if (waitForJobsAtClose) {
/* Unschedule all jobs: */
for (String triggerName : scheduler.getTriggerGroupNames()) {
for (TriggerKey triggerKey : scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(triggerName))) {
scheduler.unscheduleJob(triggerKey);
}
}
if (jobRequestCount > 0) {
logger.info("Wait for running jobs to finish ...");
while (jobRequestCount > 0) {
Thread.sleep(250);
}
logger.info("All jobs finished");
}
}
scheduler.shutdown(false);
logger.info("Shutdown of Quartz scheduler complete.");
}
logger.info("Closing XPath extension functions ...");
Iterator<ExtensionFunctionDefinition> functions = configuration.getRegisteredExtensionFunctions();
while (functions.hasNext()) {
ExtensionFunctionDefinition function = functions.next();
if (function instanceof Closeable) {
((Closeable) function).close();
}
}
if (httpClient != null) {
logger.debug("Closing HTTP client ...");
httpClient.close();
httpClient = null;
}
if (!dataSourceCache.isEmpty()) {
logger.info("Closing Datasources ...");
for (ComboPooledDataSource cpds : dataSourceCache.values()) {
cpds.close();
}
}
logger.info("Stopping queueing services ...");
for (ExecutorService service : executorServiceCache.values()) {
service.shutdownNow();
}
logger.info("Clearing compiled XSLT stylesheet cache ...");
xsltExecutableCache.clear();
logger.info("Clearing compiled STX stylesheet cache ...");
templatesCache.clear();
logger.info("Clearing compiled XQuery cache ...");
xqueryExecutableCache.clear();
logger.info("Clearing compiled XML Schema cache ...");
schemaCache.clear();
Thread.sleep(250);
logger.info(String.format("Webapp \"%s\" closed.", name));
}
示例7: addCustomExtensionFunctions
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
private void addCustomExtensionFunctions(WebApp webApp) throws Exception {
File libDir = new File(webApp.getHomeDir(), "lib");
if (!libDir.isDirectory()) {
return;
}
List<File> classPath = new ArrayList<File>();
classPath.addAll(FileUtils.listFiles(libDir, new WildcardFileFilter("*.jar"), DirectoryFileFilter.DIRECTORY));
if (classPath.isEmpty() && !XSLWebUtils.hasSubDirectories(libDir)) {
return;
}
classPath.add(libDir);
Collection<File> saxonJars = FileUtils.listFiles(new File(Context.getInstance().getWebInfDir(), "lib"),
new WildcardFileFilter("*saxon*.jar", IOCase.INSENSITIVE), FalseFileFilter.INSTANCE);
classPath.addAll(saxonJars);
logger.info("Initializing custom extension functions ...");
ClassFinder finder = new ClassFinder();
finder.add(classPath);
ClassFilter filter =
new AndClassFilter(
// Must extend ExtensionFunctionDefinition class
new SubclassClassFilter (ExtensionFunctionDefinition.class),
// Must not be abstract
new NotClassFilter (new AbstractClassFilter()));
Collection<ClassInfo> foundClasses = new ArrayList<ClassInfo>();
finder.findClasses(foundClasses, filter);
if (foundClasses.isEmpty()) {
logger.info("No custom extension functions found.");
return;
}
ClassLoaderBuilder builder = new ClassLoaderBuilder();
builder.add(classPath);
ClassLoader classLoader = builder.createClassLoader();
for (ClassInfo classInfo : foundClasses) {
String className = classInfo.getClassName();
if (initializer.isFunctionRegistered(className) || saxonJars.contains(classInfo.getClassLocation())) {
continue;
}
Class<?> clazz = classLoader.loadClass(className);
logger.info(String.format("Adding custom extension function class \"%s\" ...", className));
registerExtensionFunction((ExtensionFunctionDefinition) clazz.newInstance());
}
}
示例8: registerExtensionFunction
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
public void registerExtensionFunction(ExtensionFunctionDefinition function) {
config.registerExtensionFunction(function);
if (extensionFunctions != null) {
extensionFunctions.add(function);
}
}
示例9: getRegisteredExtensionFunctions
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
public Iterator<ExtensionFunctionDefinition> getRegisteredExtensionFunctions() {
return extensionFunctions.iterator();
}
示例10: parseStaticOptions
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
protected AbstractBeanDefinition parseStaticOptions(ParserContext parserContext, BeanDefinitionRegistry beanDefRegistry, Element elem, String elemNsPrefix,
String elemNsUri, String elemLocalName, AbstractBeanDefinition beanDef) throws Exception {
super.parseDefinition(parserContext, beanDefRegistry, elem, elemNsPrefix, elemNsUri, elemLocalName, beanDef);
MutablePropertyValues staticOptsPropValues = beanDef.getPropertyValues();
List<Element> staticFuncElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_FUNC_ELEM_LOCAL_NAME);
if (!staticFuncElems.isEmpty()) {
ManagedList<Object> staticFuncs = new ManagedList<>(staticFuncElems.size());
staticFuncs.setMergeEnabled(true);
staticFuncs.setElementTypeName(ExtensionFunctionDefinition.class.getName());
staticFuncElems
.forEach(staticFuncElem -> staticFuncs.add(new RuntimeBeanReference(staticFuncElem.getAttribute(BeanDefinitionParserDelegate.REF_ATTRIBUTE))));
staticOptsPropValues.addPropertyValue(FUNCS_PROP_NAME, staticFuncs);
}
List<Element> staticNsElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_NS_ELEM_LOCAL_NAME);
if (!staticNsElems.isEmpty()) {
ManagedMap<String, String> staticNamespaces = new ManagedMap<>(staticNsElems.size());
staticNamespaces.setMergeEnabled(true);
for (Element staticNsElem : staticNsElems) {
staticNamespaces.put(staticNsElem.getAttribute(PREFIX_ATTR_NAME), DomUtils.getTextValue(staticNsElem).trim());
}
staticOptsPropValues.addPropertyValue(NAMESPACES_PROP_NAME, staticNamespaces);
}
List<Element> staticVarElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_VAR_ELEM_LOCAL_NAME);
if (!staticVarElems.isEmpty()) {
ManagedMap<QName, Object> staticVars = new ManagedMap<>(staticVarElems.size());
staticVars.setMergeEnabled(true);
staticVars.setValueTypeName(XdmValue.class.getName());
for (Element staticVarElem : staticVarElems) {
staticVars.put(new QName(staticVarElem.getAttribute(NAME_ATTRIBUTE)), DomUtils.getTextValue(staticVarElem).trim());
}
staticOptsPropValues.addPropertyValue(VARS_PROP_NAME, staticVars);
}
List<Element> staticPooledDocElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_POOLED_DOC_ELEM_LOCAL_NAME);
if (!staticPooledDocElems.isEmpty()) {
XdmDocumentBeanDefinitionParser docBeanDefParser =
((XdmDocumentBeanDefinitionParser) this.nsHandler.getBeanDefinitionParsers().get(XdmDocumentBeanDefinitionParser.DOC_ELEM_LOCAL_NAME));
ManagedList<Object> staticPooledDocs = new ManagedList<>(staticPooledDocElems.size());
staticPooledDocs.setMergeEnabled(true);
staticPooledDocs.setElementTypeName(XdmDocument.class.getName());
for (Element staticPooledDocElem : staticPooledDocElems) {
staticPooledDocs.add(
docBeanDefParser.parse(staticPooledDocElem, new ParserContext(parserContext.getReaderContext(), parserContext.getDelegate(), beanDef)));
}
staticOptsPropValues.addPropertyValue(POOLED_DOCS_PROP_NAME, staticPooledDocs);
}
return beanDef;
}
示例11: getFunctions
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
@Override
public List<ExtensionFunctionDefinition> getFunctions() {
return this.funcs;
}
示例12: getExtensionFunctions
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
@Override
public ExtensionFunctionDefinition[] getExtensionFunctions() {
return this.extFuncs;
}
示例13: setExtensionFunctions
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
@Override
public void setExtensionFunctions(ExtensionFunctionDefinition ... extFuncs) {
this.extFuncs = extFuncs;
}
示例14: addFunction
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
public T addFunction(ExtensionFunctionDefinition funcDef);
示例15: getFunctions
import net.sf.saxon.lib.ExtensionFunctionDefinition; //导入依赖的package包/类
public List<ExtensionFunctionDefinition> getFunctions();