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

📄 workitemlistener.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: WorkItemListener.java,v 1.7 2005/05/17 16:40:45 jmettraux Exp $ *///// WorkItemListener.java//// jmettraux@openwfe.org//// generated with // jtmpl 1.0.04 20.11.2001 John Mettraux (jmettraux@openwfe.org)//package openwfe.org.engine.listen;import java.nio.ByteBuffer;import java.nio.CharBuffer;import openwfe.org.AbstractService;import openwfe.org.ApplicationContext;import openwfe.org.ServiceException;import openwfe.org.engine.Definitions;import openwfe.org.engine.workitem.WorkItemCoder;import openwfe.org.engine.workitem.WorkItemCoderLoader;/** * Fully implement this class to reply to expressions or launch workflows * * <p><font size=2>CVS Info : * <br>$Author: jmettraux $ * <br>$Date: 2005/05/17 16:40:45 $ * <br>$Id: WorkItemListener.java,v 1.7 2005/05/17 16:40:45 jmettraux Exp $ </font> * * @author jmettraux@openwfe.org */public abstract class WorkItemListener    extends AbstractService{    private final static org.apache.log4j.Logger log = org.apache.log4j.Logger        .getLogger(WorkItemListener.class.getName());    //    // CONSTANTS (definitions)    /**     * The parameter 'workItemConsumer' is used to tell the listener     * to which workitem consumer it should send the incoming workitems.     */    public final static String P_CONSUMER        = "workItemConsumer";    //    // FIELDS    private String consumerName = null;    //    // CONSTRUCTORS    public void init         (final String serviceName,          final ApplicationContext context,          final java.util.Map serviceParams)    throws         ServiceException    {        super.init(serviceName, context, serviceParams);        this.consumerName = (String)serviceParams.get(P_CONSUMER);        log.info            ("Listener '"+getName()+             "' uses Consumer '"+consumerName+"'");    }    //    // METHODS    /**     * Returns the workitem consumer attached to this listener      * (as determined in the configuration file)     */    protected WorkItemConsumer getConsumer ()    {        return (WorkItemConsumer)getContext().lookup(this.consumerName);    }    /**     * Given a workitem coder short name, returns an instance of the     * workitem code.     */    protected WorkItemCoder getCoder (final String coderName)    {        final WorkItemCoderLoader coderLoader = Definitions            .getWorkItemCoderLoader(getContext());        //if (coderName == null) return coderLoader.getDefaultCoder();        final WorkItemCoder result = coderLoader.getCoder(coderName);        if (result == null)        {            log.debug                ("getCoder() did not find coder named '"+coderName+                 "' returning default coder");                        return coderLoader.getDefaultCoder();        }        return result;    }    /**     * Extracts a workitem coder name from the incoming input stream.     */    protected String extractCoderName (final java.io.InputStream is)        throws java.io.IOException    {        final StringBuffer sb = new StringBuffer();        while (true)        {            final char c = (char)is.read();            if (c == '\n') break;            sb.append(c);        }        final String result = sb.toString().trim();        log.debug("extractCoderName(is) coderName is >"+result+"<");        return result;    }    /**     * Given the incoming inputstream, determines the workitem coder     * instance that should decode the wrapped workitem.     */    protected WorkItemCoder getCoder (final java.io.InputStream is)        throws java.io.IOException    {        return getCoder(extractCoderName(is));    }    /*    protected String extractCoderName         (final java.nio.channels.ReadableByteChannel channel)    throws         java.io.IOException    {        final StringBuffer sb = new StringBuffer();        final ByteBuffer buf = ByteBuffer.allocate(1);        while (true)        {            buf.clear();            final int read = channel.read(buf);            if (read < 0) break;            if (read == 0) continue;            buf.flip();            final char c = (char)buf.get();            log.debug("extractCoderName(c) c is >"+c+"< ("+((byte)c)+")");            if (c == (char)0) continue;            if (c == '\n') break;            sb.append(c);        }        final String result = sb.toString();        log.debug("extractCoderName(c) coderName is >"+result+"<");        return result;    }    protected WorkItemCoder getCoder         (final java.nio.channels.ReadableByteChannel channel)    throws         java.io.IOException    {        return getCoder(extractCoderName(channel));    }    */}

⌨️ 快捷键说明

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