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


Java SimpleScriptContext.setAttribute方法代码示例

本文整理汇总了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 );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:29,代码来源:ScriptCustomizationPipelineImpl.java

示例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 );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:27,代码来源:ScriptSelectorImpl.java

示例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 ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:23,代码来源:SetExternalNameWizard.java


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