KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > mom > dest > ClusterQueue


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2004 - 2007 ScalAgent Distributed Technologies
4  * Copyright (C) 2004 France Telecom R&D
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA.
20  *
21  * Initial developer(s): ScalAgent Distributed Technologies
22  * Contributor(s):
23  */

24 package org.objectweb.joram.mom.dest;
25
26 import java.util.Properties JavaDoc;
27
28 import org.objectweb.joram.mom.notifications.AckJoinQueueCluster;
29 import org.objectweb.joram.mom.notifications.JoinQueueCluster;
30 import org.objectweb.joram.mom.notifications.LBCycleLife;
31 import org.objectweb.joram.mom.notifications.LBMessageGive;
32 import org.objectweb.joram.mom.notifications.LBMessageHope;
33 import org.objectweb.joram.mom.notifications.LeaveQueueCluster;
34 import org.objectweb.joram.mom.notifications.ReceiveRequest;
35 import org.objectweb.joram.mom.notifications.SetRightQueueCluster;
36 import org.objectweb.joram.mom.notifications.WakeUpNot;
37 import org.objectweb.joram.shared.JoramTracing;
38 import org.objectweb.util.monolog.api.BasicLevel;
39
40 import fr.dyade.aaa.agent.AgentId;
41 import fr.dyade.aaa.agent.Notification;
42
43 /**
44  * A <code>ClusterQueue</code> agent is an agent hosting a MOM queue, and which
45  * behaviour is provided by a <code>ClusterQueueImpl</code> instance.
46  *
47  * @see ClusterQueueImpl
48  */

49 public class ClusterQueue extends Queue {
50   /**
51    * Empty constructor for newInstance().
52    */

53   protected ClusterQueue() {}
54
55   /**
56    * Creates the <tt>QueueImpl</tt>.
57    *
58    * @param adminId Identifier of the queue administrator.
59    * @param prop The initial set of properties.
60    */

61   public DestinationImpl createsImpl(AgentId adminId, Properties JavaDoc prop) {
62     ClusterQueueImpl queueImpl = new ClusterQueueImpl(getId(), adminId, prop);
63     return queueImpl;
64   }
65   
66   /**
67    * Distributes the received notifications to the appropriate reactions.
68    * @throws Exception
69    */

70   public void react(AgentId from, Notification not)
71     throws Exception JavaDoc {
72
73     if (JoramTracing.dbgDestination.isLoggable(BasicLevel.DEBUG))
74       JoramTracing.dbgDestination.log(BasicLevel.DEBUG, "--- " + this +
75                                     " react(" + from + "," + not + ")");
76
77     if (not instanceof AckJoinQueueCluster)
78       ((ClusterQueueImpl) destImpl).ackJoinQueueCluster((AckJoinQueueCluster) not);
79     else if (not instanceof JoinQueueCluster)
80       ((ClusterQueueImpl) destImpl).joinQueueCluster((JoinQueueCluster) not);
81     else if (not instanceof LeaveQueueCluster)
82       ((ClusterQueueImpl) destImpl).removeQueueCluster(((LeaveQueueCluster) not).removeQueue);
83     else if (not instanceof ReceiveRequest) {
84       super.react(from, not);
85       ((ClusterQueueImpl) destImpl).receiveRequest((ReceiveRequest) not);
86     } else if (not instanceof LBMessageGive)
87       ((ClusterQueueImpl) destImpl).lBMessageGive(from, (LBMessageGive) not);
88     else if (not instanceof LBMessageHope)
89       ((ClusterQueueImpl) destImpl).lBMessageHope(from, (LBMessageHope) not);
90     else if (not instanceof LBCycleLife)
91       ((ClusterQueueImpl) destImpl).lBCycleLife(from, (LBCycleLife) not);
92     else if (not instanceof WakeUpNot) {
93       super.react(from, not);
94       ((ClusterQueueImpl) destImpl).wakeUpNot((WakeUpNot) not);
95     } else if (not instanceof SetRightQueueCluster)
96       ((ClusterQueueImpl) destImpl).setRightQueueCluster((SetRightQueueCluster) not);
97     else
98       super.react(from, not);
99   }
100 }
101
Popular Tags