[core] Deprecate AbstractConnectionListener

This commit is contained in:
Florian Schmaus 2020-05-13 22:01:48 +02:00
parent 13abeb9626
commit ab2d3a2b79
18 changed files with 44 additions and 39 deletions

View File

@ -1,6 +1,6 @@
/**
*
* Copyright 2015 Florian Schmaus
* Copyright 2015-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
*/
package org.jivesoftware.smack;
public abstract class AbstractConnectionClosedListener extends AbstractConnectionListener {
public abstract class AbstractConnectionClosedListener implements ConnectionListener {
@Override
public final void connectionClosed() {

View File

@ -23,7 +23,10 @@ package org.jivesoftware.smack;
* all methods.
*
* @author Henning Staib
* @deprecated use {@link ConnectionListener} instead.
*/
// TODO: Remove in Smack 4.5.
@Deprecated
public class AbstractConnectionListener implements ConnectionListener {
@Override
public void connected(XMPPConnection connection) {

View File

@ -37,7 +37,8 @@ public interface ConnectionListener {
*
* @param connection the XMPPConnection which successfully connected to its endpoint.
*/
void connected(XMPPConnection connection);
default void connected(XMPPConnection connection) {
}
/**
* Notification that the connection has been authenticated.
@ -45,12 +46,14 @@ public interface ConnectionListener {
* @param connection the XMPPConnection which successfully authenticated.
* @param resumed true if a previous XMPP session's stream was resumed.
*/
void authenticated(XMPPConnection connection, boolean resumed);
default void authenticated(XMPPConnection connection, boolean resumed) {
}
/**
* Notification that the connection was closed normally.
*/
void connectionClosed();
default void connectionClosed() {
}
/**
* Notification that the connection was closed due to an exception. When
@ -59,6 +62,7 @@ public interface ConnectionListener {
*
* @param e the exception.
*/
void connectionClosedOnError(Exception e);
default void connectionClosedOnError(Exception e) {
}
}

View File

@ -401,7 +401,7 @@ public final class ReconnectionManager {
reconnectionThread = null;
}
private final ConnectionListener connectionListener = new AbstractConnectionListener() {
private final ConnectionListener connectionListener = new ConnectionListener() {
@Override
public void connectionClosed() {

View File

@ -18,7 +18,6 @@ package org.jivesoftware.smack.debugger;
import java.util.logging.Logger;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.ReconnectionListener;
@ -69,7 +68,7 @@ public abstract class AbstractDebugger extends SmackDebugger {
};
this.writer.addWriterListener(writerListener);
connListener = new AbstractConnectionListener() {
connListener = new ConnectionListener() {
@Override
public void connected(XMPPConnection connection) {
log("XMPPConnection connected ("

View File

@ -17,13 +17,13 @@
package org.jivesoftware.smackx.debugger.slf4j;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.ReconnectionListener;
import org.jivesoftware.smack.XMPPConnection;
import org.slf4j.Logger;
class SLF4JLoggingConnectionListener extends AbstractConnectionListener implements ReconnectionListener {
class SLF4JLoggingConnectionListener implements ConnectionListener, ReconnectionListener {
private final XMPPConnection connection;
private final Logger logger;

View File

@ -60,7 +60,6 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.BadLocationException;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.ReconnectionListener;
@ -220,7 +219,7 @@ public class EnhancedDebugger extends SmackDebugger {
addInformationPanel();
// Create a thread that will listen for any connection closed event
connListener = new AbstractConnectionListener() {
connListener = new ConnectionListener() {
@Override
public void connectionClosed() {
SwingUtilities.invokeLater(new Runnable() {

View File

@ -1,6 +1,6 @@
/**
*
* Copyright 2013-2014 Georg Lukas, 2017-2018 Florian Schmaus
* Copyright 2013-2014 Georg Lukas, 2017-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,9 +21,9 @@ import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.AsyncButOrdered;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
@ -130,7 +130,7 @@ public final class CarbonManager extends Manager {
}
};
connection.addConnectionListener(new AbstractConnectionListener() {
connection.addConnectionListener(new ConnectionListener() {
@Override
public void connectionClosed() {
// Reset the state if the connection was cleanly closed. Note that this is not strictly necessary,

View File

@ -37,9 +37,9 @@ import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
@ -118,7 +118,7 @@ public final class HttpFileUploadManager extends Manager {
private HttpFileUploadManager(XMPPConnection connection) {
super(connection);
connection.addConnectionListener(new AbstractConnectionListener() {
connection.addConnectionListener(new ConnectionListener() {
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {
// No need to reset the cache if the connection got resumed.

View File

@ -1,6 +1,6 @@
/**
*
* Copyright 2016-2017 Fernando Ramirez, Florian Schmaus
* Copyright 2016-2017 Fernando Ramirez, 2016-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,8 +24,8 @@ import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -145,7 +145,7 @@ public final class BlockingCommandManager extends Manager {
}
});
connection.addConnectionListener(new AbstractConnectionListener() {
connection.addConnectionListener(new ConnectionListener() {
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {
// No need to reset the cache if the connection got resumed.

View File

@ -36,8 +36,8 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException.NoResponseException;
@ -328,7 +328,7 @@ public final class EntityCapsManager extends Manager {
this.sdm = ServiceDiscoveryManager.getInstanceFor(connection);
instances.put(connection, this);
connection.addConnectionListener(new AbstractConnectionListener() {
connection.addConnectionListener(new ConnectionListener() {
@Override
public void connected(XMPPConnection connection) {
// It's not clear when a server would report the caps stream

View File

@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx.jingle.transports;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smackx.jingle.JingleSession;
@ -26,7 +26,7 @@ import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
* Manager for a JingleTransport method.
* @param <D> JingleContentTransport.
*/
public abstract class JingleTransportManager<D extends JingleContentTransport> extends AbstractConnectionListener {
public abstract class JingleTransportManager<D extends JingleContentTransport> implements ConnectionListener {
private final XMPPConnection connection;

View File

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,8 +28,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -191,7 +191,7 @@ public final class MultiUserChatManager extends Manager {
};
connection.addAsyncStanzaListener(invitationPacketListener, INVITATION_FILTER);
connection.addConnectionListener(new AbstractConnectionListener() {
connection.addConnectionListener(new ConnectionListener() {
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {
if (resumed) return;

View File

@ -1,6 +1,6 @@
/**
*
* Copyright © 2015 Florian Schmaus
* Copyright © 2015-2020 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,8 +22,8 @@ import java.util.WeakHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -85,7 +85,7 @@ public final class MucBookmarkAutojoinManager extends Manager {
super(connection);
multiUserChatManager = MultiUserChatManager.getInstanceFor(connection);
bookmarkManager = BookmarkManager.getBookmarkManager(connection);
connection.addConnectionListener(new AbstractConnectionListener() {
connection.addConnectionListener(new ConnectionListener() {
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {
if (!autojoinEnabled) {

View File

@ -23,8 +23,8 @@ import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -186,7 +186,7 @@ public final class PrivacyListManager extends Manager {
}
}
}, PRIVACY_RESULT);
connection.addConnectionListener(new AbstractConnectionListener() {
connection.addConnectionListener(new ConnectionListener() {
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {
// No need to reset the cache if the connection got resumed.

View File

@ -33,9 +33,9 @@ import java.util.concurrent.CopyOnWriteArraySet;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.AsyncButOrdered;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
@ -313,7 +313,7 @@ public final class Roster extends Manager {
}, PresenceTypeFilter.SUBSCRIBE);
// Listen for connection events
connection.addConnectionListener(new AbstractConnectionListener() {
connection.addConnectionListener(new ConnectionListener() {
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {

View File

@ -34,7 +34,7 @@ import java.util.WeakHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.StanzaListener;
@ -126,7 +126,7 @@ public final class OmemoManager extends Manager {
if (connection.isAuthenticated()) {
initBareJidAndDeviceId(this);
} else {
connection.addConnectionListener(new AbstractConnectionListener() {
connection.addConnectionListener(new ConnectionListener() {
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {
initBareJidAndDeviceId(OmemoManager.this);

View File

@ -55,10 +55,10 @@ import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import org.jivesoftware.smack.AbstractConnectionListener;
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.AlreadyConnectedException;
@ -294,7 +294,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
public XMPPTCPConnection(XMPPTCPConnectionConfiguration config) {
super(config);
this.config = config;
addConnectionListener(new AbstractConnectionListener() {
addConnectionListener(new ConnectionListener() {
@Override
public void connectionClosedOnError(Exception e) {
if (e instanceof XMPPException.StreamErrorException || e instanceof StreamManagementException) {