KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.objectweb.dream.AbstractComponent;
28 import org.objectweb.dream.Pull;
29 import org.objectweb.dream.Push;
30 import org.objectweb.dream.message.manager.MessageManager;
31 import org.objectweb.fractal.api.NoSuchInterfaceException;
32 import org.objectweb.fractal.api.control.IllegalBindingException;
33 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
34
35 /**
36  * Implementation of the BackupElection component. This component is in charge
37  * of electing a new backup and propagating the information to all the
38  * processes.
39  */

40 public class BackupElectionImpl extends AbstractComponent
41     implements
42       BackupElection
43 {
44
45   // ---------------------------------------------------------------------------
46
// Fields of this class
47
// ---------------------------------------------------------------------------
48

49   /**
50    * The commonly used name to refer to the <code>pendingMessageOutItf</code>
51    * interface.
52    */

53   public static final String JavaDoc PENDING_MESSAGES_OUT_ITF_NAME = "pending-messages-out";
54
55   /**
56    * The interface to retrieve messages in the <code>PendingMessage</code>
57    * queue.
58    */

59   protected Pull pendingMessagesOutItf;
60
61   /** The interface to send BAK, REP, and UPD messages. */
62   protected Push outPushItf;
63
64   /** The interface to retrieve process membership information. */
65   protected ProcessMembership processMembershipItf;
66
67   /** The interface to get/set the sequence number. */
68   protected SequenceNumber sequenceNumberItf;
69
70   /** The interface to manage message lifecycle. */
71   protected MessageManager messageManagerItf;
72
73   // ---------------------------------------------------------------------------
74
// Constructor
75
// ---------------------------------------------------------------------------
76

77   /**
78    * Constructor.
79    */

80   public BackupElectionImpl()
81   {
82   }
83
84   // ---------------------------------------------------------------------------
85
// Implementation of the BackupElection interface
86
// ---------------------------------------------------------------------------
87

88   /**
89    * @see org.objectweb.dream.protocol.utobcast.BackupElection#elect()
90    */

91   public void elect()
92   {
93     // TODO Auto-generated method stub
94

95   }
96
97   // ---------------------------------------------------------------------------
98
// Implementation of the BindingController interface
99
// ---------------------------------------------------------------------------
100

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

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

135   public String JavaDoc[] listFc()
136   {
137     return new String JavaDoc[]{PENDING_MESSAGES_OUT_ITF_NAME, SequenceNumber.ITF_NAME,
138         Push.OUT_PUSH_ITF_NAME, ProcessMembership.ITF_NAME,
139         MessageManager.ITF_NAME};
140   }
141
142 }
Popular Tags