Commit 5e7b3384 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Small refactoring.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8691 b35dd754-fafc-0310-a699-88a17e54d16e
parent 4b70f72c
...@@ -16,9 +16,9 @@ import org.jivesoftware.util.LocaleUtils; ...@@ -16,9 +16,9 @@ import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.StringUtils; import org.jivesoftware.util.StringUtils;
import org.xmpp.forms.DataForm; import org.xmpp.forms.DataForm;
import org.xmpp.forms.FormField; import org.xmpp.forms.FormField;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import org.xmpp.packet.IQ;
import java.util.*; import java.util.*;
...@@ -110,7 +110,7 @@ public class LeafNode extends Node { ...@@ -110,7 +110,7 @@ public class LeafNode extends Node {
itemsByID.remove(removedItem.getID()); itemsByID.remove(removedItem.getID());
// Add the removed item to the queue of items to delete from the database. The // Add the removed item to the queue of items to delete from the database. The
// queue is going to be processed by another thread // queue is going to be processed by another thread
service.getPubSubEngine().queueItemToRemove(removedItem); service.queueItemToRemove(removedItem);
} }
} }
} }
...@@ -161,7 +161,7 @@ public class LeafNode extends Node { ...@@ -161,7 +161,7 @@ public class LeafNode extends Node {
itemsByID.remove(removedItem.getID()); itemsByID.remove(removedItem.getID());
// Add the removed item to the queue of items to delete from the database. The // Add the removed item to the queue of items to delete from the database. The
// queue is going to be processed by another thread // queue is going to be processed by another thread
service.getPubSubEngine().queueItemToRemove(removedItem); service.queueItemToRemove(removedItem);
} }
} }
} }
...@@ -257,12 +257,12 @@ public class LeafNode extends Node { ...@@ -257,12 +257,12 @@ public class LeafNode extends Node {
itemsByID.remove(removedItem.getID()); itemsByID.remove(removedItem.getID());
// Add the removed item to the queue of items to delete from the database. The // Add the removed item to the queue of items to delete from the database. The
// queue is going to be processed by another thread // queue is going to be processed by another thread
service.getPubSubEngine().queueItemToRemove(removedItem); service.queueItemToRemove(removedItem);
} }
addPublishedItem(newItem); addPublishedItem(newItem);
// Add the new published item to the queue of items to add to the database. The // Add the new published item to the queue of items to add to the database. The
// queue is going to be processed by another thread // queue is going to be processed by another thread
service.getPubSubEngine().queueItemToAdd(newItem); service.queueItemToAdd(newItem);
} }
} }
} }
...@@ -307,7 +307,7 @@ public class LeafNode extends Node { ...@@ -307,7 +307,7 @@ public class LeafNode extends Node {
} }
// Remove deleted items from the database // Remove deleted items from the database
for (PublishedItem item : toDelete) { for (PublishedItem item : toDelete) {
service.getPubSubEngine().queueItemToRemove(item); service.queueItemToRemove(item);
} }
if (isNotifiedOfRetract()) { if (isNotifiedOfRetract()) {
// Broadcast notification deletion to subscribers // Broadcast notification deletion to subscribers
...@@ -447,7 +447,7 @@ public class LeafNode extends Node { ...@@ -447,7 +447,7 @@ public class LeafNode extends Node {
if (toDelete != null) { if (toDelete != null) {
// Delete purged items from the database // Delete purged items from the database
for (PublishedItem item : toDelete) { for (PublishedItem item : toDelete) {
service.getPubSubEngine().queueItemToRemove(item); service.queueItemToRemove(item);
} }
// Broadcast purge notification to subscribers // Broadcast purge notification to subscribers
// Build packet to broadcast to subscribers // Build packet to broadcast to subscribers
......
...@@ -227,8 +227,12 @@ public class PubSubModule extends BasicModule implements ServerItemsProvider, Di ...@@ -227,8 +227,12 @@ public class PubSubModule extends BasicModule implements ServerItemsProvider, Di
engine.presenceSubscriptionRequired(node, user); engine.presenceSubscriptionRequired(node, user);
} }
public PubSubEngine getPubSubEngine() { public void queueItemToAdd(PublishedItem newItem) {
return engine; engine.queueItemToAdd(newItem);
}
public void queueItemToRemove(PublishedItem removedItem) {
engine.queueItemToRemove(removedItem);
} }
public String getServiceName() { public String getServiceName() {
......
...@@ -186,15 +186,6 @@ public interface PubSubService { ...@@ -186,15 +186,6 @@ public interface PubSubService {
*/ */
Collection<String> getShowPresences(JID subscriber); Collection<String> getShowPresences(JID subscriber);
/**
* Returns the pubsub engine responsible for handling packets sent to the pub-sub service.
* The engine is the actual place where the pubsub magic happens like creating nodes,
* publishing items or subscribing to nodes.
*
* @return the pubsub engine responsible for handling packets sent to the pub-sub service.
*/
PubSubEngine getPubSubEngine();
/** /**
* Requests the pubsub service to subscribe to the presence of the user. If the service * Requests the pubsub service to subscribe to the presence of the user. If the service
* has already subscribed to the user's presence then do nothing. * has already subscribed to the user's presence then do nothing.
...@@ -222,4 +213,20 @@ public interface PubSubService { ...@@ -222,4 +213,20 @@ public interface PubSubService {
* @return true if a user may have more than one subscription with the node. * @return true if a user may have more than one subscription with the node.
*/ */
boolean isMultipleSubscriptionsEnabled(); boolean isMultipleSubscriptionsEnabled();
/**
* Adds the item to the queue of items to add to the database. The queue is going
* to be processed by another thread.
*
* @param newItem the item to add to the database.
*/
void queueItemToAdd(PublishedItem newItem);
/**
* Adds the item to the queue of items to remove from the database. The queue is going
* to be processed by another thread.
*
* @param removedItem the item to remove from the database.
*/
void queueItemToRemove(PublishedItem removedItem);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment