private void connectUsingFactory(ConnectionConfigurationFactory factory) throws FriendException {
   ConnectionConfigurationFactory.RequestContext requestContext =
       new ConnectionConfigurationFactory.RequestContext();
   while (factory.hasMore(configuration, requestContext)) {
     ConnectionConfiguration connectionConfig =
         factory.getConnectionConfiguration(configuration, requestContext);
     connection = new XMPPConnection(connectionConfig);
     connection.addRosterListener(new RosterListenerImpl());
     LOG.infof(
         "connecting to {0} at {1}:{2} ...",
         connectionConfig.getServiceName(),
         connectionConfig.getHost(),
         connectionConfig.getPort());
     try {
       connection.connect();
       return;
     } catch (org.jivesoftware.smack.XMPPException e) {
       LOG.debug(e.getMessage(), e);
       requestContext.incrementRequests();
     }
   }
   throw new FriendException("couldn't connect using " + factory);
 }
示例#2
0
 /**
  * Returns the name of the service provided by the XMPP server for this connection. This is also
  * called XMPP domain of the connected server. After authenticating with the server the returned
  * value may be different.
  *
  * @return the name of the service provided by the XMPP server.
  */
 public String getServiceName() {
   return config.getServiceName();
 }