4 import org.opensrf.util.*;
6 import org.open_ils.idl.*;
7 import org.opensrf.util.*;
10 import java.util.HashMap;
11 import java.io.IOException;
16 private static IDLParser idlParser = null;
19 * Initializes the connection to the OpenSRF network and parses the IDL file.
20 * @param attrs A map of configuration attributes. Options include:<br/>
22 * <li>configFile - The OpenSRF core config file</li>
23 * <li>configContext - The path to the config chunk in the config XML, typically "opensrf"</li>
24 * <li>logProtocol - Currently supported option is "file".</li>
25 * <li>logLevel - The log level. Options are 1,2,3, or 4 (error, warn, info, debug)</li>
26 * <li>syslogFacility - For future use, when syslog is a supported log option</li>
27 * <li>idlFile - The path to the IDL file. May be relative or absolute. If this option is
28 * not provided, the system will ask the OpenSRF Settings server for the IDL file path.</li>
31 public static void init(Map<String, String> attrs) throws ConfigException, SessionException, IOException, IDLException {
33 String configFile = attrs.get("configFile");
34 String configContext = attrs.get("configContext");
35 String logProto = attrs.get("logProtocol");
36 String logFile = attrs.get("logFile");
37 String logLevel = attrs.get("logLevel");
38 String syslogFacility = attrs.get("syslogFacility");
39 String idlFile = attrs.get("idlFile");
42 if(idlParser != null) {
43 /** if we've parsed the IDL file, then all of the global setup has been done.
44 * We just need to verify this thread is connected to the OpenSRF network. */
45 org.opensrf.Sys.bootstrapClient(configFile, configContext);
49 /** initialize the logging infrastructure */
50 if("file".equals(logProto))
51 Logger.init(Short.parseShort(logLevel), new FileLogger(logFile));
53 if("syslog".equals(logProto))
54 throw new ConfigException("syslog not yet implemented");
56 /** connect to the opensrf network. */
57 org.opensrf.Sys.bootstrapClient(configFile, configContext);
59 /** Grab the IDL file setting if not explicitly provided */
61 SettingsClient client = SettingsClient.instance();
62 idlFile = client.getString("/IDL");
65 /** Parse the IDL if necessary */
66 idlParser = new IDLParser(idlFile);