KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > protocol > utobcast > UPDImpl


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: dream@objectweb.org
20  *
21  * Initial developer(s): Vivien Quema
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.protocol.utobcast;
26
27 import java.util.Map JavaDoc;
28
29 import org.objectweb.dream.AbstractComponent;
30 import org.objectweb.dream.Push;
31 import org.objectweb.dream.PushException;
32 import org.objectweb.dream.message.Message;
33 import org.objectweb.dream.message.manager.MessageManager;
34 import org.objectweb.dream.protocol.utobcast.message.UPDChunk;
35 import org.objectweb.fractal.api.NoSuchInterfaceException;
36 import org.objectweb.fractal.api.control.IllegalBindingException;
37 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
38
39 /**
40  * Implementation of the UPD component. This component handles UPD messages.
41  * Upon message reception, it updates the <code>PendingMessages</code> queue,
42  * the <code>SequenceNumber</code> component, and the
43  * <code>ProcessMembership</code> component.
44  */

45 public class UPDImpl extends AbstractComponent implements Push
46 {
47
48   // ---------------------------------------------------------------------------
49
// Fields of this class
50
// ---------------------------------------------------------------------------
51

52   /**
53    * The commonly used name to refer to the <code>pendingMessageInItf</code>
54    * interface.
55    */

56   public static final String JavaDoc PENDING_MESSAGES_IN_ITF_NAME = "pending-messages-in";
57
58   /** The interface to store messages in the <code>PendingMessage</code> queue. */
59   protected Push pendingMessagesInItf;
60
61   /** The interface to retrieve process membership information. */
62   protected ProcessMembership processMembershipItf;
63
64   /** The interface to get/set the sequence number. */
65   protected SequenceNumber sequenceNumberItf;
66
67   /** The interface to manage message lifecycle. */
68   protected MessageManager messageManagerItf;
69
70   // ---------------------------------------------------------------------------
71
// Constructor
72
// ---------------------------------------------------------------------------
73

74   /**
75    * Constructor.
76    */

77   public UPDImpl()
78   {
79   }
80
81   // ---------------------------------------------------------------------------
82
// Implementation of the Push interface
83
// ---------------------------------------------------------------------------
84

85   /**
86    * @see org.objectweb.dream.Push#push(org.objectweb.dream.message.Message,
87    * java.util.Map)
88    */

89   public void push(Message message, Map JavaDoc context) throws PushException
90   {
91     UPDChunk chunk = (UPDChunk) message.getChunk(UPDChunk.DEFAULT_NAME);
92     processMembershipItf.setOtherProcesses(chunk.getProcesses());
93     sequenceNumberItf.setSequenceNumber(chunk.getSequenceNumber());
94   }
95
96   // ---------------------------------------------------------------------------
97
// Implementation of the BindingController interface
98
// ---------------------------------------------------------------------------
99

100   /**
101    * @see org.objectweb.fractal.api.control.BindingController#bindFc(java.lang.String,
102    * java.lang.Object)
103    */

104   public void bindFc(String JavaDoc clientItfName, Object JavaDoc serverItf)
105       throws NoSuchInterfaceException, IllegalBindingException,
106       IllegalLifeCycleException
107   {
108     super.bindFc(clientItfName, serverItf);
109     if (clientItfName.equals(PENDING_MESSAGES_IN_ITF_NAME))
110     {
111       pendingMessagesInItf = (Push) serverItf;
112     }
113     else if (clientItfName.equals(SequenceNumber.ITF_NAME))
114     {
115       sequenceNumberItf = (SequenceNumber) serverItf;
116     }
117     else if (clientItfName.equals(ProcessMembership.ITF_NAME))
118     {
119       processMembershipItf = (ProcessMembership) serverItf;
120     }
121     else if (clientItfName.equals(MessageManager.ITF_NAME))
122     {
123       messageManagerItf = (MessageManager) serverItf;
124     }
125
126   }
127
128   /**
129    * @see org.objectweb.fractal.api.control.BindingController#listFc()
130    */

131   public String JavaDoc[] listFc()
132   {
133     return new String JavaDoc[]{PENDING_MESSAGES_IN_ITF_NAME, SequenceNumber.ITF_NAME,
134         ProcessMembership.ITF_NAME, MessageManager.ITF_NAME};
135   }
136
137 }
Popular Tags