public Sequence eval( Sequence[] args, Sequence contextSequence ) throws XPathException
{
Properties props = ModuleUtils.parseProperties( ((NodeValue) args[0].itemAt(0)).getNode() );
ProxyInfo proxy;
ConnectionConfiguration config;
if (props.containsKey("proxy.type")){
ProxyType type = ProxyType.valueOf(props.getProperty("proxy.type"));
String host = props.getProperty("proxy.host");
int port = new Integer(props.getProperty("proxy.port")).intValue();
String user = props.getProperty("proxy.user");
String passwd = props.getProperty("proxy.password");
proxy = new ProxyInfo(type, host, port, user, passwd);
} else proxy = null;
String service = props.getProperty("xmpp.service");
String host = props.getProperty("xmpp.host");
String tmp = props.getProperty("xmpp.port");
int port = tmp == null ? 5222 : new Integer(tmp).intValue();
if (proxy == null){
if (host == null)
config = new ConnectionConfiguration(service);
else if (service == null)
config = new ConnectionConfiguration(host, port);
else config = new ConnectionConfiguration(host, port, service);
} else {
if (host == null)
config = new ConnectionConfiguration(service, proxy);
else if (service == null)
config = new ConnectionConfiguration(host, port, proxy);
else config = new ConnectionConfiguration(host, port, service, proxy);
}
XMPPConnection connection = new XMPPConnection(config);
// store the connection and return the handle of the connection