3 import org.opensrf.util.*;
4 import org.opensrf.net.xmpp.*;
10 * Connects to the OpenSRF network so that client sessions may communicate.
11 * @param configFile The OpenSRF config file
12 * @param configContext Where in the XML document the config chunk lives. This
13 * allows an OpenSRF client config chunk to live in XML files where other config
16 public static void bootstrapClient(String configFile, String configContext)
17 throws ConfigException, SessionException {
19 /** create the config parser */
20 Config config = new Config(configContext);
21 config.parse(configFile);
22 Config.setConfig(config); /* set this as the global config */
24 /** Collect the network connection info from the config */
25 String username = config.getString("/username");
26 String passwd = config.getString("/passwd");
27 String host = (String) config.getFirst("/domains/domain");
28 int port = config.getInt("/port");
31 /** Connect to the Jabber network */
32 XMPPSession xses = new XMPPSession(host, port);
33 xses.connect(username, passwd, "test-java"); /* XXX */
34 XMPPSession.setGlobalSession(xses);
35 } catch(XMPPException e) {
36 throw new SessionException("Unable to bootstrap client", e);
41 * Shuts down the connection to the opensrf network
43 public static void shutdown() {
44 XMPPSession.getGlobalSession().disconnect();