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.dom4j.Element;
13: import org.dom4j.tree.DefaultElement;
14: import org.jivesoftware.openfire.muc.spi.LocalMUCRoom;
15: import org.jivesoftware.util.cache.ExternalizableUtil;
16: import org.xmpp.packet.Message;
17:
18: import java.io.IOException;
19: import java.io.ObjectInput;
20: import java.io.ObjectOutput;
21:
22: /**
23: * Task that broadcasts a message to local room occupants. When a room occupant sends a
24: * message to the room each cluster node will execute this task and broadcast the message
25: * to its local room occupants.
26: *
27: * @author Gaston Dombiak
28: */
29: public class BroascastMessageRequest extends MUCRoomTask {
30: private int occupants;
31: private Message message;
32:
33: public BroascastMessageRequest() {
34: }
35:
36: public BroascastMessageRequest(LocalMUCRoom room, Message message,
37: int occupants) {
38: super (room);
39: this .message = message;
40: this .occupants = occupants;
41: }
42:
43: public Message getMessage() {
44: return message;
45: }
46:
47: public int getOccupants() {
48: return occupants;
49: }
50:
51: public Object getResult() {
52: return null;
53: }
54:
55: public void run() {
56: getRoom().broadcast(this );
57: }
58:
59: public void writeExternal(ObjectOutput out) throws IOException {
60: super .writeExternal(out);
61: ExternalizableUtil.getInstance().writeSerializable(out,
62: (DefaultElement) message.getElement());
63: }
64:
65: public void readExternal(ObjectInput in) throws IOException,
66: ClassNotFoundException {
67: super .readExternal(in);
68: Element packetElement = (Element) ExternalizableUtil
69: .getInstance().readSerializable(in);
70: message = new Message(packetElement, true);
71: }
72: }
|