diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-01-23 12:09:30 +0100 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-01-23 12:09:30 +0100 |
| commit | 8256917551c259df2b7e69e32cd74497e5394786 (patch) | |
| tree | 068ec6e5acf41aabeb1538c6731c8e8f70d1ddb1 /src/main/java/com/c2kernel/process/Gateway.java | |
| parent | 428d828ca640d1348979f9982d1c0bc0a489a3b4 (diff) | |
Refactored Resource into a new ResourceLoader interface, which allows
CRISTAL processes in other enviroments with complex class loading (e.g.
OSGi) to supply their own resource and class loader to the kernel and
its modules. Fixes #149
Diffstat (limited to 'src/main/java/com/c2kernel/process/Gateway.java')
| -rw-r--r-- | src/main/java/com/c2kernel/process/Gateway.java | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 53fa36f..b57e91b 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -20,11 +20,12 @@ import com.c2kernel.lookup.LDAPProperties; import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.TransactionManager;
import com.c2kernel.process.module.ModuleManager;
+import com.c2kernel.process.resource.Resource;
+import com.c2kernel.process.resource.ResourceLoader;
import com.c2kernel.utils.CastorXMLUtility;
import com.c2kernel.utils.FileStringUtility;
import com.c2kernel.utils.Language;
import com.c2kernel.utils.Logger;
-import com.c2kernel.utils.Resource;
/**************************************************************************
@@ -59,6 +60,7 @@ public class Gateway static private CorbaServer mCorbaServer;
static private CastorXMLUtility mMarshaller;
static private AgentProxy mCurrentUser = null;
+ static private ResourceLoader mResource;
@@ -73,17 +75,32 @@ public class Gateway * @throws InvalidDataException - invalid properties caused a failure in initialisation
*/
static public void init(Properties props) throws InvalidDataException {
+ init(props, null);
+ }
+
+ /**
+ * Initialises the Gateway and all of the client objects it holds, with
+ * the exception of the LDAPLookup, which is initialised during connect()
+ *
+ * @param props - java.util.Properties containing all application properties.
+ * If null, the java system properties are used
+ * @param res - ResourceLoader for the kernel to use to resolve all class resource requests
+ * such as for bootstrap descriptions and version information
+ * @throws InvalidDataException - invalid properties caused a failure in initialisation
+ */
+ static public void init(Properties props, ResourceLoader res) throws InvalidDataException {
// Init properties & resources
mC2KProps = new Properties();
- Resource.initKernelBaseURL();
+ mResource = res;
+ if (mResource == null) mResource = new Resource();
// report version info
- Logger.msg("Kernel version: "+Resource.getKernelVersion());
+ Logger.msg("Kernel version: "+getKernelVersion());
// load kernel mapfiles
try {
- mMarshaller = new CastorXMLUtility(Resource.getKernelResourceURL("mapFiles/"));
+ mMarshaller = new CastorXMLUtility(mResource.getKernelResourceURL("mapFiles/"));
} catch (MalformedURLException e1) {
throw new InvalidDataException("Invalid Resource Location", "");
}
@@ -381,6 +398,11 @@ public class Gateway {
return mMarshaller;
}
+
+ static public ResourceLoader getResource()
+ {
+ return mResource;
+ }
static public EntityProxyManager getProxyManager()
{
@@ -417,5 +439,15 @@ public class Gateway Logger.msg(" "+name+": "+getProperty(name));
}
}
+
+
+ static public String getKernelVersion() {
+ try {
+ return mResource.getTextResource(null, "textFiles/version.txt");
+ } catch (Exception ex) {
+ return "No version info found";
+ }
+
+ }
}
|
