jicarilla-sandbox/platform/plumbing/api/src/java/org/jicarilla/plumbing Alternator.java,NONE,1.1 Collector.java,NONE,1.1 Multicaster.java,NONE,1.1 Screener.java,NONE,1.1 Sink.java,NONE,1.1 Source.java,NONE,1.1 Stage.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/plumbing/api/src/java/org/jicarilla/plumbing
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30323/plumbing/api/src/java/org/jicarilla/plumbing

Added Files:
	Alternator.java Collector.java Multicaster.java Screener.java 
	Sink.java Source.java Stage.java 
Log Message:
s/o.j.f.p/o.j.p/

--- NEW FILE: Screener.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.plumbing;

import org.jicarilla.framework.Selector;

/**
 * <p>Redirects received messages to other sinks based on a selection algoritm
 * that is determined by the set of selectors provided for each of the
 * targettable sinks. In diagram form:</p>
 * 
 * <pre>
 *                      +------------------------+
 *                      |Screener                |
 *          addSink()   |  +---------++---------+|
 *              ------> |/-|Selector ||Sink     ||
 *                      || +---------++---------+|
 *                      || +---------++---------+|
 *    put() / offer() --->-|Selector ||Sink     ||
 *                      || +---------++---------+|
 *                      || +---------++---------+|
 *                      |\-|Selector ||Sink     ||
 *                      |  +---------++---------+|
 *                      +------------------------+
 * </pre>
 * 
 * <p>In other words, the <code>Screener</code> is a generic multiway
 * redirector.</p>
 * 
 * <p>Care should be taken to make sure that the Selectors used can work with
 * the messages that will be fed through the screener (of course).</p>
 * 
 * <p>Note that the <code>Screener</code> is very similar to the {@link
 * Multicaster Multicaster}: where the multicaster sends a received message to
 * all connected sinks, the Screener sends it to only one sink.</p>
 * 
 * <p>Also note that the <code>Alternator</code> is also very similar to the
 * {@link 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: Screener.java,v 1.1 2004/03/22 21:20:13 lsimons Exp $
 */
public interface Screener extends Sink
{
    /**
     * <p>Add a sink that will receive messages from this screener. A sink may
     * receive messages sent to this screener if and only if the provided
     * selector returns true upon calling its select() method with the message
     * being the argument, but it is not guaranteed that it will always receive
     * those messages.</p>
     * 
     * <p>The policy used for determining to what selector/sink pair an
     * particular message will be sent is implementation-dependent.</p>
     * 
     * @param selector the selector that governs what messages the sink will
     * receive
     * @param sink the sink that will receive messages
     */
    void addSink( Selector selector, Sink sink );
}

--- NEW FILE: Sink.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.plumbing;

import EDU.oswego.cs.dl.util.concurrent.Puttable;

/**
 * <p>Models an entity which is capable of receiving messages. The sink is one
 * of two "fundamental units" of event pipeline plumbing. A sink is that to
 * which we send messages (as opposed to that which generates messages, a
 * source).</p>
 * 
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: Sink.java,v 1.1 2004/03/22 21:20:13 lsimons Exp $
 */
public interface Sink extends Puttable
{
}

--- NEW FILE: Collector.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.plumbing;

/**
 * <p>Combines multiple sources into a single one. A collector is used in the
 * event pipeline pumbling to combine multiple sources and form a single new
 * one. Each <code>get()</code> performed on the Collector will retrieve an
 * element from one of the sources the Collector contains. From wich source an
 * element will be retrieved is implementation-specific, though the
 * implementation should strive to make sure that no starvation occurs. In
 * diagram form:</p>
 * 
 * <pre>
 *             +---------------+
 *             |Collector      |
 * addSource() |+---------+    |
 *     ------> ||Source   |-\  |
 *             |+---------+ |  |
 *             |+---------+ |  |
 *             ||Source   |->--|--> get() / poll()
 *             |+---------+ |  |
 *             |+---------+ |  |
 *             ||Source   |-/  |
 *             |+---------+    |
 *             +---------------+
 * </pre>
 * 
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: Collector.java,v 1.1 2004/03/22 21:20:13 lsimons Exp $
 */
public interface Collector extends Source
{
    /**
     * Connect a Source to this collector. It is okay to connect the same
     * source multiple times.
     * 
     * @param source the source to connect.
     */
    void addSource( Source source );
}

--- NEW FILE: Source.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.plumbing;

import EDU.oswego.cs.dl.util.concurrent.Takable;

/**
 * Models an entity which is capable of generating messages. The sink is one of
 * two "fundamental units" of event pipeline plumbing. A source is that which
 * generates messages (as opposed to that to which we send messages, a
 * sink).</p>
 * 
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: Source.java,v 1.1 2004/03/22 21:20:13 lsimons Exp $
 */
public interface Source extends Takable
{
}

--- NEW FILE: Stage.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.plumbing;

import EDU.oswego.cs.dl.util.concurrent.Channel;
import org.jicarilla.plumbing.Sink;
import org.jicarilla.plumbing.Source;

/**
 * Models an entity which is capable of both sending and receiving messages. In
 * other words, a stage is the union of a sink and a source.
 * 
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: Stage.java,v 1.1 2004/03/22 21:20:13 lsimons Exp $
 */
public interface Stage extends Source, Sink, Channel
{
}

--- NEW FILE: Multicaster.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.plumbing;

/**
 * <p>Broadcasts a message to multiple sinks. All messages sent to the
 * Multicaster will be sent to all the sinks it is linked to. In diagram
 * form:</p>
 * 
 * <pre>
 *                      +-------------+
 *                      |Multicaster  |
 *          addSink()   |  +---------+|
 *              ------> |/-|Sink     ||
 *                      || +---------+|
 *                      || +---------+|
 *    put() / offer() --->-|Sink     ||
 *                      || +---------+|
 *                      || +---------+|
 *                      |\-|Sink     ||
 *                      |  +---------+|
 *                      +-------------+
 * </pre>
 * 
 * <p>Note that the <code>Multicaster</code> is very similar to the {@link
 * Alternator Alternator}: 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>Multicaster</code> is also similar to the {@link
 * Screener screener}: where the multicaster sends a received message to all
 * connected sinks, the screener does so based on a user-provided
 * configuration.</p>
 * 
 * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
 * @version $Id: Multicaster.java,v 1.1 2004/03/22 21:20:13 lsimons Exp $
 */
public interface Multicaster extends Sink
{
    /**
     * Add a sink which will be a recipient of all the messages this
     * Multicaster receives.
     * 
     * @param sink the sink that will receive messages
     */
    void addSink( Sink sink );
}

--- 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.plumbing;

import org.jicarilla.plumbing.Multicaster;
import org.jicarilla.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.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 21:20:13 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.