KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > messaging > channel > plugins > handler > ExclusiveChannel


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.messaging.channel.plugins.handler;
8
9 import org.jboss.messaging.interfaces.Consumer;
10 import org.jboss.messaging.interfaces.MessageReference;
11
12 /**
13  * An exclusive channel has just one subscriber
14  *
15  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
16  * @version $Revision: 1.1 $
17  */

18 public class ExclusiveChannel extends AbstractChannel
19 {
20    // Constants -----------------------------------------------------
21

22    // Attributes ----------------------------------------------------
23

24    // Static --------------------------------------------------------
25

26    // Constructors --------------------------------------------------
27

28    /**
29     * Create a new ExclusiveChannel.
30     *
31     * @param consumer the consumer
32     * @param handler the handler
33     */

34    public ExclusiveChannel(Consumer consumer, ExclusiveChannelHandler handler)
35    {
36       super(consumer, handler);
37    }
38
39    // Public --------------------------------------------------------
40

41    // AbstractChannel overrides -------------------------------------
42

43    public void send(MessageReference message)
44    {
45       // We can drop the message if the consumer does not like it
46
if (consumer.accepts(message, false))
47          super.send(message);
48       else
49          message.release();
50    }
51    
52    // Protected -----------------------------------------------------
53

54    // Package Private -----------------------------------------------
55

56    // Private -------------------------------------------------------
57

58    // Inner Classes -------------------------------------------------
59
}
60
Popular Tags