Changes

Jump to navigation Jump to search
446 bytes added ,  18:36, 23 November 2014
* 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}}
 
Since {{Version|8.0}}, the [https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/QueryResource.java QueryResource] interface can be implemented to finalize opened connections or resources in a module. Its {{Code|close()}} method will be called after the query has been evaluated.
The following XQuery code invokes two Java methods. The first Java function retrieves information from the static query context, and the second one throws a query exception:
/**
* This example is inherited from inherits the {@link QueryModule} classand * implements the QueryResource interface.
*/
public class ContextModule extends QueryModule implements QueryResource {
/**
* Returns the name of the logged in user.
throw new QueryException(ex.getMessage());
}
}
 
@Override
public void close() {
// see description above
}
}
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu