1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-26 06:07:59 +01:00

SMACK-361 Minor EntityCapsManager fixes

Don't use the constructor in ConnectionCreationListener to prevent
duplicate instances for the same connection. Fixed EntityCaps
documentation.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_2@13799 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-11-03 21:49:39 +00:00 committed by flow
parent 84e1f32284
commit 0e6817dc4f
2 changed files with 4 additions and 15 deletions

View file

@ -33,7 +33,7 @@ Enable Entity Capabilities
<blockquote>
<pre>
<font color="#3f7f5f">// Get an instance of entity caps manager for the specified connection</font>
Entity CapabilitiesManager mgr = new EntityCapsManager.getInstanceFor(con);
EntityCapsManager mgr = EntityCapsManager.getInstanceFor(connection);
<font color="#3f7f5f">// Enable entity capabilities</font>
mgr.enableEntityCaps();
@ -45,7 +45,7 @@ Configure a persistent cache for Entity Capabilities
<blockquote>
<pre>
<font color="#3f7f5f">// Get an instance of entity caps manager for the specified connection</font>
Entity CapabilitiesManager mgr = new EntityCapsManager.getInstanceFor(con);
EntityCapsManager mgr = EntityCapsManager.getInstanceFor(connection);
<font color="#3f7f5f">// Create an cache, see smackx.entitycaps.cache for pre-defined cache implementations</font>
EntityCapsPersistentCache cache = new SimpleDirectoryPersistentCache(new File("/foo/cachedir"));

View file

@ -99,8 +99,7 @@ public class EntityCapsManager {
static {
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(Connection connection) {
if (connection instanceof XMPPConnection)
new EntityCapsManager(connection);
getInstanceFor(connection);
}
});
@ -225,11 +224,6 @@ public class EntityCapsManager {
private EntityCapsManager(Connection connection) {
this.weakRefConnection = new WeakReference<Connection>(connection);
this.sdm = ServiceDiscoveryManager.getInstanceFor(connection);
init();
}
private void init() {
Connection connection = weakRefConnection.get();
instances.put(connection, this);
connection.addConnectionListener(new ConnectionListener() {
@ -326,13 +320,8 @@ public class EntityCapsManager {
}
public static synchronized EntityCapsManager getInstanceFor(Connection connection) {
// For testing purposed forbid EntityCaps for non XMPPConnections
// it may work on BOSH connections too
if (!(connection instanceof XMPPConnection))
return null;
if (SUPPORTED_HASHES.size() <= 0)
return null;
throw new IllegalStateException("No supported hashes for EntityCapsManager");
EntityCapsManager entityCapsManager = instances.get(connection);