in bindings/servicemix-xmpp/src/main/java/org/apache/servicemix/xmpp/XMPPSenderEndpoint.java [86:155]
public void start() throws Exception {
super.start();
// create a proxy info object if needed
if (this.proxyInfo == null && XMPPConstants.isSet(this.proxyHost)) {
ProxyInfo.ProxyType pType = null;
if (XMPPConstants.isSet(this.proxyType)) {
pType = ProxyInfo.ProxyType.valueOf(this.proxyType.toUpperCase());
}
this.proxyInfo = new ProxyInfo(pType,
this.proxyHost,
XMPPConstants.isSet(this.proxyPort) ? Integer.parseInt(this.proxyPort) : XMPPConstants.DEFAULT_PROXY_PORT,
this.proxyUser,
this.proxyPass);
}
// create the connection config
if (this.connectionConfig == null) {
if (this.proxyInfo != null) {
this.connectionConfig = new ConnectionConfiguration(this.host, this.port, this.proxyInfo);
} else {
this.connectionConfig = new ConnectionConfiguration(this.host, this.port);
}
this.connectionConfig.setCompressionEnabled(true);
this.connectionConfig.setReconnectionAllowed(true);
this.connectionConfig.setSASLAuthenticationEnabled(true);
}
if (this.connection == null) {
this.connection = new XMPPConnection(this.connectionConfig);
this.logger.debug("Connecting to server {}", this.host);
this.connection.connect();
}
if (this.login && !this.connection.isAuthenticated()) {
if (this.user != null) {
this.logger.debug("Logging into Jabber as user: {} on connection: {}", this.user, this.connection);
if (this.password == null) {
this.logger.warn("No password configured for user: {}", this.user);
}
if (this.createAccount) {
AccountManager accountManager = new AccountManager(this.connection);
accountManager.createAccount(this.user, this.password);
}
if (this.resource != null) {
this.connection.login(this.user, this.password, this.resource);
} else {
this.connection.login(this.user, this.password);
}
} else {
this.logger.debug("Logging in anonymously to Jabber on connection: {}", this.connection);
this.connection.loginAnonymously();
}
// now lets send a presence we are available
this.connection.sendPacket(new Presence(Presence.Type.available));
}
// now register listener for new packets
if (this.connection != null && this.connection.isConnected()) {
// if the user specified a chat room to join we do this here
if (this.room != null) {
this.chatRoom = new MultiUserChat(this.connection, this.room);
this.chatRoom.join(this.user);
} else if (this.participant != null) {
this.userChat = this.connection.getChatManager().createChat(this.participant, null);
}
}
}