1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 15:52:06 +01:00

Make XMPPConnection an interface

create AbstractXMPPConnection.
This commit is contained in:
Florian Schmaus 2014-05-25 12:28:08 +02:00
parent 6dd180e9d3
commit beecb8a675
33 changed files with 1264 additions and 1090 deletions

View file

@ -14,7 +14,7 @@ Key Advantages :
- Extremely simple to use, yet powerful API. Sending a text message to a user can be accomplished in only a few lines of code:
```java
XMPPConnection connection = new XMPPTCPConnection("jabber.org");
AbstractXMPPConnection connection = new XMPPTCPConnection("jabber.org");
connection.connect();
connection.login("mtucker", "password");
Chat chat = ChatManager.getInstanceFor(connection)

View file

@ -20,8 +20,8 @@
<p>
The <tt>org.jivesoftware.smack.XMPPConnection</tt> class manages your connection to an XMPP
server. The default implementation is the <tt>org.jivesoftware.smack.XMPPConnection</tt>
class. Two constructors are mainly used. The first, <tt>XMPPConnection(String)</tt> takes
server. A default implementation is the <tt>org.jivesoftware.smack.XMPPTCPConnection</tt>
class. Two constructors are mainly used. The first, <tt>XMPPTCPConnection(String)</tt> takes
the server name you'd like to connect to as an argument. All default connection settings will
be used:
<ul>
@ -33,7 +33,7 @@
<li>The XMPP resource name "Smack" will be used for the connection.</li>
</ul>
Alternatively, you can use the <tt>XMPPServer(ConnectionConfiguration)</tt> constructor to
Alternatively, you can use the <tt>XMPPTCPConnection(ConnectionConfiguration)</tt> constructor to
specify advanced connection settings. Some of these settings include:
<ul>
@ -61,9 +61,8 @@
<font color="gray"><i>// Create the configuration for this new connection</i></font>
ConnectionConfiguration config = new ConnectionConfiguration(<font color="green">"jabber.org"</font>, 5222);
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);
Connection connection = new XMPPConnection(config);
AbstractXMPPConnection connection = new XMPPTCPConnection(config);
<font color="gray"><i>// Connect to the server</i></font>
connection.connect();
<font color="gray"><i>// Log into the server</i></font>
@ -80,7 +79,7 @@ manager will try to immediately reconnect to the server and increase the delay b
successive reconnections keep failing.</i>
<br>
In case you want to force a reconnection while the reconnetion manager is waiting for the next
reconnection, you can just use <i>XMPPConnection#connect()</i> and a new attempt will be made.
reconnection, you can just use <i>AbstractXMPPConnection#connect()</i> and a new attempt will be made.
If the manual attempt also failed then the reconnection manager will still continue the
reconnection job.
</p>

View file

@ -26,7 +26,7 @@ Debugging mode can be enabled in two different ways:
<ol>
<li>Add the following line of code <b>before</b> creating new connections:<p>
<tt>XMPPConnection.DEBUG_ENABLED = true;</tt><p>
<tt>SmackConfiguration.DEBUG_ENABLED = true;</tt><p>
<li>Set the Java system property <tt>smack.debugEnabled</tt> to true. The
system property can be set on the command line such as:<p>
@ -39,7 +39,7 @@ add the following line to your application before opening new connections:
</p>
<p>
<tt>XMPPConnection.DEBUG_ENABLED = false;</tt>
<tt>SmackConfiguration.DEBUG_ENABLED = false;</tt>
</p>
<p>

View file

@ -99,9 +99,9 @@ for notifications and will send the message to the other user. The other user wi
to a <i>MessageEventManager</i> that will listen and react to the event notification requested by the other user.
<blockquote>
<pre> <font color="#3f7f5f">// Connect to the server and log in the users</font>
conn1 = new XMPPConnection(host);
conn1 = new XMPPTCPConnection(host);
conn1.login(server_user1, pass1);
conn2 = new XMPPConnection(host);
conn2 = new XMPPTCPConnection(host);
conn2.login(server_user2, pass2);
<font color="#3f7f5f">// User2 creates a MessageEventManager</font>
@ -195,7 +195,7 @@ to a <i>MessageEventManager</i> that will listen and react to the event notifica
the requests for notifications and sends the message.
<blockquote>
<pre> <font color="#3f7f5f">// Connect to the server and log in</font>
conn1 = new XMPPConnection(host);
conn1 = new XMPPTCPConnection(host);
conn1.login(server_user1, pass1);
<font color="#3f7f5f">// Create a MessageEventManager</font>

View file

@ -39,7 +39,7 @@ the second parameter is the id of the user that will receive the roster entries.
In this example we can see how user1 sends his roster to user2.
<blockquote>
<pre> <font color="#3f7f5f">// Connect to the server and log in</font>
conn1 = new XMPPConnection(host);
conn1 = new XMPPTCPConnection(host);
conn1.login(server_user1, pass1);
<font color="#3f7f5f">// Create a new roster exchange manager on conn1</font>
@ -69,7 +69,7 @@ the second parameter is the id of the user that will receive the roster entries.
In this example we can see how user1 sends his roster groups to user2.
<blockquote>
<pre> <font color="#3f7f5f">// Connect to the server and log in</font>
conn1 = new XMPPConnection(host);
conn1 = new XMPPTCPConnection(host);
conn1.login(server_user1, pass1);
<font color="#3f7f5f">// Create a new roster exchange manager on conn1</font>
@ -100,7 +100,7 @@ the second parameter is the id of the user that will receive the roster entries.
In this example we can see how user1 sends a roster entry to user2.
<blockquote>
<pre> <font color="#3f7f5f">// Connect to the server and log in</font>
conn1 = new XMPPConnection(host);
conn1 = new XMPPTCPConnection(host);
conn1.login(server_user1, pass1);
<font color="#3f7f5f">// Create a new roster exchange manager on conn1</font>
@ -135,9 +135,9 @@ In this example we can see how user1 sends a roster entry to user2 and user2 add
entries to his roster.
<blockquote>
<pre> <font color="#3f7f5f">// Connect to the server and log in the users</font>
conn1 = new XMPPConnection(host);
conn1 = new XMPPTCPConnection(host);
conn1.login(server_user1, pass1);
conn2 = new XMPPConnection(host);
conn2 = new XMPPTCPConnection(host);
conn2.login(server_user2, pass2);
final Roster user2_roster = conn2.getRoster();

View file

@ -76,18 +76,19 @@ list of initializers.
Establishing a Connection
</p>
The <tt>XMPPConnection</tt> class is used to create a connection to an
XMPP server. Below are code examples for making a connection:<p>
The classes subclassing <tt>AbstractXMPPConnection</tt> are used to
create a connection to an XMPP server. Below are code examples for
making a connection:<p>
<div class="code">
<pre>
<font color="gray"><i>// Create a connection to the jabber.org server.</i></font>
Connection conn1 = <font color="navy"><b>new</b></font> XMPPConnection(<font color="green">"jabber.org"</font>);
AbstractXMPPConnection conn1 = <font color="navy"><b>new</b></font> XMPPTCPConnection(<font color="green">"jabber.org"</font>);
conn1.connect();
<font color="gray"><i>// Create a connection to the jabber.org server on a specific port.</i></font>
ConnectionConfiguration config = new ConnectionConfiguration(<font color="green">"jabber.org"</font>, 5222);
Connection conn2 = <font color="navy"><b>new</b></font> XMPPConnection(config);
AbstractXMPPConnection conn2 = <font color="navy"><b>new</b></font> XMPPTCPConnection(config);
conn2.connect();
</pre></div>
@ -97,7 +98,7 @@ conn2.connect();
<a href="connections.html">XMPPConnection Management</a> for full details.</p>
<p>Once you've created a connection, you should login using a username and password
with the <tt>XMPPConnection.login(String username, String password)</tt> method.
with the <tt>AbstractXMPPConnection.login(String username, String password)</tt> method.
Once you've logged in, you can being chatting with other users by creating
new <tt>Chat</tt> or <tt>GroupChat</tt> objects.
@ -130,7 +131,7 @@ and "out fishing":<p>
<font color="gray"><i>// Create a new presence. Pass in false to indicate we're unavailable.</i></font>
Presence presence = new Presence(Presence.Type.unavailable);
presence.setStatus(<font color="green">"Gone fishing"</font>);
<font color="gray"><i>// Send the packet (assume we have a XMPPConnection instance called "con").</i></font>
<font color="gray"><i>// Send the packet (assume we have a AbstractXMPPConnection instance called "con").</i></font>
con.sendPacket(presence);
</pre></div>
<p>

View file

@ -27,6 +27,7 @@ import java.util.logging.Logger;
import javax.security.sasl.SaslException;
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.SmackException.AlreadyLoggedInException;
@ -59,7 +60,7 @@ import org.igniterealtime.jbosh.ComposableBody;
* @see XMPPConnection
* @author Guenther Niess
*/
public class XMPPBOSHConnection extends XMPPConnection {
public class XMPPBOSHConnection extends AbstractXMPPConnection {
private static final Logger LOGGER = Logger.getLogger(XMPPBOSHConnection.class.getName());
/**

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,7 @@ package org.jivesoftware.smack;
/**
* Implementors of this interface will be notified when a new {@link XMPPConnection}
* has been created. The newly created connection will not be actually connected to
* the server. Use {@link XMPPConnection#addConnectionCreationListener(ConnectionCreationListener)}
* the server. Use {@link XMPPConnectionRegistry#addConnectionCreationListener(ConnectionCreationListener)}
* to add new listeners.
*
* @author Gaston Dombiak

View file

@ -17,8 +17,6 @@
package org.jivesoftware.smack;
import java.lang.ref.WeakReference;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public abstract class Manager {
@ -31,8 +29,4 @@ public abstract class Manager {
protected final XMPPConnection connection() {
return weakConnection.get();
}
protected ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
return connection().schedule(command, delay, unit);
}
}

View file

@ -39,7 +39,7 @@ public class ReconnectionManager extends AbstractConnectionListener {
private static final Logger LOGGER = Logger.getLogger(ReconnectionManager.class.getName());
// Holds the connection to the server
private XMPPConnection connection;
private final AbstractXMPPConnection connection;
private Thread reconnectionThread;
private int randomBase = new Random().nextInt(11) + 5; // between 5 and 15 seconds
@ -50,14 +50,16 @@ public class ReconnectionManager extends AbstractConnectionListener {
// Create a new PrivacyListManager on every established connection. In the init()
// method of PrivacyListManager, we'll add a listener that will delete the
// instance when the connection is closed.
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
connection.addConnectionListener(new ReconnectionManager(connection));
if (connection instanceof AbstractXMPPConnection) {
connection.addConnectionListener(new ReconnectionManager((AbstractXMPPConnection) connection));
}
}
});
}
private ReconnectionManager(XMPPConnection connection) {
private ReconnectionManager(AbstractXMPPConnection connection) {
this.connection = connection;
}

View file

@ -0,0 +1,64 @@
/**
*
* Copyright 2014 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
public class XMPPConnectionRegistry {
/**
* A set of listeners which will be invoked if a new connection is created.
*/
private final static Set<ConnectionCreationListener> connectionEstablishedListeners =
new CopyOnWriteArraySet<ConnectionCreationListener>();
/**
* Adds a new listener that will be notified when new Connections are created. Note
* that newly created connections will not be actually connected to the server.
*
* @param connectionCreationListener a listener interested on new connections.
*/
public static void addConnectionCreationListener(
ConnectionCreationListener connectionCreationListener) {
connectionEstablishedListeners.add(connectionCreationListener);
}
/**
* Removes a listener that was interested in connection creation events.
*
* @param connectionCreationListener a listener interested on new connections.
*/
public static void removeConnectionCreationListener(
ConnectionCreationListener connectionCreationListener) {
connectionEstablishedListeners.remove(connectionCreationListener);
}
/**
* Get the collection of listeners that are interested in connection creation events.
*
* @return a collection of listeners interested on new connections.
*/
protected static Collection<ConnectionCreationListener> getConnectionCreationListeners() {
return Collections.unmodifiableCollection(connectionEstablishedListeners);
}
}

View file

@ -49,7 +49,7 @@ import org.jivesoftware.smack.packet.Packet;
* @see XMPPConnection
* @author Guenther Niess
*/
public class DummyConnection extends XMPPConnection {
public class DummyConnection extends AbstractXMPPConnection {
private boolean authenticated = false;
private boolean anonymous = false;
@ -68,7 +68,7 @@ public class DummyConnection extends XMPPConnection {
public DummyConnection(ConnectionConfiguration configuration) {
super(configuration);
for (ConnectionCreationListener listener : getConnectionCreationListeners()) {
for (ConnectionCreationListener listener : XMPPConnectionRegistry.getConnectionCreationListeners()) {
listener.connectionCreated(this);
}
}

View file

@ -27,6 +27,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.IQReplyFilter;
@ -52,7 +53,7 @@ public class CarbonManager extends Manager {
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, CarbonManager>());
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
getInstanceFor(connection);
}

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.hoxt;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -37,7 +38,7 @@ public class HOXTManager {
public static final String NAMESPACE = "urn:xmpp:http";
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
@Override
public void connectionCreated(XMPPConnection connection) {
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(NAMESPACE);

View file

@ -20,6 +20,7 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.amp.packet.AMPExtension;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -39,7 +40,7 @@ public class AMPManager {
// Enable the AMP support on every established connection
// The ServiceDiscoveryManager class should have been already initialized
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
AMPManager.setServiceEnabled(connection, true);
}

View file

@ -30,6 +30,7 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -100,7 +101,7 @@ public class InBandBytestreamManager implements BytestreamManager {
* connection
*/
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(final XMPPConnection connection) {
// create the manager for this connection
InBandBytestreamManager.getByteStreamManager(connection);

View file

@ -35,6 +35,7 @@ import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
@ -93,7 +94,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
* connection
*/
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(final XMPPConnection connection) {
// create the manager for this connection

View file

@ -24,6 +24,7 @@ import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketInterceptor;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
@ -107,7 +108,7 @@ public class EntityCapsManager extends Manager {
private static final Cache<String, NodeVerHash> JID_TO_NODEVER_CACHE = new Cache<String, NodeVerHash>(10000, -1);
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
getInstanceFor(connection);
}

View file

@ -76,7 +76,7 @@ public class AdHocCommandManager extends Manager {
* related to that connection.
*/
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
getAddHocCommandsManager(connection);
}

View file

@ -22,6 +22,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
@ -79,7 +80,7 @@ public class ServiceDiscoveryManager extends Manager {
// Create a new ServiceDiscoveryManager on every established connection
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
getInstanceFor(connection);
}

View file

@ -26,6 +26,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter;
@ -104,7 +105,7 @@ public class LastActivityManager extends Manager {
// Enable the LastActivity support on every established connection
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
LastActivityManager.getInstanceFor(connection);
}

View file

@ -44,6 +44,7 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter;
@ -112,7 +113,7 @@ public class MultiUserChat {
private List<PacketListener> connectionListeners = new ArrayList<PacketListener>();
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(final XMPPConnection connection) {
// Set on every established connection that this client supports the Multi-User
// Chat protocol. This information will be used when another client tries to

View file

@ -34,6 +34,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter;
@ -69,7 +70,7 @@ public class PingManager extends Manager {
Pong.class), new IQTypeFilter(Type.RESULT));
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
getInstanceFor(connection);
}
@ -308,7 +309,7 @@ public class PingManager extends Manager {
int nextPingIn = pingInterval - delta;
LOGGER.fine("Scheduling ServerPingTask in " + nextPingIn + " seconds (pingInterval="
+ pingInterval + ", delta=" + delta + ")");
nextAutomaticPing = schedule(pingServerRunnable, pingInterval, TimeUnit.SECONDS);
nextAutomaticPing = connection().schedule(pingServerRunnable, pingInterval, TimeUnit.SECONDS);
}
}

View file

@ -29,6 +29,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter;
@ -68,7 +69,7 @@ public class PrivacyListManager extends Manager {
static {
// Create a new PrivacyListManager on every established connection.
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
getInstanceFor(connection);
}

View file

@ -28,6 +28,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.packet.Message;
@ -47,7 +48,7 @@ public class DeliveryReceiptManager extends Manager implements PacketListener {
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, DeliveryReceiptManager>());
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
getInstanceFor(connection);
}

View file

@ -25,6 +25,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.IQTypeFilter;
@ -45,7 +46,7 @@ public class EntityTimeManager extends Manager {
private static boolean autoEnable = true;
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
getInstanceFor(connection);
}

View file

@ -20,6 +20,7 @@ import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -28,7 +29,7 @@ public class VCardManager {
public static final String ELEMENT = "vCard";
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
@Override
public void connectionCreated(XMPPConnection connection) {
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(NAMESPACE);

View file

@ -21,6 +21,7 @@ import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -41,7 +42,7 @@ public class XHTMLManager {
// Enable the XHTML support on every established connection
// The ServiceDiscoveryManager class should have been already initialized
static {
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
XHTMLManager.setServiceEnabled(connection, true);
}

View file

@ -26,6 +26,7 @@ import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.RosterListener;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.IQ;
@ -258,7 +259,7 @@ public class JingleManager implements JingleSessionListener {
// Enable the Jingle support on every established connection
// The ServiceDiscoveryManager class should have been already
// initialized
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(XMPPConnection connection) {
JingleManager.setServiceEnabled(connection, true);
}

View file

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smack.tcp;
import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ConnectionListener;
@ -76,7 +77,7 @@ import java.util.logging.Logger;
* @see XMPPConnection
* @author Matt Tucker
*/
public class XMPPTCPConnection extends XMPPConnection {
public class XMPPTCPConnection extends AbstractXMPPConnection {
private static final Logger LOGGER = Logger.getLogger(XMPPTCPConnection.class.getName());
@ -890,11 +891,6 @@ public class XMPPTCPConnection extends XMPPConnection {
return super.getSASLAuthentication();
}
@Override
protected ConnectionConfiguration getConfiguration() {
return super.getConfiguration();
}
/**
* Sends a notification indicating that the connection was reconnected successfully.
*/

View file

@ -20,7 +20,6 @@ import static org.junit.Assert.*;
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.junit.Before;
import org.junit.Test;
@ -32,7 +31,7 @@ import org.junit.Test;
*/
public class RosterOfflineTest {
XMPPConnection connection;
XMPPTCPConnection connection;
Roster roster;