diff options
Diffstat (limited to 'java/src')
-rwxr-xr-x | java/src/IceGrid/Model.java | 140 | ||||
-rwxr-xr-x | java/src/IceGrid/SessionKeeper.java | 70 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/Root.java | 4 |
3 files changed, 143 insertions, 71 deletions
diff --git a/java/src/IceGrid/Model.java b/java/src/IceGrid/Model.java index 5f7addd4ede..92faec2a7d7 100755 --- a/java/src/IceGrid/Model.java +++ b/java/src/IceGrid/Model.java @@ -654,7 +654,7 @@ public class Model _writeSerial = -1;
}
- boolean login(SessionKeeper.LoginInfo info, Component parent)
+ SessionPrx login(SessionKeeper.LoginInfo info, Component parent)
{
_root.clear();
_newApplication.setEnabled(false);
@@ -695,38 +695,116 @@ public class Model "Failed to recreate the communicator: " + e.toString(),
"Login failed",
JOptionPane.ERROR_MESSAGE);
- return false;
+ return null;
}
}
- //
- // Default locator
- //
- Ice.LocatorPrx defaultLocator = null;
+ SessionPrx session = null;
+ String str = "";
- String str = info.registryInstanceName + "/Locator";
- if(!info.registryEndpoints.equals(""))
- {
- str += ":" + info.registryEndpoints;
- }
+ _communicator.setDefaultRouter(null);
+ _communicator.setDefaultLocator(null);
try
{
- defaultLocator = Ice.LocatorPrxHelper.
- checkedCast(_communicator.stringToProxy(str));
- _communicator.setDefaultLocator(defaultLocator);
-
//
- // Session manager
+ // Default router
//
- str = info.registryInstanceName + "/SessionManager";
-
- _sessionManager = SessionManagerPrxHelper.
- checkedCast(_communicator.stringToProxy(str));
+ if(info.useGlacier)
+ {
+ str = info.routerInstanceName + "/router";
+ if(!info.routerEndpoints.equals(""))
+ {
+ str += ":" + info.routerEndpoints;
+ }
+ Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.
+ uncheckedCast(_communicator.stringToProxy(str));
+
+ //
+ // The session must be routed through this router
+ //
+ _communicator.setDefaultRouter(router);
+ try
+ {
+ Glacier2.SessionPrx s =
+ router.createSession(
+ info.username, new String(info.password));
+
+ System.err.println(s.toString());
+ session = SessionPrxHelper.checkedCast(s);
+ }
+ catch(Glacier2.PermissionDeniedException e)
+ {
+ JOptionPane.showMessageDialog(parent,
+ "Permission denied: "
+ + e.reason,
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ catch(Glacier2.CannotCreateSessionException e)
+ {
+ JOptionPane.showMessageDialog(parent,
+ "Could not create session: "
+ + e.reason,
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(parent,
+ "Could not create session: "
+ + e.toString(),
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ }
+ else
+ {
+ //
+ // The client uses the locator only without routing
+ //
+
+ str = info.registryInstanceName + "/Locator";
+ if(!info.registryEndpoints.equals(""))
+ {
+ str += ":" + info.registryEndpoints;
+ }
+
+ Ice.LocatorPrx defaultLocator = Ice.LocatorPrxHelper.
+ checkedCast(_communicator.stringToProxy(str));
+ _communicator.setDefaultLocator(defaultLocator);
+
+ //
+ // Local session
+ //
+ str = info.registryInstanceName + "/SessionManager";
+
+ SessionManagerPrx sessionManager = SessionManagerPrxHelper.
+ uncheckedCast(_communicator.stringToProxy(str));
+
+ try
+ {
+ session = sessionManager.createLocalSession(info.username);
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(parent,
+ "Could not create session: "
+ + e.toString(),
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ }
//
// Admin
//
+
+ // TODO: getAdmin from Session instead
str = info.registryInstanceName + "/Admin";
_admin = AdminPrxHelper.
@@ -734,19 +812,31 @@ public class Model }
catch(Ice.LocalException e)
{
+ if(session != null)
+ {
+ try
+ {
+ System.err.println("Destroying session");
+ session.destroy();
+ }
+ catch(Ice.LocalException le)
+ {
+ System.err.println(le.toString());
+ }
+ }
JOptionPane.showMessageDialog(
parent,
"Could not contact '" + str + "': " + e.toString(),
"Login failed",
JOptionPane.ERROR_MESSAGE);
- return false;
+ return null;
}
_newApplication.setEnabled(true);
_newApplicationWithDefaultTemplates.setEnabled(true);
_newMenu.setEnabled(true);
- return true;
+ return session;
}
boolean save()
@@ -799,11 +889,6 @@ public class Model return _admin;
}
- public SessionManagerPrx getSessionManager()
- {
- return _sessionManager;
- }
-
public StatusBar getStatusBar()
{
return _statusBar;
@@ -1486,7 +1571,6 @@ public class Model private Ice.Communicator _communicator;
private Preferences _prefs;
private StatusBar _statusBar;
- private SessionManagerPrx _sessionManager;
private AdminPrx _admin;
private Root _root;
diff --git a/java/src/IceGrid/SessionKeeper.java b/java/src/IceGrid/SessionKeeper.java index 3fa3ad4c1d8..43481822eaa 100755 --- a/java/src/IceGrid/SessionKeeper.java +++ b/java/src/IceGrid/SessionKeeper.java @@ -523,40 +523,11 @@ class SessionKeeper try
{
parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- //
- // Establish session
- //
-
- if(_loginInfo.useGlacier)
- {
- //
- // Not yet implemented
- //
- assert false;
- }
- else
+
+ _session = _model.login(_loginInfo, parent);
+ if(_session == null)
{
- if(!_model.login(_loginInfo, parent))
- {
- return false;
- }
-
- try
- {
- _session = _model.getSessionManager().
- createLocalSession(_loginInfo.username);
- }
- catch(Ice.LocalException e)
- {
- logout(false);
- JOptionPane.showMessageDialog(parent,
- "Could not create session: "
- + e.toString(),
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
+ return false;
}
_model.getStatusBar().setConnected(true);
@@ -565,11 +536,10 @@ class SessionKeeper // Start thread
//
assert(_thread == null);
+ long period = _session.getTimeout() * 1000/ 2;
+ period = 500;
+ System.err.println("period == " + period + " ms");
- //
- // TODO: get period from session
- //
- long period = 10000;
_thread = new Pinger(period);
_thread.start();
@@ -669,17 +639,30 @@ class SessionKeeper // Create the object adapter for the observers
//
String uuid = Ice.Util.generateUUID();
- _observerAdapter = _model.getCommunicator().createObjectAdapterWithEndpoints(
- "Observers-" + uuid, "tcp");
+ String category;
+
+ Ice.RouterPrx router = _model.getCommunicator().getDefaultRouter();
+ if(router == null)
+ {
+ _observerAdapter = _model.getCommunicator().createObjectAdapterWithEndpoints(
+ "Observers-" + uuid, "default -t 15000");
+ category = "observer";
+ }
+ else
+ {
+ _observerAdapter = _model.getCommunicator().createObjectAdapter("Observers-" + uuid);
+ _observerAdapter.addRouter(router);
+ category = router.getServerProxy().ice_getIdentity().category;
+ }
//
// Create servants and proxies
//
- _registryObserverIdentity.name = uuid;
- _registryObserverIdentity.category = "registryObserver";
+ _registryObserverIdentity.name = "registry-" + uuid;
+ _registryObserverIdentity.category = category;
- _nodeObserverIdentity.name = uuid;
- _nodeObserverIdentity.category = "nodeObserver";
+ _nodeObserverIdentity.name = "node-" + uuid;
+ _nodeObserverIdentity.category = category;
RegistryObserverI registryObserverServant = new RegistryObserverI(_model);
@@ -722,6 +705,7 @@ class SessionKeeper {
}
_observerAdapter.deactivate();
+ _observerAdapter.waitForDeactivate();
_observerAdapter = null;
}
}
diff --git a/java/src/IceGrid/TreeNode/Root.java b/java/src/IceGrid/TreeNode/Root.java index 99127a35267..86e45bf5cc7 100755 --- a/java/src/IceGrid/TreeNode/Root.java +++ b/java/src/IceGrid/TreeNode/Root.java @@ -110,6 +110,10 @@ public class Root extends Parent public void clear()
{
clearChildren();
+ _dynamicInfoMap.clear();
+ _nodeAdapterMap.clear();
+ _nodeServerMap.clear();
+
fireStructureChangedEvent(this);
}
|