diff options
| author | ogattaz <olivier@gattaz.com> | 2014-07-07 10:59:14 +0200 |
|---|---|---|
| committer | ogattaz <olivier@gattaz.com> | 2014-07-07 10:59:14 +0200 |
| commit | 6772bfb46b72d859c316a9f6573d0c6be477ad5c (patch) | |
| tree | dafa343584216685e68b6edae37570eb97cf9d0c /src/main/java/com/c2kernel/process/Gateway.java | |
| parent | 2fd193d7936084de91eae46e8c2763914d87ab71 (diff) | |
| parent | 0b689a787288f5a4ba568157905c3a0577f83821 (diff) | |
Merge branch 'master' of ssh://dev.cccs.uwe.ac.uk:22/var/git/cristal-kernel
Diffstat (limited to 'src/main/java/com/c2kernel/process/Gateway.java')
| -rw-r--r-- | src/main/java/com/c2kernel/process/Gateway.java | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 2db7aa1..7a040ac 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -9,6 +9,7 @@ import java.net.MalformedURLException; import java.util.Enumeration;
import java.util.Properties;
+import com.c2kernel.common.CannotManageException;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.CorbaServer;
@@ -17,6 +18,7 @@ import com.c2kernel.entity.proxy.ProxyManager; import com.c2kernel.entity.proxy.ProxyServer;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.Lookup;
+import com.c2kernel.lookup.LookupManager;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.NextKeyManager;
import com.c2kernel.persistency.TransactionManager;
@@ -58,6 +60,7 @@ public class Gateway static private org.omg.CORBA.ORB mORB;
static private boolean orbDestroyed = false;
static private Lookup mLookup;
+ static private LookupManager mLookupManager = null;
static private NextKeyManager mNextKeyManager;
static private TransactionManager mStorage;
static private ProxyManager mProxyManager;
@@ -111,7 +114,7 @@ public class Gateway // init module manager
try {
- mModules = new ModuleManager(mResource.getModuleDefURLs(), AbstractMain.runningAsWrapper);
+ mModules = new ModuleManager(mResource.getModuleDefURLs(), AbstractMain.isServer);
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("Could not load module definitions.", "");
@@ -145,13 +148,20 @@ public class Gateway *
* @throws InvalidDataException - error initialising
*/
- static public void startServer() throws InvalidDataException {
+ static public void startServer(Authenticator auth) throws InvalidDataException, CannotManageException {
try {
// check top level directory contexts
- mLookup.initializeDirectory();
+ if (mLookup instanceof LookupManager) {
+ mLookupManager = (LookupManager)mLookup;
+ mLookupManager.initializeDirectory();
+ }
+ else {
+ throw new CannotManageException("Lookup implementation is not a LookupManager. Cannot write to directory");
+ }
// init next key manager
mNextKeyManager = (NextKeyManager)mC2KProps.getInstance("NextKeyManager");
+ mNextKeyManager.open(auth);
// start entity proxy server
mProxyServer = new ProxyServer(mC2KProps.getProperty("ItemServer.name"));
@@ -165,7 +175,8 @@ public class Gateway //TODO: externalize this (or replace corba completely)
mC2KProps.put("com.sun.CORBA.POA.ORBServerId", "1");
mC2KProps.put("com.sun.CORBA.POA.ORBPersistentServerPort", serverPort);
-
+ mC2KProps.put("com.sun.CORBA.codeset.charsets", "0x05010001, 0x00010109"); // need to force UTF-8 in the Sun ORB
+ mC2KProps.put("com.sun.CORBA.codeset.wcharsets", "0x00010109, 0x05010001");
//Standard initialisation of the ORB
mORB = org.omg.CORBA.ORB.init(new String[0], mC2KProps);
@@ -196,7 +207,7 @@ public class Gateway * @throws InvalidDataException - bad params
* @throws ClusterStorageException - error starting storages
*/
- static public void connect()
+ static public Authenticator connect()
throws InvalidDataException,
ClusterStorageException
{
@@ -210,6 +221,7 @@ public class Gateway mStorage = new TransactionManager(auth);
mProxyManager = new ProxyManager();
+ return auth;
} catch (Exception ex) {
Logger.error(ex);
throw new InvalidDataException("Cannot connect server process. Please check config.", "");
@@ -254,6 +266,12 @@ public class Gateway return userProxy;
}
+
+ static public AgentProxy connect(String agentName, String agentPassword)
+ throws InvalidDataException, ObjectNotFoundException, ClusterStorageException, InstantiationException, IllegalAccessException, ClassNotFoundException
+ {
+ return connect(agentName, agentPassword, null);
+ }
/**
* Shuts down all kernel api objects
@@ -299,8 +317,12 @@ public class Gateway static public org.omg.CORBA.ORB getORB()
{
if (orbDestroyed) throw new RuntimeException("Gateway has been closed. ORB is destroyed.");
- if (mORB == null)
+
+ if (mORB == null) {
+ mC2KProps.put("com.sun.CORBA.codeset.charsets", "0x05010001, 0x00010109"); // need to force UTF-8 in the Sun ORB
+ mC2KProps.put("com.sun.CORBA.codeset.wcharsets", "0x00010109, 0x05010001");
mORB = org.omg.CORBA.ORB.init(new String[0], mC2KProps);
+ }
return mORB;
}
@@ -309,6 +331,14 @@ public class Gateway return mLookup;
}
+ static public LookupManager getLookupManager() throws CannotManageException
+ {
+ if (mLookupManager == null)
+ throw new CannotManageException("No Lookup Manager created. Not a server process.", "");
+ else
+ return mLookupManager;
+ }
+
static public CorbaServer getCorbaServer()
{
return mCorbaServer;
|
