mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Reworked OSGi support of Smack (SMACK-343)
Because of OSGi, no subproject of Smack (which is the same as a OSGi bundle) must export a package that is already exported by another subproject. Therefore it was necessary to move the TCP and BOSH code into their own packages: org.jivesoftware.smack.(tcp|bosh). OSGi classloader restrictions also made it necessary to create a Declarative Service for smack-extensions, smack-experimental and smack-lagacy (i.e. smack subprojects which should be initialized), in order to initialize them accordingly, as smack-core is, when used in a OSGi environment, unable to load and initialize classes from other smack bundles. OSGi's "Service Component Runtime" (SCR) will now take care of running the initialization code of the particular Smack bundle by activating its Declarative Service. That is also the reason why most initialization related method now have an additional classloader argument. Note that due the refactoring, some ugly changes in XMPPTCPConnection and its PacketReader and PacketWriter where necessary.
This commit is contained in:
parent
541b8b3798
commit
4c76f2652d
39 changed files with 413 additions and 446 deletions
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack;
|
||||
package org.jivesoftware.smack.bosh;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack;
|
||||
package org.jivesoftware.smack.bosh;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class BOSHPacketReader implements BOSHClientResponseListener {
|
|||
// The server supports sessions
|
||||
connection.serverSupportsSession();
|
||||
} else if (parser.getName().equals("register")) {
|
||||
AccountManager.getInstance(connection).setSupportsAccountCreation(true);
|
||||
connection.serverSupportsAccountCreation();
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("features")) {
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack;
|
||||
package org.jivesoftware.smack.bosh;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PipedReader;
|
||||
|
@ -27,9 +27,11 @@ import java.util.logging.Logger;
|
|||
|
||||
import javax.security.sasl.SaslException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.SmackException.AlreadyLoggedInException;
|
||||
import org.jivesoftware.smack.SmackException.ConnectionException;
|
||||
import org.jivesoftware.smack.SASLAuthentication;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
|
@ -137,7 +139,7 @@ public class XMPPBOSHConnection extends XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
void connectInternal() throws SmackException {
|
||||
protected void connectInternal() throws SmackException {
|
||||
if (connected) {
|
||||
throw new IllegalStateException("Already connected to a server.");
|
||||
}
|
||||
|
@ -267,7 +269,7 @@ public class XMPPBOSHConnection extends XMPPConnection {
|
|||
if (response != null) {
|
||||
this.user = response;
|
||||
// Update the serviceName with the one returned by the server
|
||||
config.setServiceName(StringUtils.parseServer(response));
|
||||
setServiceName(StringUtils.parseServer(response));
|
||||
} else {
|
||||
this.user = username + "@" + getServiceName();
|
||||
if (resource != null) {
|
||||
|
@ -285,7 +287,7 @@ public class XMPPBOSHConnection extends XMPPConnection {
|
|||
anonymous = false;
|
||||
|
||||
// Stores the autentication for future reconnection
|
||||
config.setLoginInfo(username, password, resource);
|
||||
setLoginInfo(username, password, resource);
|
||||
|
||||
// If debugging is enabled, change the the debug window title to include
|
||||
// the
|
||||
|
@ -316,7 +318,7 @@ public class XMPPBOSHConnection extends XMPPConnection {
|
|||
// Set the user value.
|
||||
this.user = response;
|
||||
// Update the serviceName with the one returned by the server
|
||||
config.setServiceName(StringUtils.parseServer(response));
|
||||
setServiceName(StringUtils.parseServer(response));
|
||||
|
||||
// Set presence to online.
|
||||
if (config.isSendPresence()) {
|
||||
|
@ -337,7 +339,8 @@ public class XMPPBOSHConnection extends XMPPConnection {
|
|||
callConnectionAuthenticatedListener();
|
||||
}
|
||||
|
||||
void sendPacketInternal(Packet packet) throws NotConnectedException {
|
||||
@Override
|
||||
protected void sendPacketInternal(Packet packet) throws NotConnectedException {
|
||||
if (done) {
|
||||
throw new NotConnectedException();
|
||||
}
|
||||
|
@ -508,6 +511,30 @@ public class XMPPBOSHConnection extends XMPPConnection {
|
|||
callConnectionClosedOnErrorListener(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processPacket(Packet packet) {
|
||||
super.processPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SASLAuthentication getSASLAuthentication() {
|
||||
return super.getSASLAuthentication();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void serverRequiresBinding() {
|
||||
super.serverRequiresBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void serverSupportsSession() {
|
||||
super.serverSupportsSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void serverSupportsAccountCreation() {
|
||||
super.serverSupportsAccountCreation();
|
||||
}
|
||||
|
||||
/**
|
||||
* A listener class which listen for a successfully established connection
|
Loading…
Add table
Add a link
Reference in a new issue