當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.getCurrentContext方法代碼示例

本文整理匯總了Java中org.mozilla.javascript.Context.getCurrentContext方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.getCurrentContext方法的具體用法?Java Context.getCurrentContext怎麽用?Java Context.getCurrentContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mozilla.javascript.Context的用法示例。


在下文中一共展示了Context.getCurrentContext方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ensureScopePresent

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
private void ensureScopePresent()
{
    if (scope == null)
    {
        // Create a scope for the value conversion. This scope will be an empty scope exposing basic Object and Function, sufficient for value-conversion.
        // In case no context is active for the current thread, we can safely enter end exit one to get hold of a scope
        Context ctx = Context.getCurrentContext();
        boolean closeContext = false;
        if (ctx == null)
        {
            ctx = Context.enter();
            closeContext = true;
        }

        scope = ctx.initStandardObjects();
        scope.setParentScope(null);

        if (closeContext)
        {
            // Only an exit call should be done when context didn't exist before
            Context.exit();
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:25,代碼來源:ActivitiScriptNode.java

示例2: getScope

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
private ScriptableObject getScope() 
{
    // Create a scope for the value conversion. This scope will be an empty scope exposing basic Object and Function, sufficient for value-conversion.
    // In case no context is active for the current thread, we can safely enter end exit one to get hold of a scope
    ScriptableObject scope;
    Context ctx = Context.getCurrentContext();
    boolean closeContext = false;
    if (ctx == null) 
    {
        ctx = Context.enter();
        closeContext = true;
    }
    scope = ctx.initStandardObjects();
    scope.setParentScope(null);

    if (closeContext) 
    {
        Context.exit();
    }
    return scope;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:22,代碼來源:ScriptNodeTest.java

示例3: jsFunction_include

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
public void jsFunction_include(final Scriptable scope, String scriptName) throws Exception {
    final Context cx = Context.getCurrentContext();
    if (scriptName.charAt(0) != '/') {
        // relative script name -- resolve it against currently executing
        // script's directory
        String pathPrefix = currentScriptDirectory;
        while (scriptName.startsWith("../")) {
            final int lastSlash = pathPrefix.lastIndexOf('/');
            if (lastSlash == -1) {
                throw new FileNotFoundException("script:" + currentScriptDirectory + '/' + scriptName);
            }
            scriptName = scriptName.substring(3);
            pathPrefix = pathPrefix.substring(0, lastSlash);
        }
        scriptName = pathPrefix + '/' + scriptName;
    } else {
        // strip off leading slash
        scriptName = scriptName.substring(1);
    }
    final Script script = scriptStorage.getScript(scriptName);
    if (script == null) {
        throw new FileNotFoundException("script:" + scriptName);
    }
    try {
        final String oldScriptDirectory = currentScriptDirectory;
        currentScriptDirectory = getDirectoryForScript(scriptName);
        try {
            script.exec(cx, scope);
        } finally {
            currentScriptDirectory = oldScriptDirectory;
        }
    } finally {
    }
}
 
開發者ID:szegedi,項目名稱:spring-web-jsflow,代碼行數:35,代碼來源:HostObject.java

示例4: getHandler

import org.mozilla.javascript.Context; //導入方法依賴的package包/類
/**
 * get the (cached) handler Function for this event Handler
 * on first access compile the function
 * @return
 */
Function getHandler() {
    if (_handler == null) {
        String attribute = _baseElement.getAttributeWithNoDefault( _handlerName );
        if (attribute != null && Context.getCurrentContext() != null) {
            _handler = Context.getCurrentContext().compileFunction( _baseElement, "function " + AbstractDomComponent.createAnonymousFunctionName() + "() { " + attribute + "}", "httpunit", 0, null );
        }
    }
    return _handler;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:HTMLEventHandler.java


注:本文中的org.mozilla.javascript.Context.getCurrentContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。