org.jph.channels
Interface OutputChannel<M>

All Known Subinterfaces:
ActiveOutputChannel<M>, BufferedChannel<M>, Channel<M>, FilteringOutputChannel<M>, LoggingOutputChannel<M>, ProcessingOutputChannel<Min,Mout>, RegulatingOutputChannel<M>, RoutingOutputChannel<M>
All Known Implementing Classes:
ComposedChannel, DeadLetterOutputChannel, Log4jOutputChannel, MonitoringOutputChannel, SimpleLoggingOutputChannel, StdActiveOuputChannel, StdBufferedChannel, StdFilteringOutputChannel, StdProcessingOutputChannel, StdRegulatingOutputChannel, StdRoutingOutputChannel, SynchronousChannel

public interface OutputChannel<M>

The OutputChannel is the frontend of a Channel where messages can be put into. The OutputChannel can be compared to a java.io.OutputStream.

In JMS this is called the MessageProducer.

In Java NIO it is called the sink channel.

All OutputChannel implementations are threadsafe.

An outputChannel can also be seen as a event listener.

The OutputChannel is based on the: Puttable from the old concurrency library from Doug Lea. But it didn`t make it into JSE 5.0.

Author:
Peter Veentjer
See Also:
InputChannel

Method Summary
 boolean offer(M msg, long timeout, java.util.concurrent.TimeUnit unit)
          Place msg in channel only if it can be accepted within msecs milliseconds.
 void put(M msg)
          Place msg in the channel, possibly waiting indefinitely until it can be accepted.
 

Method Detail

put

void put(M msg)
         throws java.lang.InterruptedException
Place msg in the channel, possibly waiting indefinitely until it can be accepted.

Parameters:
msg - the element to be inserted. Should be non-null.
Throws:
java.lang.InterruptedException - if the current thread has been interrupted at a point at which interruption is detected, in which case the element is guaranteed not to be inserted. Otherwise, on normal return, the element is guaranteed to have been inserted.
java.lang.NullPointerException - if msg is null.

offer

boolean offer(M msg,
              long timeout,
              java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException
Place msg in channel only if it can be accepted within msecs milliseconds. The time bound is interpreted in a coarse-grained, best-effort fashion.

Parameters:
msg - the element to be inserted. Should be non-null.
timeout - how long to wait before giving up, in units of unit. If less than or equal to zero, the method does not perform any timed waits, but might still require access to a synchronization lock, which can impose unbounded delay if there is a lot of contention for the channel.
unit - the time unit of the timeout argument
Returns:
true if accepted, else false
Throws:
java.lang.InterruptedException - if the current thread has been interrupted at a point at which interruption is detected, in which case the element is guaranteed not to be inserted (i.e., is equivalent to a false return).
java.lang.NullPointerException - if message or unit is null.


Copyright © 2005 Anchormen. All Rights Reserved.