本文整理汇总了Java中javax.script.SimpleScriptContext.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleScriptContext.setAttribute方法的具体用法?Java SimpleScriptContext.setAttribute怎么用?Java SimpleScriptContext.setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.script.SimpleScriptContext
的用法示例。
在下文中一共展示了SimpleScriptContext.setAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: customize
import javax.script.SimpleScriptContext; //导入方法依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public void customize ( final CustomizationRequest request )
{
// FIXME: we should somehow take this out of here
try
{
if ( this.executor == null )
{
final String resource = eResource ().getURI ().toString ();
this.executor = new ScriptExecutor ( getScriptEngine (), this.code, ScriptCustomizationPipelineImpl.class.getClassLoader (), resource );
}
final SimpleScriptContext ctx = new SimpleScriptContext ();
ctx.setAttribute ( "request", request, ScriptContext.ENGINE_SCOPE );
this.executor.execute ( ctx );
}
catch ( final Exception e )
{
throw new RuntimeException ( e );
}
}
示例2: selected
import javax.script.SimpleScriptContext; //导入方法依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public Boolean selected ( final CustomizationRequest request )
{
try
{
if ( this.executor == null )
{
this.executor = new ScriptExecutor ( getScriptEngine (), this.code, ScriptCustomizationPipelineImpl.class.getClassLoader () );
}
final SimpleScriptContext ctx = new SimpleScriptContext ();
ctx.setAttribute ( "request", request, ScriptContext.ENGINE_SCOPE );
return (Boolean)this.executor.execute ( ctx );
}
catch ( final Exception e )
{
throw new RuntimeException ( e );
}
}
示例3: evalName
import javax.script.SimpleScriptContext; //导入方法依赖的package包/类
public static String evalName ( final CompiledScript script, final ExternalValue v ) throws Exception
{
final SimpleScriptContext ctx = new SimpleScriptContext ();
ctx.setAttribute ( "item", v, ScriptContext.ENGINE_SCOPE ); //$NON-NLS-1$
final Object result = Scripts.executeWithClassLoader ( Activator.class.getClassLoader (), new Callable<Object> () {
@Override
public Object call () throws Exception
{
return script.eval ( ctx );
}
} );
if ( result == null )
{
return null;
}
return result.toString ();
}