Loading TOC...

MarkLogic 10 Product Documentation
plugin:initialize-scope

plugin:initialize-scope(
   $scope as xs:string
) as xs:integer

Summary

This function ensures the availability of all plugins from a given scope. A scope is a directory relative to marklogic-dir/Assets/plugins. Attempting to reload the System scope (with an empty string for $scope) has no effect (and hence returns 0). Any application that calls this function must do so through a function amped to the application-plugin-registrar role.

This function MUST be called by an application before querying or enumerating plugins (or else see an empty set of available plugins). Even if called on every request, this function will only load from the directory on the first call. This function checks the global debug flag, and if true, forces a reload on every request.

Parameters
scope A scope identifier. This must be a "dotted" package-style path, which will be resolved relative to the marklogic-dir/Assets/plugins directory. For example, a $scope value of my-plugin-scope is resolved to the marklogic-dir/Assets/plugins/myplugin-scope directory and a $scope value of my.plugin.scope is resolved to the marklogic-dir/Assets/plugins/my/plugin/scope directory.

Required Privileges

This function requires the privileges in the application-plugin-registrar role, and the best practice is to put plugin:initialize-scope in a function that is amped to the application-plugin-registrar role.

Example

xquery version "1.0-ml"; 
 
import module namespace plugin = "http://marklogic.com/extension/plugin" 
    at "/MarkLogic/plugin/plugin.xqy";

plugin:initialize-scope("marklogic.appservices")

(: Initializes all of the plugins located in /Assets/plugins/marklogic/appservices :)
 

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.