org.apache.excalibur.event.impl
Class MultiCastSink

java.lang.Object
  extended by org.apache.excalibur.event.impl.MultiCastSink
All Implemented Interfaces:
org.apache.excalibur.event.Sink

public class MultiCastSink
extends java.lang.Object
implements org.apache.excalibur.event.Sink

This is a org.apache.excalibur.event.seda.event.Sink implementation that multicasts enqueue operations to the contained and concrete sink objects. The multi cast sink will try to enqueue and only succeeds if no element was rejected from any sink. The sink can be configured to enqueue into one sink alone or all sinks. If a sink array in the collection of sinks contains more than one sink the multicast sink will try to enqueue the element always to only one of these sinks.

Version:
$Revision: 1.4 $
Author:
Avalon Development Team

Nested Class Summary
private static class MultiCastSink.DefaultPreparedEnqueue
          A prepared enqueue object that holds other prepared enqueue objects and allows to perform a commit / abort on all of these objects.
 
Field Summary
private  boolean m_single
          Boolean value describing if one or all operations must succeed.
private  java.util.Collection m_sinks
          A collection of sink arrays representing the sinks to enqueue to.
private  int m_size
          The size of the sink.
 
Fields inherited from interface org.apache.excalibur.event.Sink
ROLE
 
Constructor Summary
MultiCastSink(java.util.Collection sinks)
          This constructor creates a failure in-tolerant multicast sink based on the collection of sink arrays.
MultiCastSink(java.util.Collection sinks, boolean single)
          This constructor creates a failure in-tolerant multicast sink based on the collection of sink arrays.
 
Method Summary
 int canAccept()
           
 void enqueue(java.lang.Object element)
           
 void enqueue(java.lang.Object[] elements)
           
 boolean isFull()
           
 int maxSize()
           
 org.apache.excalibur.event.PreparedEnqueue prepareEnqueue(java.lang.Object[] elements)
           
 int size()
           
 boolean tryEnqueue(java.lang.Object element)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_sinks

private final java.util.Collection m_sinks
A collection of sink arrays representing the sinks to enqueue to.


m_size

private final int m_size
The size of the sink.


m_single

private final boolean m_single
Boolean value describing if one or all operations must succeed.

Constructor Detail

MultiCastSink

public MultiCastSink(java.util.Collection sinks)
This constructor creates a failure in-tolerant multicast sink based on the collection of sink arrays. The delivery must succeed for all sinks in the collection or it will fail entirely.

Parameters:
sinks - A collection of sink arrays for each stage.
Since:
May 16, 2002

MultiCastSink

public MultiCastSink(java.util.Collection sinks,
                     boolean single)
This constructor creates a failure in-tolerant multicast sink based on the collection of sink arrays.

Parameters:
sinks - A collection of sink arrays for each stage.
single - true if just one operation must succeed. false if all operations must succeed.
Since:
May 16, 2002
Method Detail

canAccept

public int canAccept()
Specified by:
canAccept in interface org.apache.excalibur.event.Sink
See Also:
Sink.canAccept()

isFull

public boolean isFull()
Specified by:
isFull in interface org.apache.excalibur.event.Sink
See Also:
Sink.isFull()

maxSize

public int maxSize()
Specified by:
maxSize in interface org.apache.excalibur.event.Sink
See Also:
Sink.maxSize()

enqueue

public void enqueue(java.lang.Object element)
             throws org.apache.excalibur.event.SinkException
Specified by:
enqueue in interface org.apache.excalibur.event.Sink
Throws:
org.apache.excalibur.event.SinkException
See Also:
Sink.enqueue(Object)

enqueue

public void enqueue(java.lang.Object[] elements)
             throws org.apache.excalibur.event.SinkException
Specified by:
enqueue in interface org.apache.excalibur.event.Sink
Throws:
org.apache.excalibur.event.SinkException
See Also:
Sink.enqueue(Object[])

tryEnqueue

public boolean tryEnqueue(java.lang.Object element)
Specified by:
tryEnqueue in interface org.apache.excalibur.event.Sink
See Also:
Sink.tryEnqueue(Object)

prepareEnqueue

public org.apache.excalibur.event.PreparedEnqueue prepareEnqueue(java.lang.Object[] elements)
                                                          throws org.apache.excalibur.event.SinkException
Specified by:
prepareEnqueue in interface org.apache.excalibur.event.Sink
Throws:
org.apache.excalibur.event.SinkException
See Also:
Sink.prepareEnqueue(Object[])

size

public int size()
Specified by:
size in interface org.apache.excalibur.event.Sink
See Also:
Sink.size()