diff --git a/documentation/extensions/caps.html b/documentation/extensions/caps.html index 71e0e2f77..f22fa2ce3 100644 --- a/documentation/extensions/caps.html +++ b/documentation/extensions/caps.html @@ -33,7 +33,7 @@ Enable Entity Capabilities
// Get an instance of entity caps manager for the specified connection - Entity CapabilitiesManager mgr = new EntityCapsManager.getInstanceFor(con); + EntityCapsManager mgr = EntityCapsManager.getInstanceFor(connection); // Enable entity capabilities mgr.enableEntityCaps(); @@ -45,7 +45,7 @@ Configure a persistent cache for Entity Capabilities// Get an instance of entity caps manager for the specified connection - Entity CapabilitiesManager mgr = new EntityCapsManager.getInstanceFor(con); + EntityCapsManager mgr = EntityCapsManager.getInstanceFor(connection); // Create an cache, see smackx.entitycaps.cache for pre-defined cache implementations EntityCapsPersistentCache cache = new SimpleDirectoryPersistentCache(new File("/foo/cachedir")); diff --git a/source/org/jivesoftware/smackx/entitycaps/EntityCapsManager.java b/source/org/jivesoftware/smackx/entitycaps/EntityCapsManager.java index 1893288ab..afce78bbe 100644 --- a/source/org/jivesoftware/smackx/entitycaps/EntityCapsManager.java +++ b/source/org/jivesoftware/smackx/entitycaps/EntityCapsManager.java @@ -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); 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);