Changes

Jump to navigation Jump to search
4 bytes added ,  11:23, 30 June 2021
=Integration=
Java classes can be coupled even more closely to the BaseX core library.If a class inherits the abstract [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/QueryModule.java QueryModule] class, the two variables [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/QueryContext.java queryContext] and [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/StaticContext.java staticContext] get available, which provide access to the global and static context of a query.
The [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/QueryResource.java QueryResource] interface can be implemented to enforce finalizing operations, such as the closing of opened connections or resources in a module. Its {{Code|close()}} method will be called after the XQuery expression has been fully evaluated.
The internal properties of functions can be assigned via annotations:
* Java functions can only be executed by users with [[User_Management|Admin permissions]]. You may can annotate a function with {{Code|@Requires(<Permission>)}} to also make it accessible to users with less fewer privileges.* Java code is treated as ''non-deterministic'', as its behavior cannot be predicted by the XQuery processor. You may annotate a function as {{Code|@Deterministic}} if you know that it will have no side-effects and will always yield the same result.
* Java code is treated as ''context-independent''. If a function accesses the query context, it should be annotated as {{Code|@ContextDependent}}
* Java code is treated as ''focus-independent''. If a function accesses the current context item, position or size, it should be annotated as {{Code|@FocusDependent}}
public class ContextModule extends QueryModule implements QueryResource {
/**
* Returns the name of the logged -in user.
* @return user string
*/
===Java Locks===
Java provides a handful of mechanism to control the execution of code. The concurrent execution of functions can be avoided with the {{Code|synchronized}} keyword. For more complex scenarios, the Lock and Semaphor , Semaphore and Atomic classes existcan be brought into play.
===XQuery Locks===
</syntaxhighlight>
If an XQuery expression invokes {{Code|write()}}, any other query that call calls {{Code|write()}} or {{Code|read()}} needs to wait for the query to be finished. The {{Code|read()}} function can be run in parallel; only those whereas queries are will be queued that call if {{Code|write()}}is called.
More details on concurrent querying can be found in the article on [[Transaction Management]].
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu