31 lines
1.0 KiB
Java
31 lines
1.0 KiB
Java
package org.mercury_im.messenger.transport.xmpp;
|
|
|
|
import org.jivesoftware.smack.ConnectionConfiguration;
|
|
import org.jivesoftware.smack.XMPPConnection;
|
|
import org.mercury_im.messenger.Messenger;
|
|
import org.mercury_im.messenger.transport.connection.ConnectionFactory;
|
|
import org.mercury_im.messenger.entity.Account;
|
|
|
|
public abstract class XmppConnectionFactory<CF extends ConnectionConfiguration>
|
|
implements ConnectionFactory<XmppTcpConnectionMethod> {
|
|
|
|
protected final Messenger messenger;
|
|
|
|
public XmppConnectionFactory(Messenger messenger) {
|
|
this.messenger = messenger;
|
|
}
|
|
|
|
public Messenger getMessenger() {
|
|
return messenger;
|
|
}
|
|
|
|
@Override
|
|
public XmppTcpConnectionMethod provideConnection(Account account) {
|
|
return new XmppTcpConnectionMethod(account, getMessenger(), createXmppConnection(getConfiguration(account)));
|
|
}
|
|
|
|
protected abstract CF getConfiguration(Account account);
|
|
|
|
protected abstract XMPPConnection createXmppConnection(CF connectionConfiguration);
|
|
}
|