From baf9db9d6ec33bdcf054f5bd943ea7b148e4931a Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 30 Aug 2007 19:10:47 +0000 Subject: [PATCH] added a top-level init method to connect and parse the IDL git-svn-id: svn://svn.open-ils.org/ILS/trunk@7752 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/java/org/open_ils/Sys.java | 55 +++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Open-ILS/src/java/org/open_ils/Sys.java diff --git a/Open-ILS/src/java/org/open_ils/Sys.java b/Open-ILS/src/java/org/open_ils/Sys.java new file mode 100644 index 0000000000..ad93a92741 --- /dev/null +++ b/Open-ILS/src/java/org/open_ils/Sys.java @@ -0,0 +1,55 @@ +package org.open_ils; + +import org.opensrf.*; +import org.opensrf.util.*; +import org.open_ils.*; +import org.open_ils.idl.*; +import org.opensrf.util.*; + +import java.util.Map; +import java.util.HashMap; +import java.io.IOException; + + +public class Sys { + + private static IDLParser idlParser = null; + + public static void init(Map attrs) throws ConfigException, SessionException, IOException, IDLException { + + String configFile = attrs.get("configFile"); + String configContext = attrs.get("configContext"); + String logProto = attrs.get("logProtocol"); + String logFile = attrs.get("logFile"); + String logLevel = attrs.get("logLevel"); + String syslogFacility = attrs.get("syslogFacility"); + + + if(idlParser != null) { + /** if we've parsed the IDL file, then all of the global setup has been done. + * We just need to verify this thread is connected to the OpenSRF network. */ + org.opensrf.Sys.bootstrapClient(configFile, configContext); + return; + } + + /** initialize the logging infrastructure */ + if("file".equals(logProto)) + Logger.init(Short.parseShort(logLevel), new FileLogger(logFile)); + + if("syslog".equals(logProto)) + throw new ConfigException("syslog not yet implemented"); + + /** connect to the opensrf network. */ + org.opensrf.Sys.bootstrapClient(configFile, configContext); + + /** Grab the IDL file setting */ + SettingsClient client = SettingsClient.instance(); + String idlFile = client.getString("/IDL"); + + + /** Parse the IDL if necessary */ + idlParser = new IDLParser(idlFile); + idlParser.parse(); + } +} + -- 2.11.0