1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

s/processPacket/processStanza/ s/PacketCollector/StanzaCollector/

This commit is contained in:
Florian Schmaus 2017-01-03 11:12:34 +01:00
parent 9328182912
commit 90a5e289f8
100 changed files with 406 additions and 406 deletions

View file

@ -34,15 +34,15 @@ public class FloodTest extends SmackTestCase {
public void testMessageFlood() {
try {
Chat chat11 = getConnection(0).getChatManager().createChat(getBareJID(1), null);
PacketCollector chat12 = getConnection(1).createPacketCollector(
StanzaCollector chat12 = getConnection(1).createStanzaCollector(
new ThreadFilter(chat11.getThreadID()));
Chat chat21 = getConnection(0).getChatManager().createChat(getBareJID(2), null);
PacketCollector chat22 = getConnection(2).createPacketCollector(
StanzaCollector chat22 = getConnection(2).createStanzaCollector(
new ThreadFilter(chat21.getThreadID()));
Chat chat31 = getConnection(0).getChatManager().createChat(getBareJID(3), null);
PacketCollector chat32 = getConnection(3).createPacketCollector(
StanzaCollector chat32 = getConnection(3).createStanzaCollector(
new ThreadFilter(chat31.getThreadID()));
for (int i=0; i<500; i++) {

View file

@ -52,7 +52,7 @@ public class IQTest extends SmackTestCase {
PacketFilter filter = new AndFilter(new PacketIDFilter(iq.getStanzaId()),
new StanzaTypeFilter(IQ.class));
PacketCollector collector = getConnection(0).createPacketCollector(filter);
StanzaCollector collector = getConnection(0).createStanzaCollector(filter);
// Send the iq packet with an invalid namespace
getConnection(0).sendStanza(iq);
@ -82,7 +82,7 @@ public class IQTest extends SmackTestCase {
versionRequest.setTo(getBareJID(0) + "/Something");
// Create a packet collector to listen for a response.
PacketCollector collector = getConnection(0).createPacketCollector(
StanzaCollector collector = getConnection(0).createStanzaCollector(
new PacketIDFilter(versionRequest.getStanzaId()));
getConnection(0).sendStanza(versionRequest);

View file

@ -48,8 +48,8 @@ public class MessageTest extends SmackTestCase {
presence.setTo(getBareJID(1));
getConnection(0).sendStanza(presence);
PacketCollector collector = getConnection(0)
.createPacketCollector(new MessageTypeFilter(Message.Type.chat));
StanzaCollector collector = getConnection(0)
.createStanzaCollector(new MessageTypeFilter(Message.Type.chat));
try {
getConnection(1).getChatManager().createChat(getBareJID(0), null).sendMessage("Test 1");
}
@ -77,7 +77,7 @@ public class MessageTest extends SmackTestCase {
// User1 sends some messages to User2 which is not available at the moment
Chat chat = getConnection(0).getChatManager().createChat(getBareJID(1), null);
PacketCollector collector = getConnection(1).createPacketCollector(
StanzaCollector collector = getConnection(1).createStanzaCollector(
new MessageTypeFilter(Message.Type.chat));
chat.sendMessage("Test 1");
chat.sendMessage("Test 2");
@ -119,7 +119,7 @@ public class MessageTest extends SmackTestCase {
// User1 sends some messages to User2 which is not available at the moment
Chat chat = getConnection(0).getChatManager().createChat(getBareJID(1), null);
PacketCollector collector = getConnection(1).createPacketCollector(
StanzaCollector collector = getConnection(1).createStanzaCollector(
new MessageTypeFilter(Message.Type.chat));
chat.sendMessage("Test \f 1");
chat.sendMessage("Test \r 1");
@ -153,7 +153,7 @@ public class MessageTest extends SmackTestCase {
getConnection(0).sendStanza(new Presence(Presence.Type.available));
getConnection(1).sendStanza(new Presence(Presence.Type.available));
// User2 becomes available again
PacketCollector collector = getConnection(1).createPacketCollector(
StanzaCollector collector = getConnection(1).createStanzaCollector(
new MessageTypeFilter(Message.Type.chat));
// Create message with a body of 4K characters
@ -210,8 +210,8 @@ public class MessageTest extends SmackTestCase {
Thread.sleep(200);
// User0 listen in both connected clients
PacketCollector collector = getConnection(0).createPacketCollector(new MessageTypeFilter(Message.Type.chat));
PacketCollector coll3 = conn3.createPacketCollector(new MessageTypeFilter(Message.Type.chat));
StanzaCollector collector = getConnection(0).createStanzaCollector(new MessageTypeFilter(Message.Type.chat));
StanzaCollector coll3 = conn3.createStanzaCollector(new MessageTypeFilter(Message.Type.chat));
// User1 sends a message to the bare JID of User0
Chat chat = getConnection(1).getChatManager().createChat(getBareJID(0), null);
@ -259,8 +259,8 @@ public class MessageTest extends SmackTestCase {
Thread.sleep(200);
// User0 listen in both connected clients
PacketCollector collector = getConnection(0).createPacketCollector(new MessageTypeFilter(Message.Type.chat));
PacketCollector coll3 = conn3.createPacketCollector(new MessageTypeFilter(Message.Type.chat));
StanzaCollector collector = getConnection(0).createStanzaCollector(new MessageTypeFilter(Message.Type.chat));
StanzaCollector coll3 = conn3.createStanzaCollector(new MessageTypeFilter(Message.Type.chat));
// User1 sends a message to the bare JID of User0
Chat chat = getConnection(1).getChatManager().createChat(getBareJID(0), null);
@ -321,9 +321,9 @@ public class MessageTest extends SmackTestCase {
Thread.sleep(200);
// User0 listen in both connected clients
PacketCollector collector = getConnection(0).createPacketCollector(new MessageTypeFilter(Message.Type.chat));
PacketCollector coll3 = conn3.createPacketCollector(new MessageTypeFilter(Message.Type.chat));
PacketCollector coll4 = conn4.createPacketCollector(new MessageTypeFilter(Message.Type.chat));
StanzaCollector collector = getConnection(0).createStanzaCollector(new MessageTypeFilter(Message.Type.chat));
StanzaCollector coll3 = conn3.createStanzaCollector(new MessageTypeFilter(Message.Type.chat));
StanzaCollector coll4 = conn4.createStanzaCollector(new MessageTypeFilter(Message.Type.chat));
// Send a message from this resource to indicate most recent activity
conn3.sendStanza(new Message("admin@" + getXMPPServiceDomain()));
@ -368,7 +368,7 @@ public class MessageTest extends SmackTestCase {
Thread.sleep(200);
// User0 listen for incoming traffic
PacketCollector collector = getConnection(0).createPacketCollector(new MessageTypeFilter(Message.Type.chat));
StanzaCollector collector = getConnection(0).createStanzaCollector(new MessageTypeFilter(Message.Type.chat));
// User1 sends a message to the bare JID of User0
Chat chat = getConnection(1).getChatManager().createChat(getBareJID(0), null);

View file

@ -82,7 +82,7 @@ public class PacketReaderTest extends SmackTestCase {
iqPacket.setType(IQ.Type.get);
// Send the IQ and wait for the answer
PacketCollector collector = getConnection(0).createPacketCollector(
StanzaCollector collector = getConnection(0).createStanzaCollector(
new PacketIDFilter(iqPacket.getStanzaId()));
getConnection(0).sendStanza(iqPacket);
IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
@ -100,7 +100,7 @@ public class PacketReaderTest extends SmackTestCase {
public void testRemoveListener() {
PacketListener listener = new PacketListener() {
public void processPacket(Packet packet) {
public void processStanza(Packet packet) {
// Do nothing
}
};
@ -135,7 +135,7 @@ public class PacketReaderTest extends SmackTestCase {
// User1 will always reply to user0 when a message is received
getConnection(1).addAsyncPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
public void processStanza(Packet packet) {
System.out.println(new Date() + " " + packet);
Message message = new Message(packet.getFrom());
@ -146,7 +146,7 @@ public class PacketReaderTest extends SmackTestCase {
}, new StanzaTypeFilter(Message.class));
// User0 listen for replies from user1
PacketCollector collector = getConnection(0).createPacketCollector(
StanzaCollector collector = getConnection(0).createStanzaCollector(
new FromMatchesFilter(getFullJID(1)));
// User0 sends the regular message to user1
getConnection(0).sendStanza(packet);
@ -176,7 +176,7 @@ public class PacketReaderTest extends SmackTestCase {
for (int j = 0; j < repeat; j++) {
PacketListener listener0 = new PacketListener() {
public void processPacket(Packet packet) {
public void processStanza(Packet packet) {
System.out.println("Packet Captured");
incCounter();
}
@ -190,7 +190,7 @@ public class PacketReaderTest extends SmackTestCase {
};
PacketListener listener1 = new PacketListener() {
public void processPacket(Packet packet) {
public void processStanza(Packet packet) {
System.out.println("Packet Captured");
incCounter();
}

View file

@ -111,17 +111,17 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
new CopyOnWriteArraySet<ConnectionListener>();
/**
* A collection of PacketCollectors which collects packets for a specified filter
* A collection of StanzaCollectors which collects packets for a specified filter
* and perform blocking and polling operations on the result queue.
* <p>
* We use a ConcurrentLinkedQueue here, because its Iterator is weakly
* consistent and we want {@link #invokePacketCollectors(Stanza)} for-each
* loop to be lock free. As drawback, removing a PacketCollector is O(n).
* consistent and we want {@link #invokeStanzaCollectorsAndNotifyRecvListeners(Stanza)} for-each
* loop to be lock free. As drawback, removing a StanzaCollector is O(n).
* The alternative would be a synchronized HashSet, but this would mean a
* synchronized block around every usage of <code>collectors</code>.
* </p>
*/
private final Collection<PacketCollector> collectors = new ConcurrentLinkedQueue<PacketCollector>();
private final Collection<StanzaCollector> collectors = new ConcurrentLinkedQueue<>();
/**
* List of PacketListeners that will be notified synchronously when a new stanza(/packet) was received.
@ -531,7 +531,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// Note that we can not use IQReplyFilter here, since the users full JID is not yet
// available. It will become available right after the resource has been successfully bound.
Bind bindResource = Bind.newSet(resource);
PacketCollector packetCollector = createPacketCollectorAndSend(new StanzaIdFilter(bindResource), bindResource);
StanzaCollector packetCollector = createStanzaCollectorAndSend(new StanzaIdFilter(bindResource), bindResource);
Bind response = packetCollector.nextResultOrThrow();
// Set the connections user to the result of resource binding. It is important that we don't infer the user
// from the login() arguments and the configurations service name, as, for example, when SASL External is used,
@ -547,7 +547,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
boolean legacySessionDisabled = getConfiguration().isLegacySessionDisabled();
if (sessionFeature != null && !sessionFeature.isOptional() && !legacySessionDisabled) {
Session session = new Session();
packetCollector = createPacketCollectorAndSend(new StanzaIdFilter(session), session);
packetCollector = createStanzaCollectorAndSend(new StanzaIdFilter(session), session);
packetCollector.nextResultOrThrow();
}
}
@ -743,18 +743,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
@Override
public PacketCollector createPacketCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException {
public StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException {
StanzaFilter packetFilter = new IQReplyFilter(packet, this);
// Create the packet collector before sending the packet
PacketCollector packetCollector = createPacketCollectorAndSend(packetFilter, packet);
StanzaCollector packetCollector = createStanzaCollectorAndSend(packetFilter, packet);
return packetCollector;
}
@Override
public PacketCollector createPacketCollectorAndSend(StanzaFilter packetFilter, Stanza packet)
public StanzaCollector createStanzaCollectorAndSend(StanzaFilter packetFilter, Stanza packet)
throws NotConnectedException, InterruptedException {
// Create the packet collector before sending the packet
PacketCollector packetCollector = createPacketCollector(packetFilter);
StanzaCollector packetCollector = createStanzaCollector(packetFilter);
try {
// Now we can send the packet as the collector has been created
sendStanza(packet);
@ -767,21 +767,21 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
@Override
public PacketCollector createPacketCollector(StanzaFilter packetFilter) {
PacketCollector.Configuration configuration = PacketCollector.newConfiguration().setStanzaFilter(packetFilter);
return createPacketCollector(configuration);
public StanzaCollector createStanzaCollector(StanzaFilter packetFilter) {
StanzaCollector.Configuration configuration = StanzaCollector.newConfiguration().setStanzaFilter(packetFilter);
return createStanzaCollector(configuration);
}
@Override
public PacketCollector createPacketCollector(PacketCollector.Configuration configuration) {
PacketCollector collector = new PacketCollector(this, configuration);
public StanzaCollector createStanzaCollector(StanzaCollector.Configuration configuration) {
StanzaCollector collector = new StanzaCollector(this, configuration);
// Add the collector to the list of active collectors.
collectors.add(collector);
return collector;
}
@Override
public void removePacketCollector(PacketCollector collector) {
public void removeStanzaCollector(StanzaCollector collector) {
collectors.remove(collector);
}
@ -878,7 +878,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
public void run() {
for (StanzaListener listener : listenersToNotify) {
try {
listener.processPacket(packet);
listener.processStanza(packet);
}
catch (Exception e) {
LOGGER.log(Level.WARNING, "Sending listener threw exception", e);
@ -926,7 +926,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
for (StanzaListener interceptor : interceptorsToInvoke) {
try {
interceptor.processPacket(packet);
interceptor.processStanza(packet);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Packet interceptor threw exception", e);
}
@ -1033,18 +1033,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
executorService.executeBlocking(new Runnable() {
@Override
public void run() {
invokePacketCollectorsAndNotifyRecvListeners(stanza);
invokeStanzaCollectorsAndNotifyRecvListeners(stanza);
}
});
}
/**
* Invoke {@link PacketCollector#processPacket(Stanza)} for every
* PacketCollector with the given packet. Also notify the receive listeners with a matching stanza(/packet) filter about the packet.
* Invoke {@link StanzaCollector#processStanza(Stanza)} for every
* StanzaCollector with the given packet. Also notify the receive listeners with a matching stanza(/packet) filter about the packet.
*
* @param packet the stanza(/packet) to notify the PacketCollectors and receive listeners about.
* @param packet the stanza(/packet) to notify the StanzaCollectors and receive listeners about.
*/
protected void invokePacketCollectorsAndNotifyRecvListeners(final Stanza packet) {
protected void invokeStanzaCollectorsAndNotifyRecvListeners(final Stanza packet) {
if (packet instanceof IQ) {
final IQ iq = (IQ) packet;
final IQ.Type type = iq.getType();
@ -1140,7 +1140,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override
public void run() {
try {
listener.processPacket(packet);
listener.processStanza(packet);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Exception in async packet listener", e);
}
@ -1149,8 +1149,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
// Loop through all collectors and notify the appropriate ones.
for (PacketCollector collector: collectors) {
collector.processPacket(packet);
for (StanzaCollector collector: collectors) {
collector.processStanza(packet);
}
// Notify the receive listeners interested in the packet
@ -1170,7 +1170,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
public void run() {
for (StanzaListener listener : listenersToNotify) {
try {
listener.processPacket(packet);
listener.processStanza(packet);
} catch(NotConnectedException e) {
LOGGER.log(Level.WARNING, "Got not connected exception, aborting", e);
break;
@ -1471,10 +1471,10 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
final StanzaListener packetListener = new StanzaListener() {
@Override
public void processPacket(Stanza packet) throws NotConnectedException, InterruptedException {
public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException {
try {
XMPPErrorException.ifHasErrorThenThrow(packet);
callback.processPacket(packet);
callback.processStanza(packet);
}
catch (XMPPErrorException e) {
if (exceptionCallback != null) {
@ -1532,9 +1532,9 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
public void addOneTimeSyncCallback(final StanzaListener callback, final StanzaFilter packetFilter) {
final StanzaListener packetListener = new StanzaListener() {
@Override
public void processPacket(Stanza packet) throws NotConnectedException, InterruptedException {
public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException {
try {
callback.processPacket(packet);
callback.processStanza(packet);
} finally {
removeSyncStanzaListener(this);
}

View file

@ -129,7 +129,7 @@ public final class SmackConfiguration {
*
* @return The number of packets to queue before deleting older packets.
*/
public static int getPacketCollectorSize() {
public static int getStanzaCollectorSize() {
return packetCollectorSize;
}
@ -139,7 +139,7 @@ public final class SmackConfiguration {
*
* @param collectorSize the number of packets to queue before deleting older packets.
*/
public static void setPacketCollectorSize(int collectorSize) {
public static void setStanzaCollectorSize(int collectorSize) {
packetCollectorSize = collectorSize;
}

View file

@ -93,7 +93,7 @@ public class SmackException extends Exception {
}
public static NoResponseException newWith(XMPPConnection connection,
PacketCollector collector) {
StanzaCollector collector) {
return newWith(connection, collector.getStanzaFilter());
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software.
* Copyright 2003-2007 Jive Software, 2016-2017 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -27,20 +27,20 @@ import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.Stanza;
/**
* Provides a mechanism to collect packets into a result queue that pass a
* specified filter. The collector lets you perform blocking and polling
* operations on the result queue. So, a PacketCollector is more suitable to
* Provides a mechanism to collect Stanzas into a result queue that pass a
* specified filter/matcher. The collector lets you perform blocking and polling
* operations on the result queue. So, a StanzaCollector is more suitable to
* use than a {@link StanzaListener} when you need to wait for a specific
* result.<p>
*
* Each stanza(/packet) collector will queue up a configured number of packets for processing before
* older packets are automatically dropped. The default number is retrieved by
* {@link SmackConfiguration#getPacketCollectorSize()}.
* {@link SmackConfiguration#getStanzaCollectorSize()}.
*
* @see XMPPConnection#createPacketCollector(StanzaFilter)
* @see XMPPConnection#createStanzaCollector(StanzaFilter)
* @author Matt Tucker
*/
public class PacketCollector {
public class StanzaCollector {
private final StanzaFilter packetFilter;
@ -49,7 +49,7 @@ public class PacketCollector {
/**
* The stanza(/packet) collector which timeout for the next result will get reset once this collector collects a stanza.
*/
private final PacketCollector collectorToReset;
private final StanzaCollector collectorToReset;
private final XMPPConnection connection;
@ -62,7 +62,7 @@ public class PacketCollector {
* @param connection the connection the collector is tied to.
* @param configuration the configuration used to construct this collector
*/
protected PacketCollector(XMPPConnection connection, Configuration configuration) {
protected StanzaCollector(XMPPConnection connection, Configuration configuration) {
this.connection = connection;
this.packetFilter = configuration.packetFilter;
this.resultQueue = new ArrayBlockingQueue<>(configuration.size);
@ -78,7 +78,7 @@ public class PacketCollector {
// If the packet collector has already been cancelled, do nothing.
if (!cancelled) {
cancelled = true;
connection.removePacketCollector(this);
connection.removeStanzaCollector(this);
}
}
@ -274,7 +274,7 @@ public class PacketCollector {
*
* @param packet the stanza(/packet) to process.
*/
protected void processPacket(Stanza packet) {
protected void processStanza(Stanza packet) {
if (packetFilter == null || packetFilter.accept(packet)) {
// CHECKSTYLE:OFF
while (!resultQueue.offer(packet)) {
@ -305,8 +305,8 @@ public class PacketCollector {
public static final class Configuration {
private StanzaFilter packetFilter;
private int size = SmackConfiguration.getPacketCollectorSize();
private PacketCollector collectorToReset;
private int size = SmackConfiguration.getStanzaCollectorSize();
private StanzaCollector collectorToReset;
private Configuration() {
}
@ -355,7 +355,7 @@ public class PacketCollector {
* @param collector
* @return a reference to this configuration.
*/
public Configuration setCollectorToReset(PacketCollector collector) {
public Configuration setCollectorToReset(StanzaCollector collector) {
this.collectorToReset = collector;
return this;
}

View file

@ -23,8 +23,8 @@ import org.jivesoftware.smack.packet.Stanza;
/**
* Provides a mechanism to listen for packets that pass a specified filter.
* This allows event-style programming -- every time a new stanza(/packet) is found,
* the {@link #processPacket(Stanza)} method will be called. This is the
* opposite approach to the functionality provided by a {@link PacketCollector}
* the {@link #processStanza(Stanza)} method will be called. This is the
* opposite approach to the functionality provided by a {@link StanzaCollector}
* which lets you block while waiting for results.
* <p>
* Additionally you are able to intercept Packets that are going to be send and
@ -50,6 +50,6 @@ public interface StanzaListener {
* @throws NotConnectedException
* @throws InterruptedException
*/
public void processPacket(Stanza packet) throws NotConnectedException, InterruptedException;
public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException;
}

View file

@ -225,11 +225,11 @@ public interface XMPPConnection {
* @throws NotConnectedException
* @throws InterruptedException
*/
public PacketCollector createPacketCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException;
public StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException;
/**
* Creates a new stanza(/packet) collector for this connection. A stanza(/packet) filter determines
* which packets will be accumulated by the collector. A PacketCollector is
* which packets will be accumulated by the collector. A StanzaCollector is
* more suitable to use than a {@link StanzaListener} when you need to wait for
* a specific result.
*
@ -239,46 +239,46 @@ public interface XMPPConnection {
* @throws InterruptedException
* @throws NotConnectedException
*/
public PacketCollector createPacketCollectorAndSend(StanzaFilter packetFilter, Stanza packet)
public StanzaCollector createStanzaCollectorAndSend(StanzaFilter packetFilter, Stanza packet)
throws NotConnectedException, InterruptedException;
/**
* Creates a new stanza(/packet) collector for this connection. A stanza(/packet) filter
* determines which packets will be accumulated by the collector. A
* PacketCollector is more suitable to use than a {@link StanzaListener}
* StanzaCollector is more suitable to use than a {@link StanzaListener}
* when you need to wait for a specific result.
* <p>
* <b>Note:</b> If you send a Stanza(/Packet) right after using this method, then
* consider using
* {@link #createPacketCollectorAndSend(StanzaFilter, Stanza)} instead.
* Otherwise make sure cancel the PacketCollector in every case, e.g. even
* if an exception is thrown, or otherwise you may leak the PacketCollector.
* {@link #createStanzaCollectorAndSend(StanzaFilter, Stanza)} instead.
* Otherwise make sure cancel the StanzaCollector in every case, e.g. even
* if an exception is thrown, or otherwise you may leak the StanzaCollector.
* </p>
*
* @param packetFilter the stanza(/packet) filter to use.
* @return a new stanza(/packet) collector.
*/
public PacketCollector createPacketCollector(StanzaFilter packetFilter);
public StanzaCollector createStanzaCollector(StanzaFilter packetFilter);
/**
* Create a new stanza(/packet) collector with the given stanza(/packet) collector configuration.
* <p>
* Please make sure to cancel the collector when it is no longer required. See also
* {@link #createPacketCollector(StanzaFilter)}.
* {@link #createStanzaCollector(StanzaFilter)}.
* </p>
*
* @param configuration the stanza(/packet) collector configuration.
* @return a new stanza(/packet) collector.
* @since 4.1
*/
public PacketCollector createPacketCollector(PacketCollector.Configuration configuration);
public StanzaCollector createStanzaCollector(StanzaCollector.Configuration configuration);
/**
* Remove a stanza(/packet) collector of this connection.
*
* @param collector a stanza(/packet) collectors which was created for this connection.
*/
public void removePacketCollector(PacketCollector collector);
public void removeStanzaCollector(StanzaCollector collector);
/**
* Registers a stanza(/packet) listener with this connection.
@ -316,7 +316,7 @@ public interface XMPPConnection {
* incoming stanzas. Only use this kind of stanza(/packet) filter if it does not perform any XMPP activity that waits for a
* response. Consider using {@link #addAsyncStanzaListener(StanzaListener, StanzaFilter)} when possible, i.e. when
* the invocation order doesn't have to be the same as the order of the arriving packets. If the order of the
* arriving packets, consider using a {@link PacketCollector} when possible.
* arriving packets, consider using a {@link StanzaCollector} when possible.
* </p>
*
* @param packetListener the stanza(/packet) listener to notify of new received packets.

View file

@ -68,7 +68,7 @@ public abstract class AbstractDebugger implements SmackDebugger {
// the GUI. This is what we call "interpreted" packet data, since it's the packet
// data as Smack sees it and not as it's coming in as raw XML.
listener = new StanzaListener() {
public void processPacket(Stanza packet) {
public void processStanza(Stanza packet) {
if (printInterpreted) {
log("RCV PKT (" + connection.getConnectionCounter() + "): " + packet.toXML());
}

View file

@ -37,10 +37,10 @@ package org.jivesoftware.smack.filter;
* }
* };
* // Create a new stanza(/packet) collector using the filter we created.
* PacketCollector myCollector = packetReader.createPacketCollector(myFilter);
* StanzaCollector myCollector = packetReader.createStanzaCollector(myFilter);
* </pre>
*
* @see org.jivesoftware.smack.PacketCollector
* @see org.jivesoftware.smack.StanzaCollector
* @see org.jivesoftware.smack.StanzaListener
* @author Matt Tucker
* @deprecated use {@link StanzaFilter}

View file

@ -39,10 +39,10 @@ import org.jivesoftware.smack.packet.Stanza;
* }
* };
* // Create a new stanza collector using the filter we created.
* PacketCollector myCollector = connection.createPacketCollector(myFilter);
* StanzaCollector myCollector = connection.createStanzaCollector(myFilter);
* </pre>
*
* @see org.jivesoftware.smack.PacketCollector
* @see org.jivesoftware.smack.StanzaCollector
* @see org.jivesoftware.smack.StanzaListener
* @author Matt Tucker
*/

View file

@ -16,6 +16,6 @@
*/
/**
* Allows {@link org.jivesoftware.smack.PacketCollector} and {@link org.jivesoftware.smack.StanzaListener} instances to filter for stanzas with particular attributes.
* Allows {@link org.jivesoftware.smack.StanzaCollector} and {@link org.jivesoftware.smack.StanzaListener} instances to filter for stanzas with particular attributes.
*/
package org.jivesoftware.smack.filter;

View file

@ -180,7 +180,7 @@ public class DummyConnection extends AbstractXMPPConnection {
* @param packet the stanza(/packet) to process.
*/
public void processStanza(Stanza packet) {
invokePacketCollectorsAndNotifyRecvListeners(packet);
invokeStanzaCollectorsAndNotifyRecvListeners(packet);
}
/**

View file

@ -23,18 +23,18 @@ import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.Stanza;
import org.junit.Test;
public class PacketCollectorTest
public class StanzaCollectorTest
{
@Test
public void verifyRollover() throws InterruptedException
{
TestPacketCollector collector = new TestPacketCollector(null, new OKEverything(), 5);
TestStanzaCollector collector = new TestStanzaCollector(null, new OKEverything(), 5);
for (int i=0; i<6; i++)
{
Stanza testPacket = new TestPacket(i);
collector.processPacket(testPacket);
collector.processStanza(testPacket);
}
// Assert that '0' has rolled off
@ -48,7 +48,7 @@ public class PacketCollectorTest
for (int i=10; i<15; i++)
{
Stanza testPacket = new TestPacket(i);
collector.processPacket(testPacket);
collector.processStanza(testPacket);
}
assertEquals("10", collector.nextResultBlockForever().getStanzaId());
@ -69,7 +69,7 @@ public class PacketCollectorTest
public void verifyThreadSafety()
{
int insertCount = 500;
final TestPacketCollector collector = new TestPacketCollector(null, new OKEverything(), insertCount);
final TestStanzaCollector collector = new TestStanzaCollector(null, new OKEverything(), insertCount);
Thread consumer1 = new Thread(new Runnable()
{
@ -158,7 +158,7 @@ public class PacketCollectorTest
for(int i=0; i<insertCount; i++)
{
collector.processPacket(new TestPacket(i));
collector.processStanza(new TestPacket(i));
}
try
@ -186,11 +186,11 @@ public class PacketCollectorTest
}
class TestPacketCollector extends PacketCollector
class TestStanzaCollector extends StanzaCollector
{
protected TestPacketCollector(XMPPConnection conection, StanzaFilter packetFilter, int size)
protected TestStanzaCollector(XMPPConnection conection, StanzaFilter packetFilter, int size)
{
super(conection, PacketCollector.newConfiguration().setStanzaFilter(packetFilter).setSize(size));
super(conection, StanzaCollector.newConfiguration().setStanzaFilter(packetFilter).setSize(size));
}
}

View file

@ -28,7 +28,7 @@ public class WaitForPacketListener implements StanzaListener {
private CountDownLatch latch = new CountDownLatch(1);
@Override
public void processPacket(Stanza packet) throws NotConnectedException {
public void processStanza(Stanza packet) throws NotConnectedException {
reportInvoked();
}