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

📄 wsinvoker.java

📁 一个工作流设计及定义的系统,可以直接与数据库结合进行系统工作流程的定义及应用.
💻 JAVA
字号:
/* * Copyright (c) 2005, John Mettraux, OpenWFE.org * All rights reserved. *  * Redistribution and use in source and binary forms, with or without  * modification, are permitted provided that the following conditions are met: *  * . Redistributions of source code must retain the above copyright notice, this *   list of conditions and the following disclaimer.   *  * . Redistributions in binary form must reproduce the above copyright notice,  *   this list of conditions and the following disclaimer in the documentation  *   and/or other materials provided with the distribution. *  * . Neither the name of the "OpenWFE" nor the names of its contributors may be *   used to endorse or promote products derived from this software without *   specific prior written permission. *  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  * POSSIBILITY OF SUCH DAMAGE. * * $Id: WsInvoker.java,v 1.2 2005/05/17 16:41:06 jmettraux Exp $ *///// WsInvoker.java//// john.mettraux@openwfe.org//// generated with // jtmpl 1.1.01 2004/05/19 (john.mettraux@openwfe.org)//package openwfe.org.ws;import javax.xml.namespace.QName;import org.apache.axis.client.Call;import org.apache.axis.client.Service;import openwfe.org.MapUtils;import openwfe.org.ServiceException;import openwfe.org.ApplicationContext;//import openwfe.org.engine.listen.reply.OkReply;//import openwfe.org.engine.listen.reply.FatalReply;import openwfe.org.engine.expool.ExpressionPool;import openwfe.org.engine.workitem.WorkItem;import openwfe.org.engine.workitem.InFlowWorkItem;import openwfe.org.engine.dispatch.WorkItemDispatcher;import openwfe.org.engine.dispatch.DispatchingException;/** * A workitem dispatcher that invokes web services (and then replies * immediately). * * <p><font size=2>CVS Info : * <br>$Author: jmettraux $ * <br>$Id: WsInvoker.java,v 1.2 2005/05/17 16:41:06 jmettraux Exp $ </font> * * @author john.mettraux@openwfe.org */public class WsInvoker    implements WorkItemDispatcher{    private final static org.apache.log4j.Logger log = org.apache.log4j.Logger        .getLogger(WsInvoker.class.getName());    //    // CONSTANTS & co    /**     * The param 'endPoint' is a mandatory parameter.     */    public final static String P_END_POINT         = "endPoint";    /**     * The param 'operationName' is a mandatory parameter.     */    public final static String P_OP_NAME         = "operationName";    /**     * This param named 'interop' is used to set the prefix for     * the operation name.     * (It has a default value).     */    public final static String P_INTEROP         = "interop";    /**     * The default value for "interop" is "http://soapinterop.org/".     */    public final static String DEFAULT_INTEROP        = "http://soapinterop.org/";    /**     * This param named 'wsParamMapper' is optional, it could be used     * to make the dispatcher (invoker) point to another wsParamMapper.     */    public final static String P_PARAM_MAPPER        = "wsParamMapper";    /**     * By default, the param mapper used is a service named 'wsParamMapper'.     */    public final static String DEFAULT_PARAM_MAPPER        = "wsParamMapper";    //    // FIELDS    private ApplicationContext context = null;    private String endPoint = null;    private String operationName = null;    private String interop = null;    private String paramMapperName = null;    //    // CONSTRUCTORS    public void init         (final String name,          final ApplicationContext context,          final java.util.Map params)    throws         ServiceException    {        this.context = context;        this.endPoint = MapUtils            .getMandatoryString(params, P_END_POINT);        log.debug("init() endPoint set to '"+this.endPoint+"'");        this.operationName = MapUtils            .getMandatoryString(params, P_OP_NAME);        log.debug("init() operationName set to '"+this.operationName+"'");        this.interop = MapUtils            .getAsString(params, P_INTEROP, DEFAULT_INTEROP);        this.paramMapperName = MapUtils            .getAsString(params, P_PARAM_MAPPER, DEFAULT_PARAM_MAPPER);    }    //    // METHODS from WorkItemDispatcher    public Object dispatch (final WorkItem wi)         throws DispatchingException    {        final InFlowWorkItem ifwi = (InFlowWorkItem)wi;        //        // invoke        final WsParamMapper mapper =             (WsParamMapper)this.context.lookup(this.paramMapperName);                try        {            final Service service = new Service();            final Call call = (Call)service.createCall();            call.setTargetEndpointAddress(new java.net.URL(this.endPoint));            //call.setOperationName(new QName(this.interop, this.operationName));            call.setOperationName(new QName(this.operationName));            final Object[] params = mapper.prepareParams(call, ifwi);            final String toField = mapper.determineToField(ifwi);            //            // invoke            final Object ret = call.invoke(params);            //            // integrate return value            ifwi.getAttributes().puts(toField, ""+ret);        }        catch (final Throwable t)        {            log.debug                ("dispatch() WS invocation problem", t);            throw new DispatchingException                ("WS invocation problem", t);            //return new FatalReply            //    ("WS invocation failed", t);        }        //        // reply (in own thread to let main thread reply immediately)                (new Thread ()         {             public void run ()             {                 //this.yield();                     // making sure the parent thread resumes a bit                    // before this thread gets into full play                 final ExpressionPool pool = openwfe.org.engine.Definitions                     .getExpressionPool(WsInvoker.this.context);                 try                 {                     pool.reply(ifwi.getLastExpressionId(), ifwi);                 }                 catch (final Throwable t)                 {                     log.warn                         ("dispatch() reply failure after WS invocation", t);                 }             }         }).start();        //        // return something                //return new OkReply("");        return null;    }    //    // METHODS    //    // STATIC METHODS}

⌨️ 快捷键说明

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