1 package org.opensrf.util;
6 * Connects to the OpenSRF Settings server to fetch the settings config.
7 * Provides a Config interface for fetching settings via path
9 public class SettingsClient extends Config {
11 /** Singleton SettingsClient instance */
12 private static SettingsClient client = new SettingsClient();
14 public SettingsClient() {
19 * @return The global settings client instance
21 public static SettingsClient instance() throws ConfigException {
22 if(client.getConfigObject() == null)
28 * Fetches the settings object from the settings server
30 private void fetchConfig() throws ConfigException {
32 ClientSession ses = new ClientSession("opensrf.settings");
35 Request req = ses.request(
36 "opensrf.settings.host_config.get",
37 new String[]{(String)Config.global().getFirst("/domain")});
39 Result res = req.recv(12000);
41 /** throw exception */
43 setConfigObject((Map) res.getContent());
45 } catch(Exception e) {
46 throw new ConfigException("Error fetching settings config", e);