summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/process/Gateway.java
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/process/Gateway.java')
-rw-r--r--source/com/c2kernel/process/Gateway.java77
1 files changed, 45 insertions, 32 deletions
diff --git a/source/com/c2kernel/process/Gateway.java b/source/com/c2kernel/process/Gateway.java
index 3a03088..f399351 100644
--- a/source/com/c2kernel/process/Gateway.java
+++ b/source/com/c2kernel/process/Gateway.java
@@ -5,8 +5,8 @@ package com.c2kernel.process;
* @author $Author: abranson $
*/
+import java.io.IOException;
import java.net.MalformedURLException;
-import java.net.URL;
import java.util.Enumeration;
import java.util.Properties;
@@ -51,6 +51,7 @@ import com.c2kernel.utils.server.SimpleTCPIPServer;
public class Gateway
{
static private Properties mC2KProps;
+ static private ModuleManager mModules;
static private org.omg.CORBA.ORB mORB;
static private LDAPLookup mLDAPLookup;
static private TransactionManager mStorage;
@@ -59,6 +60,7 @@ public class Gateway
static private SimpleTCPIPServer mHTTPServer;
+
private Gateway() { }
/**
@@ -69,18 +71,21 @@ public class Gateway
* If null, the java system properties are used
* @throws InvalidDataException - invalid properties caused a failure in initialisation
*/
- static public void init(Properties props) throws InvalidDataException {
+ static public void init(Properties props, boolean isServer) throws InvalidDataException {
+
// if supplied props are null, use system props
if (props == null) props = System.getProperties();
- // set resource URLs from config
- String resURL = props.getProperty("KernelResourceURL");
- if (resURL != null && resURL.length()>0)
- Resource.setKernelBaseURL(resURL);
-
- resURL = props.getProperty("DomainResourceURL");
- if (resURL != null && resURL.length()>0)
- Resource.setDomainBaseURL(resURL);
+ // report version info
+ Logger.msg("Kernel version: "+Resource.getKernelVersion());
+
+ // init module manager
+ try {
+ mModules = new ModuleManager(ClassLoader.getSystemResources("module.xml"), isServer);
+ } catch (IOException e) {
+ Logger.error(e);
+ throw new InvalidDataException("Could not load module definitions. Classpath problem", "");
+ }
// Start with default props from kernel jar
try {
@@ -88,6 +93,13 @@ public class Gateway
} catch (MalformedURLException ex) {
Logger.die("Default properties not found. Probable cause is missing resources");
}
+
+ // merge in module props
+ Properties moduleProperties = mModules.getAllModuleProperties();
+ for (Enumeration<?> e = moduleProperties.propertyNames(); e.hasMoreElements();) {
+ String propName = (String)e.nextElement();
+ mC2KProps.put(propName, moduleProperties.get(propName));
+ }
// Overwrite with supplied props
for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) {
@@ -98,15 +110,9 @@ public class Gateway
// dump properties
dumpC2KProps(7);
- // report version info
- Logger.msg("Domain version: "+Resource.getDomainVersion());
- Logger.msg("Kernel version: "+Resource.getKernelVersion());
-
- // load kernel and domain mapfiles
+ // load kernel mapfiles
try {
CastorXMLUtility.loadMapsFrom(Resource.getKernelResourceURL("mapFiles/"));
- if (Resource.getDomainBaseURL()!=null)
- CastorXMLUtility.loadMapsFrom(Resource.getDomainResourceURL("mapFiles/"));
} catch (MalformedURLException e1) {
throw new InvalidDataException("Invalid Resource Location", "");
}
@@ -117,12 +123,9 @@ public class Gateway
Language.isTranlated=true;
Language.mTableOfTranslation = FileStringUtility.loadLanguageFile(languageFile);
}
-
- try {
- Resource.setImportURL(new URL("file:"+getProperty("Import.dir")));
- } catch (MalformedURLException e) {
- Logger.error("Import directory not set. "+getProperty("Import.dir"));
- }
+
+ // run module startup scripts
+ mModules.runScripts("startup");
}
/**
@@ -162,25 +165,32 @@ public class Gateway
// start checking bootstrap items
Bootstrap.run();
+ // register modules
+ mModules.registerModules();
+
} catch (Exception ex) {
Logger.error(ex);
Logger.die("Exception starting server components. Shutting down.");
}
// start the http server
- try {
- int httpPort = Integer.parseInt(Gateway.getProperty("ItemServer.HTTP.port"));
- Logger.msg(2, "Starting HTTP Server on port "+httpPort);
- mHTTPServer = new SimpleTCPIPServer(httpPort, ItemHTTPBridge.class, 5);
- mHTTPServer.startListening();
- } catch (NumberFormatException ex) {
- Logger.msg(3, "Invalid or no HTTP port defined. HTTP server not available.");
- }
+// try {
+// int httpPort = Integer.parseInt(Gateway.getProperty("ItemServer.HTTP.port"));
+// Logger.msg(2, "Starting HTTP Server on port "+httpPort);
+// mHTTPServer = new SimpleTCPIPServer(httpPort, ItemHTTPBridge.class, 5);
+// mHTTPServer.startListening();
+// } catch (NumberFormatException ex) {
+// Logger.msg(3, "Invalid or no HTTP port defined. HTTP server not available.");
+// }
System.out.println("Server '"+Gateway.getCentreId()+"' initialised.");
}
- /**
+ public static ModuleManager getModuleManager() {
+ return mModules;
+ }
+
+ /**
* Connects to the LDAP server in an administrative context - using the admin username and
* password given in the LDAP.user and LDAP.password props of the kernel properties.
*
@@ -327,6 +337,9 @@ public class Gateway
*/
public static void close()
{
+ // run shutdown module scripts
+ mModules.runScripts("shutdown");
+
// shut down servers if running
if (mCorbaServer != null)
mCorbaServer.close();