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

📄 webworkexecutor.java

📁 一个很好实用的工作流OSWORKFLOW开发例子.有着非常优秀的灵活性.
💻 JAVA
字号:
/* * Copyright (c) 2002-2003 by OpenSymphony * All rights reserved. */package com.opensymphony.workflow.util;import com.opensymphony.module.propertyset.PropertySet;import com.opensymphony.workflow.*;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import webwork.action.ActionContext;import webwork.dispatcher.GenericDispatcher;import java.security.Principal;import java.util.*;/** * Executes a WebWork function and restores the old ActionContext when finished * (but does not provide chaining support yet). The following conversion is done: * <ul> *  <li>inputs -> ActionContext#parameters</li> *  <li>variables -> ActionContext#session</li> *  <li>args -> ActionContext#application</li> * </ul> * <p> * * <ul> *  <li><b>action.name</b> - the actionName to ask from the ActionFactory</li> * </ul> */public class WebWorkExecutor implements FunctionProvider {    //~ Static fields/initializers /////////////////////////////////////////////    private static final Log log = LogFactory.getLog(WebWorkExecutor.class);    //~ Methods ////////////////////////////////////////////////////////////////    public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException {        final WorkflowContext wfContext = (WorkflowContext) transientVars.get("context");        String actionName = (String) args.get("action.name");        GenericDispatcher gd = new GenericDispatcher(actionName);        gd.prepareContext();        ActionContext.setPrincipal(new Principal() {                public String getName() {                    return wfContext.getCaller();                }            });        ActionContext.setApplication(args);        ActionContext.setSession(ps.getProperties(""));        ActionContext.setLocale(Locale.getDefault());        Map params = new HashMap(transientVars);        params.putAll(args);        ActionContext.setParameters(Collections.unmodifiableMap(params));        try {            gd.executeAction();            gd.finish();            gd.finalizeContext();        } catch (Exception e) {            throw new WorkflowException("Could not execute action " + actionName, e);        }    }}

⌨️ 快捷键说明

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