jicarilla-sandbox/platform/framework/api/src/java/org/jicarilla/framework/plumbing Alternator.java,NONE,1.1

Leo Simons <[email protected]>
Newsgroups gmane.comp.java.jicarilla.cvs
Message-ID <[email protected]>
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/framework/api/src/java/org/jicarilla/framework/plumbing
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17849/platform/framework/api/src/java/org/jicarilla/framework/plumbing

Added Files:
	Alternator.java 
Log Message:
move o.j.f.Alternator to o.j.f.p.Alternator where it belongs

--- NEW FILE: Alternator.java ---
/* ====================================================================
 The Jicarilla Software License

 Copyright (c) 2003 Leo Simons.
 All rights reserved.

 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
 "Software"), to deal in the Software without restriction, including
 without limitation the rights to use, copy, modify, merge, publish,
 distribute, sublicense, and/or sell copies of the Software, and to
 permit persons to whom the Software is furnished to do so, subject to
 the following conditions:

 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.framework.plumbing;

import org.jicarilla.framework.plumbing.Multicaster;
import org.jicarilla.framework.plumbing.Sink;

/**
 * <p>Distribute messages across multiple sinks, choosing which sink to send
 * any particular message to randomly, but weighing in the relative sink
 * priority. Exactly how that weighing is done is implementation-dependent. In
 * diagram form:</p>
 * 
 * <pre>
 *                      +-------------+
 *                      |Alternator   |
 *          addSink()   |  +---------+|
 *              ------> |/-|Sink     ||
 *                      || +---------+|
 *                      || +---------+|
 *    put() / offer() --->-|Sink     ||
 *                      || +---------+|
 *                      || +---------+|
 *                      |\-|Sink     ||
 *                      |  +---------+|
 *                      +-------------+
 * </pre>
 * 
 * <p>Note that the <code>Alternator</code> is very similar to the {@link
 * Multicaster Multicaster}: where the multicaster sends a received message to
 * all connected sinks, the Alternator sends it to only one sink.</p>
 * 
 * <p>Also note that the <code>Alternator</code> is also very similar to the
 * {@link org.jicarilla.framework.plumbing.Screener screener}: where the alternator decides which connected sink
 * should receive the message randomly, the screener does so based on a
 * user-provided configuration.</p>
 * 
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: Alternator.java,v 1.1 2004/03/22 15:52:35 lsimons Exp $
 */
public interface Alternator extends Multicaster
{
    /** The minimum priority of any sink. */
    public final static int MIN_PRIORITY = 1;
    /** The maximum priority of any sink. */
    public final static int MAX_PRIORITY = 10;
    /** The priority assigned to any sink by default. */
    public final static int DEFAULT_PRIORITY = 5;

    /**
     * Add a sink which will be a recipient of some of the messages this
     * alternator receives (as determined by the 'randomness' algorithm of this
     * alternator).
     * 
     * @param sink the sink that will receive some of the messages
     */
    void addSink( Sink sink );

    /**
     * Add a sink (which will be a recipient of messages), with the
     * 'randomness' algorithm of this alternator influenced by the specified
     * priority.
     * 
     * @param sink
     * @param priority number specifying the relative priority of this sink.
     * Bigger number means higher priority. Minimum value of 1, maximum value
     * of 10.
     */
    void addSink( Sink sink, int priority );
}



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.