01: /**
02: * $RCSfile$
03: * $Revision: $
04: * $Date: $
05: *
06: * Copyright (C) 2007 Jive Software. All rights reserved.
07: *
08: * This software is published under the terms of the GNU Public License (GPL),
09: * a copy of which is included in this distribution.
10: */package org.jivesoftware.openfire.muc.cluster;
11:
12: import org.jivesoftware.openfire.XMPPServer;
13: import org.jivesoftware.openfire.muc.MUCRoom;
14: import org.jivesoftware.openfire.muc.MultiUserChatServer;
15: import org.jivesoftware.openfire.muc.spi.LocalMUCRoom;
16: import org.jivesoftware.util.cache.ClusterTask;
17:
18: import java.io.IOException;
19: import java.io.ObjectInput;
20: import java.io.ObjectOutput;
21: import java.util.ArrayList;
22: import java.util.List;
23:
24: /**
25: * Task to be requested by a node that joins a cluster and be executed in the senior cluster member to get
26: * the rooms with occupants. The list of rooms with occupants is returned to the new cluster node so that
27: * the new cluster node can be updated and have the same information shared by the cluster.<p>
28: *
29: * Moreover, each existing cluster node will also need to learn the rooms with occupants that exist in
30: * the new cluster node and replicate them. This work is accomplished using {@link GetNewMemberRoomsRequest}.
31: *
32: * @author Gaston Dombiak
33: */
34: public class SeniorMemberRoomsRequest implements ClusterTask {
35: private List<RoomInfo> rooms;
36:
37: public SeniorMemberRoomsRequest() {
38: }
39:
40: public Object getResult() {
41: return rooms;
42: }
43:
44: public void run() {
45: rooms = new ArrayList<RoomInfo>();
46: // Get rooms that have occupants and include them in the reply
47: MultiUserChatServer mucServer = XMPPServer.getInstance()
48: .getMultiUserChatServer();
49: for (MUCRoom room : mucServer.getChatRooms()) {
50: LocalMUCRoom localRoom = (LocalMUCRoom) room;
51: if (!room.getOccupants().isEmpty()) {
52: rooms.add(new RoomInfo(localRoom, localRoom
53: .getOccupants()));
54: }
55: }
56: }
57:
58: public void writeExternal(ObjectOutput out) throws IOException {
59: // Do nothing
60: }
61:
62: public void readExternal(ObjectInput in) throws IOException,
63: ClassNotFoundException {
64: // Do nothing
65: }
66: }
|