diff options
| author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
|---|---|---|
| committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-09 19:58:05 +0000 |
| commit | 65bf3316cf384588453604be6b4f0ed3751a8b0f (patch) | |
| tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/classpath/gnu/CORBA/OrbFunctional.java | |
| parent | 8fc56618a84446beccd45b80381cdfe0e94050df (diff) | |
| download | ppe42-gcc-65bf3316cf384588453604be6b4f0ed3751a8b0f.tar.gz ppe42-gcc-65bf3316cf384588453604be6b4f0ed3751a8b0f.zip | |
Merged gcj-eclipse branch to trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/CORBA/OrbFunctional.java')
| -rw-r--r-- | libjava/classpath/gnu/CORBA/OrbFunctional.java | 122 |
1 files changed, 69 insertions, 53 deletions
diff --git a/libjava/classpath/gnu/CORBA/OrbFunctional.java b/libjava/classpath/gnu/CORBA/OrbFunctional.java index 7b9c34ada12..bfb5e3d86c1 100644 --- a/libjava/classpath/gnu/CORBA/OrbFunctional.java +++ b/libjava/classpath/gnu/CORBA/OrbFunctional.java @@ -938,48 +938,55 @@ public class OrbFunctional extends OrbRestricted /** * Start the ORBs main working cycle (receive invocation - invoke on the local - * object - send response - wait for another invocation). - * - * The method only returns after calling {@link #shutdown(boolean)}. + * object - send response - wait for another invocation). The method only + * returns after calling {@link #shutdown(boolean)}. */ public void run() { - running = true; - - // Instantiate the port server for each socket. - Iterator iter = connected_objects.entrySet().iterator(); - Map.Entry m; - Connected_objects.cObject obj; - - while (iter.hasNext()) + CollocatedOrbs.registerOrb(this); + try { - m = (Map.Entry) iter.next(); - obj = (Connected_objects.cObject) m.getValue(); + running = true; - portServer subserver; + // Instantiate the port server for each socket. + Iterator iter = connected_objects.entrySet().iterator(); + Map.Entry m; + Connected_objects.cObject obj; - if (obj.identity == null) - { - subserver = new portServer(obj.port); - portServers.add(subserver); - } - else - subserver = (portServer) identities.get(obj.identity); - - if (!subserver.isAlive()) + while (iter.hasNext()) { - // Reuse the current thread for the last portServer. - if (!iter.hasNext()) + m = (Map.Entry) iter.next(); + obj = (Connected_objects.cObject) m.getValue(); + + portServer subserver; + + if (obj.identity == null) { - // Discard the iterator, eliminating lock checks. - iter = null; - subserver.run(); - return; + subserver = new portServer(obj.port); + portServers.add(subserver); } else - subserver.start(); + subserver = (portServer) identities.get(obj.identity); + + if (! subserver.isAlive()) + { + // Reuse the current thread for the last portServer. + if (! iter.hasNext()) + { + // Discard the iterator, eliminating lock checks. + iter = null; + subserver.run(); + return; + } + else + subserver.start(); + } } } + finally + { + CollocatedOrbs.unregisterOrb(this); + } } /** @@ -1051,22 +1058,26 @@ public class OrbFunctional extends OrbRestricted org.omg.CORBA.Object object = find_local_object(ior); if (object == null) { - ObjectImpl impl = StubLocator.search(this, ior); - try - { - if (impl._get_delegate() == null) - impl._set_delegate(new IorDelegate(this, ior)); - } - catch (BAD_OPERATION ex) + // Check maybe the local object on another ORB, but same VM. + object = CollocatedOrbs.searchLocalObject(ior); + if (object == null) { - // Some colaborants may throw this exception - // in response to the attempt to get the unset delegate. - impl._set_delegate(new IorDelegate(this, ior)); - } + // Surely remote object. + ObjectImpl impl = StubLocator.search(this, ior); + try + { + if (impl._get_delegate() == null) + impl._set_delegate(new IorDelegate(this, ior)); + } + catch (BAD_OPERATION ex) + { + // Some colaborants may throw this exception + // in response to the attempt to get the unset delegate. + impl._set_delegate(new IorDelegate(this, ior)); + } - object = impl; - // TODO remove commented out code below. - // connected_objects.add(ior.key, impl, ior.Internet.port, null); + object = impl; + } } return object; } @@ -1239,15 +1250,10 @@ public class OrbFunctional extends OrbRestricted } if (ior.Id == null) ior.Id = ref.object.getClass().getName(); - try - { - ior.Internet.host = InetAddress.getLocalHost().getHostAddress(); - ior.Internet.port = ref.port; - } - catch (UnknownHostException ex) - { - throw new BAD_OPERATION("Cannot resolve the local host address"); - } + + ior.Internet.host = CollocatedOrbs.localHost; + ior.Internet.port = ref.port; + return ior; } @@ -1775,4 +1781,14 @@ public class OrbFunctional extends OrbRestricted running = false; super.finalize(); } + + /** + * Get the number of objects that are connected to this ORB. + * + * @return the number of objects, connected to this ORB. + */ + public int countConnectedObjects() + { + return connected_objects.size(); + } }
\ No newline at end of file |

