Changes

Jump to navigation Jump to search
1,145 bytes added ,  18:52, 18 November 2020
no edit summary
* The namespace of the function name identifies the Java class.
* The local part of the name, which is rewritten to camel case, identifies a variable or function of that class.
* The middle dot character <code>[httphttps://www.fileformat.info/info/unicode/char/b7/index.htm ·]</code> (&amp;#xB7;, a valid character in XQuery names, but not in Java) can be used to append exact Java parameter types to the function name. Class types must be referenced by their full path.
{| class="wikitable"
Please visit the XQuery 3.0 specification if you want to get more insight into
[httphttps://www.w3.org/TR/xpath-functions-3031/#properties-of-functions function properties]. ==Updates== The {{Code|@Updating}} annotation can be applied to mark Java functions that perform write or update operations: <syntaxhighlight lang="java"> @Updating public void backup() { // ... }</syntaxhighlight> An XQuery expression will be handled as an [[XQuery Update#Updating Expressions|updating expression]] if it calls an updating Java function. In contrast to XQuery update operations, the Java code will immediately be executed, but the result will be cached as if {{Function|Update|update:output}} was called. The annotation is particularly helpful if combined with a lock annotation.
==Locking==
By default, a Java function will be executed in parallel with other code. If a Java function performs sensitive operations, it is advisable to explicitly lock the code. ===Java Locks=== Java provides a handful of mechanism to control the execution of code. The concurrent execution of functions can be avoided with the {{MarkCode|Updated with Version 9.4:synchronized}} Single annotation for read keyword. For more complex scenarios, Lock and Semaphor and write locksAtomic classes exist===XQuery Locks===
By default, a Java function will be executed in parallel with other code. If a Java function performs sensitive operations, it is advisable you want to explicitly lock synchronize the execution of your code. This with BaseX locks, you can be realized via locking annotationstake advantage of the {{Code|@Lock}} annotation:
<syntaxhighlight lang="java">
@Lock("HEAVYIO") public void read() { // ... }  @Updating @Lock("HEAVYIO")
public void write() {
// ...
</syntaxhighlight>
If the function writes or updates dataan XQuery expression invokes {{Code|write()}}, a any other query that call {{Code|write lock should ()}} or {{Code|read()}} needs to wait for the query to be enforced via a finished. The {{FunctionCode|Update|update:outputread()}} function can be run in parallel; only those queries are queued that call: <syntaxhighlight lang="java">java-module:{{Code|write() => update:output()</syntaxhighlight>}}.
More details on parallel query execution concurrent querying can be found in the article on [[Transaction Management]].
==Data Types==
=Changelog=
 
; Version 9.4
* Added: Annotation for [[#Updates|updating functions]].
* Updated: Single annotation for read and write locks.
; Version 8.4
 
* Updated: Rewriting rules
;Version 8.2
 
* Added: [[#URI Rewriting|URI Rewriting]]: support for URNs
; Version 8.0
 
* Added: {{Code|QueryResource}} interface, called after a query has been fully evaluated.
; Version 7.8
 
* Added: Java locking annotations
* Updated: {{Code|context}} variable has been split into {{Code|queryContext}} and {{Code|staticContext}}.
; Version 7.2.1
 
* Added: import of Java modules, context awareness
* Added: [[#Packaging|Packaging]], [[#URI Rewriting|URI Rewriting]]
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu