⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 beanshellregister.java

📁 一个很好实用的工作流OSWORKFLOW开发例子.有着非常优秀的灵活性.
💻 JAVA
字号:
/* * Copyright (c) 2002-2003 by OpenSymphony * All rights reserved. */package com.opensymphony.workflow.util.beanshell;import bsh.EvalError;import bsh.Interpreter;import bsh.TargetError;import com.opensymphony.module.propertyset.PropertySet;import com.opensymphony.workflow.*;import com.opensymphony.workflow.spi.WorkflowEntry;import java.util.Map;/** * A register that executes a beanshell script when invoked. * @author Hani */public class BeanShellRegister implements Register {    //~ Methods ////////////////////////////////////////////////////////////////    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args, PropertySet ps) throws WorkflowException {        String script = (String) args.get(AbstractWorkflow.BSH_SCRIPT);        Interpreter i = new Interpreter();        ClassLoader loader = Thread.currentThread().getContextClassLoader();        try {            if (loader != null) {                i.setClassLoader(loader);            }            i.set("entry", entry);            i.set("context", context);            i.set("propertySet", ps);            return i.eval(script);        } catch (TargetError targetError) {            if (targetError.getTarget() instanceof WorkflowException) {                throw (WorkflowException) targetError.getTarget();            } else {                String message = "Could not get object registered in to variable map";                throw new WorkflowException(message, targetError.getTarget());            }        } catch (EvalError e) {            String message = "Could not get object registered in to variable map";            throw new WorkflowException(message, e);        } finally {            if (loader != null) {                i.setClassLoader(null);            }        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -