当前位置: 首页>>代码示例>>Java>>正文


Java Callable.call方法代码示例

本文整理汇总了Java中org.mozilla.javascript.Callable.call方法的典型用法代码示例。如果您正苦于以下问题:Java Callable.call方法的具体用法?Java Callable.call怎么用?Java Callable.call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mozilla.javascript.Callable的用法示例。


在下文中一共展示了Callable.call方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: callWithDomain

import org.mozilla.javascript.Callable; //导入方法依赖的package包/类
/**
 * Calls {@link Callable#call(Context, Scriptable, Scriptable, Object[])} of
 * <code>callable</code> under restricted security domain where an action is
 * allowed only if it is allowed according to the Java stack on the
 * moment of the <code>callWithDomain</code> call and
 * <code>securityDomain</code>. Any call to
 * {@link #getDynamicSecurityDomain(Object)} during execution of
 * {@link Callable#call(Context, Scriptable, Scriptable, Object[])}
 * should return a domain incorporate restrictions imposed by
 * <code>securityDomain</code>.
 */
public Object callWithDomain(Object securityDomain, final Context cx,
                             final Callable callable,
                             final Scriptable scope,
                             final Scriptable thisObj,
                             final Object[] args) {
    AccessControlContext acc;
    if (securityDomain instanceof AccessControlContext)
        acc = (AccessControlContext)securityDomain;
    else {
        RhinoClassLoader loader = (RhinoClassLoader)securityDomain;
        acc = loader.rhinoAccessControlContext;
    }

    PrivilegedExceptionAction execAction = new PrivilegedExceptionAction() {
        public Object run() {
            return callable.call(cx, scope, thisObj, args);
        }
    };
    try {
        return AccessController.doPrivileged(execAction, acc);
    } catch (Exception e) {
        throw new WrappedException(e);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:36,代码来源:BatikSecurityController.java

示例2: callWithDomain

import org.mozilla.javascript.Callable; //导入方法依赖的package包/类
@Override
public Object callWithDomain(Object securityDomain, final Context ctx, final Callable callable,
		final Scriptable scope, final Scriptable thisObj, final Object[] args) {

	Object obj = null;
	try {
		if (securityDomain == null) {
			obj = callable.call(ctx, scope, thisObj, args);
		} else {
			PrivilegedAction<Object> action = () -> callable.call(ctx, scope, thisObj, args);
			AccessControlContext acctx = new AccessControlContext(
					new ProtectionDomain[] { (ProtectionDomain) securityDomain });
			return AccessController.doPrivileged(action, acctx);
		}
	} catch (MissingResourceException err) {
		logger.error("Missing Resource");
	}
	return obj;
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:20,代码来源:SecurityControllerImpl.java

示例3: evaluate

import org.mozilla.javascript.Callable; //导入方法依赖的package包/类
public synchronized VMValue evaluate( String expression )
{
	int currentState = debugger.currentState( );

	if ( currentState == VM_TERMINATED )
	{
		return null;
	}

	JsValue result = null;
	Debugger oldDebugger = cx.getDebugger( );
	Object oldContextData = cx.getDebuggerContextData( );
	int oldLevel = cx.getOptimizationLevel( );

	cx.setDebugger( null, null );
	cx.setOptimizationLevel( -1 );
	cx.setGeneratingDebug( false );

	try
	{
		Callable script = (Callable) cx.compileString( expression,
				EVALUATOR_LITERAL,
				0,
				null );
		Object val = script.call( cx,
				scope,
				thisObj,
				ScriptRuntime.emptyArgs );

		if ( val == Undefined.instance )
		{
			result = new JsValue( UNDEFINED_LITERAL, UNDEFINED_TYPE );
		}
		else
		{
			result = new JsValue( val );
		}
	}
	catch ( Exception ex )
	{
		result = new JsValue( ex.getMessage( ), EXCEPTION_TYPE );
	}
	finally
	{
		cx.setGeneratingDebug( true );
		cx.setOptimizationLevel( oldLevel );
		cx.setDebugger( oldDebugger, oldContextData );
	}

	return result;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:52,代码来源:JsDebugFrame.java


注:本文中的org.mozilla.javascript.Callable.call方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。