geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject [05/51] [abbrv] geronimo-yoko git commit: Cache outbound connections with reference counting.
Date Sun, 19 Feb 2017 01:49:22 GMT
Cache outbound connections with reference counting.


Project: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/repo
Commit: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/commit/f580371d
Tree: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/tree/f580371d
Diff: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/diff/f580371d

Branch: refs/heads/master
Commit: f580371d0268da98d776f118aa86c0d68b780a89
Parents: eab4a8d
Author: Joe Chacko <chackoj@uk.ibm.com>
Authored: Thu Sep 10 14:18:51 2015 +0100
Committer: Joe Chacko <chackoj@uk.ibm.com>
Committed: Wed Oct 28 19:48:07 2015 +0000

----------------------------------------------------------------------
 pom.xml                                         |  48 +-
 yoko-core/pom.xml                               |  19 +-
 .../org/apache/yoko/orb/CORBA/Delegate.java     |   7 -
 .../org/apache/yoko/orb/CORBA/ObjectImpl.java   |   3 +-
 .../java/org/apache/yoko/orb/OB/Client.java     |   2 +-
 .../org/apache/yoko/orb/OB/ClientManager.java   |   8 +-
 .../apache/yoko/orb/OB/CollocatedClient.java    |   2 +-
 .../yoko/orb/OB/DispatchRequest_impl.java       |   1 -
 .../org/apache/yoko/orb/OB/DowncallStub.java    |  12 +-
 .../java/org/apache/yoko/orb/OB/GIOPClient.java | 315 ++++------
 .../org/apache/yoko/orb/OB/GIOPConnection.java  |  46 +-
 .../apache/yoko/orb/OB/GIOPIncomingMessage.java |   3 +-
 .../apache/yoko/orb/OB/GIOPServerStarter.java   |  31 +-
 .../yoko/orb/OB/GIOPServerStarterThreaded.java  |  32 +-
 .../org/apache/yoko/orb/OB/ORBInstance.java     |  30 +-
 .../org/apache/yoko/orb/OB/PluginManager.java   |   2 +-
 .../main/java/org/apache/yoko/orb/OB/Util.java  |   2 +-
 .../org/apache/yoko/orb/OB/ValueWriter.java     |   3 +-
 .../org/apache/yoko/orb/OBCORBA/ORB_impl.java   |   4 +-
 .../orb/OBMessaging/ExceptionHolder_impl.java   |   4 +-
 .../OBMessaging/UserExceptionRaiseProxy.java    |   2 +-
 .../yoko/orb/OCI/AcceptorInfoOperations.java    |  23 -
 .../java/org/apache/yoko/orb/OCI/Buffer.java    |  12 +
 .../yoko/orb/OCI/ConnectorInfoOperations.java   |  31 -
 .../apache/yoko/orb/OCI/CurrentOperations.java  |  12 -
 .../org/apache/yoko/orb/OCI/Current_impl.java   |   8 -
 .../yoko/orb/OCI/IIOP/AcceptorInfo_impl.java    |  37 +-
 .../apache/yoko/orb/OCI/IIOP/Acceptor_impl.java |  88 +--
 .../orb/OCI/IIOP/ConnectorInfoOperations.java   |   3 +
 .../yoko/orb/OCI/IIOP/ConnectorInfo_impl.java   | 140 ++---
 .../yoko/orb/OCI/IIOP/Connector_impl.java       | 125 ++--
 .../apache/yoko/orb/OCI/IIOP/Exceptions.java    |  35 ++
 .../yoko/orb/OCI/IIOP/TransportInfo_impl.java   | 204 ++-----
 .../yoko/orb/OCI/IIOP/Transport_impl.java       | 199 ++-----
 .../yoko/orb/OCI/TransportInfoOperations.java   |  45 --
 .../main/java/org/apache/yoko/orb/OCI/iiop.java |   4 +-
 .../apache/yoko/orb/activator/Activator.java    |   2 +-
 .../apache/yoko/orb/csi/SecurityContext.java    |   2 +-
 .../org/apache/yoko/ConnectionCachingTest.java  | 203 +++++++
 .../org/apache/yoko/ConnectionCleanupTest.java  | 150 +++++
 .../internal/ProcessAgentImpl.java              |   2 +-
 .../test/java/test/iiopplugin/ClientPlugin.java |   1 -
 .../test/java/test/iiopplugin/ServerPlugin.java |   1 -
 .../iiopplugin/ServiceContextInterceptor.java   |   6 +-
 yoko-core/src/test/java/test/ins/Server.java    |   6 +-
 .../src/test/java/test/util/MultiException.java |  61 ++
 .../src/test/java/test/util/Skellington.java    | 127 ++++
 yoko-osgi/pom.xml                               |  64 ++
 .../org/apache/yoko/osgi/ProviderLocator.java   | 583 +++++++++++++++++++
 .../org/apache/yoko/osgi/ProviderRegistry.java  | 100 ++++
 .../yoko/osgi/locator/BundleProviderLoader.java | 119 ++++
 .../apache/yoko/osgi/locator/ProviderBean.java  |  63 ++
 .../yoko/osgi/locator/ProviderRegistryImpl.java | 327 +++++++++++
 .../org/apache/yoko/osgi/locator/Register.java  |  36 ++
 .../apache/yoko/osgi/locator/ServiceBean.java   |  63 ++
 .../activator/AbstractBundleActivator.java      | 107 ++++
 yoko-rmi-impl/pom.xml                           |   5 +
 .../yoko/rmi/api/PortableRemoteObjectExt.java   |   2 +-
 .../java/org/apache/yoko/rmi/impl/UtilImpl.java |   2 +-
 .../yoko/rmi/osgi/activator/Activator.java      |   6 +-
 yoko-rmi-spec/pom.xml                           |   4 +
 .../apache/yoko/rmispec/util/UtilLoader.java    |   2 +-
 yoko-spec-corba/pom.xml                         |   2 +-
 .../src/main/java/org/omg/CORBA/ORB.java        |   2 +-
 .../src/main/java/org/omg/IIOP/ListenPoint.java |  14 +-
 .../java/org/omg/IIOP/ListenPointHelper.java    |   5 +-
 yoko-util/pom.xml                               |  32 +-
 .../main/java/org/apache/yoko/util/Cache.java   |  47 ++
 .../main/java/org/apache/yoko/util/Factory.java |   5 +
 .../main/java/org/apache/yoko/util/Fifa.java    |   6 +
 .../main/java/org/apache/yoko/util/Fifo.java    |   6 +
 .../java/org/apache/yoko/util/KeyedFactory.java |   5 +
 .../java/org/apache/yoko/util/Reference.java    |   9 +
 .../java/org/apache/yoko/util/Sequential.java   |  18 +
 .../yoko/util/concurrent/ConcurrentFifo.java    | 164 ++++++
 .../yoko/util/concurrent/CountedEntry.java      | 153 +++++
 .../org/apache/yoko/util/concurrent/Foot.java   |  15 +
 .../org/apache/yoko/util/concurrent/Head.java   |   7 +
 .../org/apache/yoko/util/concurrent/NNode.java  |   7 +
 .../util/concurrent/NoOpRunnableFactory.java    |  10 +
 .../org/apache/yoko/util/concurrent/PNode.java  |   7 +
 .../util/concurrent/ReferenceCountedCache.java  | 124 ++++
 .../apache/yoko/util/concurrent/StrongNode.java |  29 +
 .../org/apache/yoko/util/concurrent/VNode.java  |  10 +
 .../util/concurrent/WeakConcurrentFifo.java     |  73 +++
 .../yoko/util/concurrent/WeakCountedCache.java  |  35 ++
 .../apache/yoko/util/concurrent/WeakNode.java   |  34 ++
 .../apache/yoko/util/osgi/ProviderLocator.java  | 583 -------------------
 .../apache/yoko/util/osgi/ProviderRegistry.java | 100 ----
 .../util/osgi/locator/BundleProviderLoader.java | 119 ----
 .../yoko/util/osgi/locator/ProviderBean.java    |  63 --
 .../util/osgi/locator/ProviderRegistryImpl.java | 326 -----------
 .../apache/yoko/util/osgi/locator/Register.java |  36 --
 .../yoko/util/osgi/locator/ServiceBean.java     |  63 --
 .../activator/AbstractBundleActivator.java      | 107 ----
 .../util/concurrent/ConcurrentFifoTest.java     | 274 +++++++++
 .../concurrent/ReferenceCountedCacheTest.java   | 255 ++++++++
 .../util/concurrent/WeakConcurrentFifoTest.java | 105 ++++
 98 files changed, 3976 insertions(+), 2460 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index cec4645..9eaf6ae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,11 +71,12 @@
     <packaging>pom</packaging>
 
     <modules>
-        <module>yoko-core</module>
+        <module>yoko-osgi</module>
         <module>yoko-spec-corba</module>
         <module>yoko-rmi-spec</module>
-        <module>yoko-rmi-impl</module>
         <module>yoko-util</module>
+        <module>yoko-rmi-impl</module>
+        <module>yoko-core</module>
     </modules>
 
     <dependencyManagement>
@@ -83,7 +84,7 @@
             <!--  Yoko modules -->
             <dependency>
                 <groupId>org.apache.yoko</groupId>
-                <artifactId>yoko-core</artifactId>
+                <artifactId>yoko-osgi</artifactId>
                 <version>${project.version}</version>
             </dependency>
             <dependency>
@@ -93,12 +94,12 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.yoko</groupId>
-                <artifactId>yoko-util</artifactId>
+                <artifactId>yoko-rmi-spec</artifactId>
                 <version>${project.version}</version>
             </dependency>
             <dependency>
                 <groupId>org.apache.yoko</groupId>
-                <artifactId>yoko-rmi-spec</artifactId>
+                <artifactId>yoko-util</artifactId>
                 <version>${project.version}</version>
             </dependency>
             <dependency>
@@ -106,6 +107,11 @@
                 <artifactId>yoko-rmi-impl</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.apache.yoko</groupId>
+                <artifactId>yoko-core</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <!--  External dependencies -->
             <dependency>
                 <groupId>junit</groupId>
@@ -117,16 +123,6 @@
                 <artifactId>org.apache.servicemix.bundles.bcel</artifactId>
                 <version>5.2_2</version>
             </dependency>
-            <!--<dependency>-->
-                <!--<groupId>org.apache.maven</groupId>-->
-                <!--<artifactId>maven-plugin-api</artifactId>-->
-                <!--<version>${maven.version}</version>-->
-            <!--</dependency>-->
-            <!--<dependency>-->
-                <!--<groupId>org.apache.maven</groupId>-->
-                <!--<artifactId>maven-project</artifactId>-->
-                <!--<version>${maven.version}</version>-->
-            <!--</dependency>-->
             <dependency>
                 <groupId>ant</groupId>
                 <artifactId>ant</artifactId>
@@ -209,7 +205,6 @@
                     </compilerArguments>
                 </configuration>
             </plugin>
-
         </plugins>
 
         <pluginManagement>
@@ -226,24 +221,6 @@
                         </dependency>
                     </dependencies>
                 </plugin>
-                <!--<plugin>-->
-                    <!--<groupId>org.apache.maven.plugins</groupId>-->
-                    <!--<artifactId>maven-surefire-plugin</artifactId>-->
-                    <!--<configuration>-->
-                        <!--<includes>-->
-                            <!--<include>**/*Test.java</include>-->
-                            <!--<include>**/*TestCase.java</include>-->
-                        <!--</includes>-->
-                        <!--<excludes>-->
-                            <!--<exclude>**/*$*</exclude>-->
-                        <!--</excludes>-->
-                        <!--<reportFormat>brief</reportFormat>-->
-                        <!--<useFile>false</useFile>-->
-                        <!--<forkMode>once</forkMode>-->
-                        <!--<childDelegation>false</childDelegation>-->
-                        <!--<argLine>-ea</argLine>-->
-                    <!--</configuration>-->
-                <!--</plugin>-->
                 <plugin>
                     <groupId>org.apache.felix</groupId>
                     <artifactId>maven-bundle-plugin</artifactId>
@@ -272,9 +249,6 @@
                 <artifactId>maven-clover-plugin</artifactId>
                 <version>2.4</version>
             </plugin>
-            <!--plugin>
-              <artifactId>maven-pmd-plugin</artifactId>
-            </plugin!-->
             <plugin>
                 <artifactId>maven-project-info-reports-plugin</artifactId>
             </plugin>

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/pom.xml
----------------------------------------------------------------------
diff --git a/yoko-core/pom.xml b/yoko-core/pom.xml
index eb8b4ff..54af256 100644
--- a/yoko-core/pom.xml
+++ b/yoko-core/pom.xml
@@ -38,18 +38,18 @@
         </dependency>
         <dependency>
             <groupId>org.apache.yoko</groupId>
-            <artifactId>yoko-spec-corba</artifactId>
+            <artifactId>yoko-osgi</artifactId>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.yoko</groupId>
-            <artifactId>yoko-rmi-spec</artifactId>
+            <artifactId>yoko-spec-corba</artifactId>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.yoko</groupId>
-            <artifactId>yoko-rmi-impl</artifactId>
-            <scope>test</scope>
+            <artifactId>yoko-rmi-spec</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.yoko</groupId>
@@ -57,11 +57,15 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.yoko</groupId>
+            <artifactId>yoko-rmi-impl</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
-
     </dependencies>
 
     <build>
@@ -102,7 +106,7 @@
                                 </artifactItem>
                                 <artifactItem>
                                     <groupId>org.apache.yoko</groupId>
-                                    <artifactId>yoko-util</artifactId>
+                                    <artifactId>yoko-osgi</artifactId>
                                     <type>jar</type>
                                     <overWrite>true</overWrite>
                                     <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
@@ -127,7 +131,8 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
-                    <argLine>-Djava.endorsed.dirs=${basedir}/target/endorsed</argLine>
+                    <argLine>-Xmx128m</argLine>
+                    <argLine>-Djava.endorsed.dirs=${project.build.directory}/endorsed</argLine>
                     <includes>
                         <include>**/org/apache/yoko/*Test.java</include>
                     </includes>

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/Delegate.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/Delegate.java b/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/Delegate.java
index db5868f..acc5015 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/Delegate.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/Delegate.java
@@ -1057,11 +1057,4 @@ public final class Delegate extends org.omg.CORBA_2_4.portable.Delegate {
         return downcallStub_;
     }
 
-    public synchronized void _OB_closeConnection(boolean terminate) {
-        if (downcallStub_ == null) {
-            return;
-        }
-        downcallStub_._OB_closeConnection(terminate);
-        downcallStub_ = null;
-    }
 }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ObjectImpl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ObjectImpl.java b/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ObjectImpl.java
index 780a695..5a456c2 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ObjectImpl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/CORBA/ObjectImpl.java
@@ -19,8 +19,7 @@ package org.apache.yoko.orb.CORBA;
 
 import static org.apache.yoko.orb.OCI.GiopVersion.GIOP1_2;
 
-import org.apache.yoko.orb.OCI.GiopVersion;
-import org.apache.yoko.util.osgi.ProviderLocator;
+import org.apache.yoko.osgi.ProviderLocator;
 
 //
 // ObjectImpl is the base class for proprietary stubs with full

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/Client.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/Client.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/Client.java
index 3cab63b..c97df61 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/Client.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/Client.java
@@ -53,7 +53,7 @@ public abstract class Client {
     //
     // Destroy the client
     //
-    public abstract void destroy(boolean terminate);
+    public abstract void destroy();
 
     //
     // Increment usage (not mutex protected)

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/ClientManager.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/ClientManager.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/ClientManager.java
index 644ba01..e5f6ff7 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/ClientManager.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/ClientManager.java
@@ -82,7 +82,7 @@ public final class ClientManager {
         //
         // Destroy all clients
         //
-        for (Client c : allClients_) c.destroy(false);
+        for (Client c : allClients_) c.destroy();
 
         //
         // Reset internal data
@@ -284,7 +284,7 @@ public final class ClientManager {
                         }
 
                         if (matched) {
-                            newClient.destroy(false);
+                            newClient.destroy();
                             continue;
                         }
                     }
@@ -372,7 +372,7 @@ public final class ClientManager {
         return pairs;
     }
 
-    public synchronized void releaseClient(Client client, boolean terminate) {
+    public synchronized void releaseClient(Client client) {
         //
         // The ORB destroys this object, so it's an initialization error
         // if this operation is called after ORB destruction
@@ -400,7 +400,7 @@ public final class ClientManager {
             reusableClients_.remove(client);
 
             if (allClients_.remove(client)) {
-                client.destroy(terminate);
+                client.destroy();
             } else {
                 Assert._OB_assert("Release called on unknown client");
             }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/CollocatedClient.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/CollocatedClient.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/CollocatedClient.java
index d3f26d4..5cb1242 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/CollocatedClient.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/CollocatedClient.java
@@ -36,7 +36,7 @@ final public class CollocatedClient extends Client implements DowncallEmitter {
     //
     // Destroy the client
     //
-    public void destroy(boolean terminate) {
+    public void destroy() {
         // Nothing to do here
     }
 

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/DispatchRequest_impl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/DispatchRequest_impl.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/DispatchRequest_impl.java
index 3cb2d8c..949cb84 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/DispatchRequest_impl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/DispatchRequest_impl.java
@@ -54,7 +54,6 @@ final public class DispatchRequest_impl extends org.omg.CORBA.LocalObject
 
     public void invoke() {
         poa_._OB_dispatch(oid_, upcall_);
-
         upcall_ = null;
     }
 }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/DowncallStub.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/DowncallStub.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/DowncallStub.java
index ad989ce..f947285 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/DowncallStub.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/DowncallStub.java
@@ -136,7 +136,7 @@ public final class DowncallStub {
         return clientProfilePair.client;
     }
 
-    private void destroy(boolean terminate) {
+    private void destroy() {
         //
         // If the ORB has been destroyed then the clientManager can be nil
         //
@@ -144,7 +144,7 @@ public final class DowncallStub {
 
         if (clientManager != null && clientProfilePairs_ != null) {
             for (ClientProfilePair pair: clientProfilePairs_) {
-                clientManager.releaseClient(pair.client, terminate);
+                clientManager.releaseClient(pair.client);
             }
         }
 
@@ -152,7 +152,7 @@ public final class DowncallStub {
     }
 
     protected void finalize() throws Throwable {
-        destroy(false);
+        destroy();
 
         super.finalize();
     }
@@ -355,7 +355,7 @@ public final class DowncallStub {
 
         for (ClientProfilePair pair : clientProfilePairs_) {
             if (pair.client == client && pair.profile == profile) {
-                clientManager.releaseClient(pair.client, false);
+                clientManager.releaseClient(pair.client);
                 clientProfilePairs_.remove(pair);
                 break;
             }
@@ -1026,10 +1026,6 @@ public final class DowncallStub {
         return delivered;
     }
 
-    public void _OB_closeConnection(boolean terminate) {
-        destroy(terminate);
-    }
-
     //
     // Need to be able to access the ORB instance from a stub for AMI
     // polling

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java
index 6756e8e..2d58692 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java
@@ -17,9 +17,19 @@
 
 package org.apache.yoko.orb.OB;
 
+import org.apache.yoko.orb.OBPortableServer.POAManager_impl;
+import org.apache.yoko.orb.OCI.ConnectorInfo;
 import org.apache.yoko.orb.OCI.GiopVersion;
+import org.apache.yoko.util.Cache;
+import org.apache.yoko.util.Factory;
+import org.apache.yoko.util.Reference;
+import org.omg.CORBA.INITIALIZE;
+import org.omg.PortableServer.POAManager;
 import org.omg.SendingContext.CodeBaseHelper;
 
+import static org.apache.yoko.orb.OB.MinorCodes.*;
+import static org.omg.CORBA.CompletionStatus.*;
+
 final class GIOPClient extends Client {
     protected ORBInstance orbInstance_; // The ORB instance
 
@@ -44,9 +54,8 @@ final class GIOPClient extends Client {
 
     protected boolean bidirWorker_; // is the worker bidir?
 
-    protected boolean ownsWorker_; // does 'this' own the worker?
-
-    protected boolean destroy_; // True if destroy() was called
+    protected volatile boolean destroy_; // True if destroy() was called
+    private Reference<GIOPConnection> connectionRef;
 
     // ----------------------------------------------------------------------
     // GIOPClient private and protected member implementations
@@ -66,60 +75,14 @@ final class GIOPClient extends Client {
     //
     protected GIOPConnection find_bidir_worker() {
         try {
-            //
-            // Any transport that we want to query should exist when the
-            // server first receives a request from the client-side. This
-            // transport will have the ListenPointList populated inside of
-            // its TransportInfo. So we query the list of
-            // GIOPServerStarters for the correct transport and hopefully
-            // find a match if we want to use bidir
-            //
-            org.apache.yoko.orb.OBPortableServer.POAManagerFactory pmFactoryImpl = orbInstance_
-                    .getPOAManagerFactory();
-
-            //
-            // Obtain a list of POAs for this POAManager
-            // 
-            org.omg.PortableServer.POAManager[] pmSeq = pmFactoryImpl.list();
-
-            for (int i = 0; i < pmSeq.length; i++) {
-                org.apache.yoko.orb.OBPortableServer.POAManager_impl poaImpl = (org.apache.yoko.orb.OBPortableServer.POAManager_impl) pmSeq[i];
-
-                // 
-                // Get the server manager from the POA
-                // 
-                org.apache.yoko.orb.OB.ServerManager sm = poaImpl
-                        ._OB_getServerManager();
-
-                //
-                // get the list of servers from the server manager
-                //
-                org.apache.yoko.orb.OB.Server[] servSeq = sm.getServers();
-
-                // 
-                // iterate these servers obtaining the GIOPServerStarter
-                //
-                for (int j = 0; j < servSeq.length; j++) {
-                    org.apache.yoko.orb.OB.GIOPServer giopServer = (org.apache.yoko.orb.OB.GIOPServer) servSeq[j];
-
-                    org.apache.yoko.orb.OB.GIOPServerStarter servStarter = giopServer
-                            ._OB_getGIOPServerStarter();
-
-                    //
-                    // get the matching worker from the GIOPServerStarter
-                    //
-                    GIOPConnection gw = servStarter.getWorker(connectorInfo());
-
+            for (POAManager poaManager : orbInstance_.getPOAManagerFactory().list()) {
+                for (Server aServSeq : ((POAManager_impl) poaManager)._OB_getServerManager().getServers()) {
+                    GIOPConnection gw = ((GIOPServer) aServSeq)._OB_getGIOPServerStarter().getMatchingConnection(connectorInfo());
                     if (gw != null)
                         return gw;
                 }
             }
-        } catch (ClassCastException ex) {
-        }
-
-        //
-        // nothing was found to return
-        // 
+        } catch (ClassCastException ignored) {}
         return null;
     }
 
@@ -128,118 +91,124 @@ final class GIOPClient extends Client {
     // a new worker is created, with the timeout specified as second
     // parameter.
     //
-    protected synchronized GIOPConnection getWorker(boolean create, int t) {
+    protected synchronized GIOPConnection getWorker(boolean create, final int timeout) {
         if (destroy_)
-            throw new org.omg.CORBA.INITIALIZE(org.apache.yoko.orb.OB.MinorCodes
-                    .describeInitialize(org.apache.yoko.orb.OB.MinorCodes.MinorORBDestroyed),
-                    org.apache.yoko.orb.OB.MinorCodes.MinorORBDestroyed,
-                    org.omg.CORBA.CompletionStatus.COMPLETED_NO);
+            throw new INITIALIZE(describeInitialize(MinorORBDestroyed), MinorORBDestroyed, COMPLETED_NO);
+
+        if (connection_ == null)
+            reuseInboundConnection();
+
 
-        // 
-        // first attempt to locate a reusable bidir connection
         //
-        if (connection_ == null) {
-            connection_ = find_bidir_worker();
-
-            if (connection_ != null) {
-                //
-                // adjust the requestID to match the spec (even for
-                // clients, odd for servers)
-                // 
-                if ((nextRequestId_ & 1) == 0)
-                    nextRequestId_++;
-                ownsWorker_ = false;
-                connection_.activateClientSide(this);
-
-                // 
-                // log the reusing of the connection
-                //
-                CoreTraceLevels coreTraceLevels = orbInstance_
-                        .getCoreTraceLevels();
-                if (coreTraceLevels.traceConnections() > 0) {
-                    org.apache.yoko.orb.OCI.TransportInfo info = connection_
-                            .transport().get_info();
-                    String msg = "reusing established bidir connection\n";
-                    msg += info.describe();
-                    orbInstance_.getLogger().trace("outgoing", msg);
-                }
-            }
+        // no inbound bidir connection resolved so lookup an existing outbound connection
+        // or create one if the request calls for it
+        //
+        if (connection_ == null)
+            reuseOrCreateOutboundConnection(create, timeout);
+
+        //
+        // Lazy initialization of codeSetSC_. We don't want to
+        // initialize codeSetSC_ in the constructor, in order to
+        // keep creation of GIOPClients, which might later on not
+        // be used, as light-weight as possible.
+        //
+        initServiceContexts();
+
+        return connection_;
+    }
+
+    private synchronized void reuseOrCreateOutboundConnection(boolean create, final int timeout) {
+        Cache<ConnectorInfo, GIOPConnection> connCache = orbInstance_.getOutboundConnectionCache();
+        if (create) {
+            connectionRef = connCache.getOrCreate(connector_.get_info(), new Factory<GIOPConnection>() {
+                @Override public GIOPConnection create() {return createOutboundConnection(timeout);}
+            });
+        } else {
+            connectionRef = connCache.get(connector_.get_info());
         }
+        connCache.clean();
+        connection_ = connectionRef.get();
 
-        // 
-        // no bidir connection resolved so create one if the request
-        // calls for it
-        // 
-        if (connection_ == null && create) {
-            //
-            // Trace connection attempt
-            //
-            CoreTraceLevels coreTraceLevels = orbInstance_.getCoreTraceLevels();
-            if (coreTraceLevels.traceConnections() > 0) {
-                org.apache.yoko.orb.OCI.ConnectorInfo info = connector_
-                        .get_info();
-                String msg = "trying to establish connection\n";
-                msg += "timeout: ";
-                if (t >= 0) {
-                    msg += t;
-                    msg += "ms\n";
-                } else
-                    msg += "none\n";
-                msg += info.describe();
-                orbInstance_.getLogger().trace("outgoing", msg);
-            }
+        //
+        // bidirWorker_ means that this connection may be used to
+        // service requests so we need to set ourselves up as a
+        // server (to correct map the OAInterfaces)
+        //
+        if (bidirWorker_)
+            connection_.activateServerSide();
+    }
 
-            //
-            // Create new transport, using the connector
-            //
-            // For symetry reasons, GIOPClientStarterThreaded should also be
-            // added, even though these classes only have a trivial
-            // functionality. Or perhaps the GIOPClientStarterThreaded tries to
-            // connect() in the backgound? Just an idea...
-            //
+    private synchronized void reuseInboundConnection() {
+        //
+        // first attempt to locate a reusable bidir connection
+        //
+        connection_ = find_bidir_worker();
+
+        if (connection_ == null) return;
+
+        //
+        // adjust the requestID to match the spec (even for
+        // clients, odd for servers)
+        //
+        nextRequestId_ |= 1;
+        connection_.activateClientSide(this);
 
-            org.apache.yoko.orb.OCI.Transport transport;
+        //
+        // log the reusing of the connection
+        //
+        if (orbInstance_.getCoreTraceLevels().traceConnections() > 0) {
+            String msg = "reusing established bidir connection\n" + connection_.transport().get_info().describe();
+            orbInstance_.getLogger().trace("outgoing", msg);
+        }
+    }
 
+    private GIOPConnectionThreaded createOutboundConnection(int t) {
+        //
+        // Trace connection attempt
+        //
+        CoreTraceLevels coreTraceLevels = orbInstance_.getCoreTraceLevels();
+        if (coreTraceLevels.traceConnections() > 0) {
+            String msg = "trying to establish connection\n";
+            msg += "timeout: ";
             if (t >= 0) {
-                transport = connector_.connect_timeout(t);
-
-                //
-                // Was there a timeout?
-                //
-                if (transport == null)
-                    throw new org.omg.CORBA.NO_RESPONSE("Connection timeout",
-                            0, org.omg.CORBA.CompletionStatus.COMPLETED_NO);
-            } else {
-                transport = connector_.connect();
-                Assert._OB_assert(transport != null);
-            }
+                msg += t;
+                msg += "ms\n";
+            } else
+                msg += "none\n";
+            msg += connector_.get_info().describe();
+            orbInstance_.getLogger().trace("outgoing", msg);
+        }
 
-            //
-            // Create new worker
-            //
-            Assert._OB_assert(concModel_ == Threaded);
-            connection_ = new GIOPConnectionThreaded(orbInstance_, transport,
-                    this);
-            ownsWorker_ = true;
+        //
+        // Create new transport, using the connector
+        //
+        // For symetry reasons, GIOPClientStarterThreaded should also be
+        // added, even though these classes only have a trivial
+        // functionality. Or perhaps the GIOPClientStarterThreaded tries to
+        // connect() in the backgound? Just an idea...
+        //
+
+        org.apache.yoko.orb.OCI.Transport transport;
+
+        if (t >= 0) {
+            transport = connector_.connect_timeout(t);
 
             //
-            // bidirWorker_ means that this connection may be used to
-            // service requests so we need to set ourselves up as a
-            // server (to correct map the OAInterfaces)
+            // Was there a timeout?
             //
-            if (bidirWorker_)
-                connection_.activateServerSide();
+            if (transport == null)
+                throw new org.omg.CORBA.NO_RESPONSE("Connection timeout",
+                        0, org.omg.CORBA.CompletionStatus.COMPLETED_NO);
+        } else {
+            transport = connector_.connect();
+            Assert._OB_assert(transport != null);
         }
 
         //
-        // Lazy initialization of codeSetSC_. We don't want to
-        // initialize codeSetSC_ in the constructor, in order to
-        // keep creation of GIOPClients, which might later on not
-        // be used, as light-weight as possible.
+        // Create new worker
         //
-        initServiceContexts();
-
-        return connection_;
+        Assert._OB_assert(concModel_ == Threaded);
+        return new GIOPConnectionThreaded(orbInstance_, transport, this);
     }
 
     //
@@ -325,7 +294,6 @@ final class GIOPClient extends Client {
         connection_ = null;
         destroy_ = false;
         bidirWorker_ = bidirEnable;
-        ownsWorker_ = true;
     }
 
     // ----------------------------------------------------------------------
@@ -335,39 +303,20 @@ final class GIOPClient extends Client {
     //
     // Destroy the client
     //
-    public void destroy(boolean terminate) {
-        GIOPConnection c = null;
-
-        synchronized (this) {
-            //
-            // Don't destroy twice
-            //
-            if (destroy_)
-                return;
-
-            //
-            // Set the destroy flag
-            //
-            destroy_ = true;
-
-            //
-            // Use a copy of the worker, and destroy the worker outside
-            // the synchronization, to avoid deadlocks
-            //
-            c = connection_;
-            connection_ = null;
-        }
-
-        //
-        // If there is a worker (and we exclusively own it) destroy it
-        //
-        if (c != null && ownsWorker_)
-            c.destroy(terminate);
+    public synchronized void destroy() {
+        if (destroy_) return;
+        destroy_ = true;
+        connection_ = null;
+        // release the reference if this is an outbound connection
+        if (connectionRef != null) connectionRef.close();
     }
 
     public synchronized void removeConnection(GIOPConnection connection) {
-        if (connection_ == connection)
-            connection_ = null;
+        if (connection != connection_) return;
+        connection_ = null;
+        // purge the reference from the cache if this is an outbound connection
+        if (connectionRef != null)
+            orbInstance_.getOutboundConnectionCache().remove(connectionRef);
     }
 
     //
@@ -601,12 +550,4 @@ final class GIOPClient extends Client {
         org.apache.yoko.orb.OCI.Transport transport = connection.transport();
         return transport.mode() == org.apache.yoko.orb.OCI.SendReceiveMode.SendReceive;
     }
-
-    // 
-    // determines whether this GIOPClient exclusively owns its worker or
-    // if its shared with another Client/Server
-    //
-    public boolean sharedConnection() {
-        return !ownsWorker_;
-    }
 }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java
index 2280516..77aec72 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java
@@ -17,19 +17,14 @@
 
 package org.apache.yoko.orb.OB;
 
-import static org.apache.yoko.orb.OCI.GiopVersion.GIOP1_2;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
+import static org.apache.yoko.orb.OB.MinorCodes.*;
+import static org.omg.CORBA.CompletionStatus.*;
 
 import org.apache.yoko.orb.CORBA.InputStream;
-import org.apache.yoko.orb.OB.Logger;
-import org.apache.yoko.orb.OCI.Buffer;
 import org.apache.yoko.orb.OCI.GiopVersion;
 import org.omg.CORBA.SystemException;
+import org.omg.CORBA.TRANSIENT;
 import org.omg.CORBA.UNKNOWN;
-import org.omg.CORBA.portable.UnknownException;
 import org.omg.IOP.ServiceContext;
 import org.omg.IOP.UnknownExceptionInfo;
 import org.omg.SendingContext.CodeBase;
@@ -489,8 +484,7 @@ abstract public class GIOPConnection implements DowncallEmitter, UpcallReturn {
         // Parse the SCL, examining it for various codeset info
         //
         readCodeConverters(scl.value);
-        if (codeConverters_ != null)
-            in._OB_codeConverters(codeConverters_, GiopVersion.get(version.major, version.minor));
+        in._OB_codeConverters(codeConverters_, GiopVersion.get(version.major, version.minor));
 
         //
         // read in the peer's sending context runtime object
@@ -502,7 +496,7 @@ abstract public class GIOPConnection implements DowncallEmitter, UpcallReturn {
         //
         if (response.value)
             upcallsInProgress_++;
-        
+
         orbInstance_.getLogger().debug("Processing request reqId=" + reqId + " op=" + op.value); 
 
         return oaInterface_.createUpcall(
@@ -1162,6 +1156,16 @@ abstract public class GIOPConnection implements DowncallEmitter, UpcallReturn {
             idleTimeout_ = Integer.parseInt(value);
     }
 
+    /** @returns true iff this connection was initiated by the other party */
+    public final boolean isInbound() {
+        return (properties_ & Property.CreatedByClient) == 0;
+    }
+
+    /** @returns true iff this connection was initiated by this party */
+    public final boolean isOutbound() {
+        return !!! isInbound();
+    }
+
     //
     // start populating the reply data
     //
@@ -1450,15 +1454,6 @@ abstract public class GIOPConnection implements DowncallEmitter, UpcallReturn {
     }
 
     //
-    // check if this connection is enabled for BiDir communication
-    //
-    synchronized public boolean bidirConnection() {
-        if (client_ == null)
-            return false;
-        return client_.sharedConnection();
-    }
-
-    //
     // change the state of this connection
     //
     public void setState(int newState) {
@@ -1598,15 +1593,8 @@ abstract public class GIOPConnection implements DowncallEmitter, UpcallReturn {
     //
     // destroy this connection
     //
-    public void destroy(boolean terminateNow) {
-        if (!terminateNow)
-            setState(State.Closing);
-        else
-            processException(State.Closed, new org.omg.CORBA.TRANSIENT(
-                    MinorCodes
-                            .describeTransient(org.apache.yoko.orb.OB.MinorCodes.MinorForcedShutdown),
-                    org.apache.yoko.orb.OB.MinorCodes.MinorForcedShutdown,
-                    org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE), false);
+    public void destroy() {
+        setState(State.Closing);
     }
 
     //

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPIncomingMessage.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPIncomingMessage.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPIncomingMessage.java
index 1c5157e..bd5cc94 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPIncomingMessage.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPIncomingMessage.java
@@ -232,8 +232,7 @@ final public class GIOPIncomingMessage {
                     org.apache.yoko.orb.OB.MinorCodes.MinorVersion,
                     org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
 
-        org.apache.yoko.orb.CORBA.InputStream in = new org.apache.yoko.orb.CORBA.InputStream(
-                buf, 0, false);
+        org.apache.yoko.orb.CORBA.InputStream in = new org.apache.yoko.orb.CORBA.InputStream(buf, 0, false);
 
         switch (version_.minor) {
         case 0: {

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPServerStarter.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPServerStarter.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPServerStarter.java
index 2cb4be4..ccbe630 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPServerStarter.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPServerStarter.java
@@ -17,18 +17,21 @@
 
 package org.apache.yoko.orb.OB;
 
+import org.apache.yoko.orb.OCI.Acceptor;
+
+import java.util.Vector;
 import java.util.logging.Logger;
 
 abstract class GIOPServerStarter {
     static final Logger logger = Logger.getLogger(GIOPServerStarter.class.getName());
     
-    protected ORBInstance orbInstance_; // The ORBInstance
+    protected final ORBInstance orbInstance_; // The ORBInstance
 
-    protected org.apache.yoko.orb.OCI.Acceptor acceptor_; // The acceptor
+    protected final Acceptor acceptor_; // The acceptor
 
-    protected OAInterface oaInterface_; // The OA interface
+    protected final OAInterface oaInterface_; // The OA interface
 
-    protected java.util.Vector connections_ = new java.util.Vector(); // Workers
+    protected final Vector connections_ = new java.util.Vector(); // Workers
 
     public static final int StateActive = 0;
 
@@ -63,8 +66,7 @@ abstract class GIOPServerStarter {
 
     protected void reapWorkers() {
         for (int i = 0; i < connections_.size();) {
-            GIOPConnection connection = (GIOPConnection) connections_
-                    .elementAt(i);
+            GIOPConnection connection = (GIOPConnection) connections_.elementAt(i);
             if (connection.destroyed())
                 connections_.removeElementAt(i);
             else
@@ -110,11 +112,11 @@ abstract class GIOPServerStarter {
 
     //
     // given a host/port this will search the workers of this
-    // GIOPServerStarter for a transport which matches the specific
-    // connection information. It returns null if not found.
+    // GIOPServerStarter for an inbound connection transport
+    // which matches the specific connection information.
+    // It returns null if not found.
     //
-    public synchronized GIOPConnection getWorker(
-            org.apache.yoko.orb.OCI.ConnectorInfo connInfo) {
+    public synchronized GIOPConnection getMatchingConnection(org.apache.yoko.orb.OCI.ConnectorInfo connInfo) {
         //
         // reap the workers first since we don't want to return a
         // destroyed transport
@@ -127,11 +129,14 @@ abstract class GIOPServerStarter {
         for (int i = 0; i < connections_.size(); i++) {
             GIOPConnection worker = (GIOPConnection) connections_.elementAt(i);
 
+            // we only want to find inbound connections
+            if (worker.isOutbound())
+                continue;
+
             org.apache.yoko.orb.OCI.Transport transport = worker.transport();
 
-            if (transport != null)
-                if (transport.get_info().endpoint_alias_match(connInfo))
-                    return worker;
+            if (transport != null && transport.get_info().endpoint_alias_match(connInfo))
+                return worker;
         }
 
         // 

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPServerStarterThreaded.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPServerStarterThreaded.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPServerStarterThreaded.java
index 81303b4..4701484 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPServerStarterThreaded.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/GIOPServerStarterThreaded.java
@@ -17,6 +17,9 @@
 
 package org.apache.yoko.orb.OB;
 
+import org.apache.yoko.orb.OCI.Acceptor;
+import org.apache.yoko.orb.OCI.Transport;
+
 import java.util.concurrent.ExecutorService;
 import java.util.logging.Level;
 
@@ -44,29 +47,19 @@ final class GIOPServerStarterThreaded extends GIOPServerStarter {
             //
             // Accept all connections which might have queued up in the
             // listen() backlog
-            while (true) {
-                org.apache.yoko.orb.OCI.Transport transport = null;
+            do {
 
                 try {
-                    transport = acceptor_.accept(false);
-                } catch (org.omg.CORBA.SystemException ex) {
-                }
-
-                if (transport == null) {
-                    logger.fine("Null transport received from a connect"); 
-                    break;
-                }
-
-                try {
-                    GIOPConnection connection = new GIOPConnectionThreaded(
-                            orbInstance_, transport,
-                            oaInterface_);
-
+                    Transport t = acceptor_.accept(false);
+                    if (t == null) {
+                        logger.fine("Null transport received from a connect");
+                        break;
+                    }
+                    GIOPConnection connection = new GIOPConnectionThreaded(orbInstance_, t, oaInterface_);
                     connection.setState(GIOPConnection.State.Closing);
                 } catch (org.omg.CORBA.SystemException ex) {
-                    // Ignore SystemExceptions
                 }
-            }
+            } while (true);
 
             //
             // Close the acceptor
@@ -80,8 +73,7 @@ final class GIOPServerStarterThreaded extends GIOPServerStarter {
     // GIOPServerStarterThreaded package member implementation
     // ----------------------------------------------------------------------
 
-    GIOPServerStarterThreaded(ORBInstance orbInstance,
-            org.apache.yoko.orb.OCI.Acceptor acceptor, OAInterface oaInterface) {
+    GIOPServerStarterThreaded(ORBInstance orbInstance, Acceptor acceptor, OAInterface oaInterface) {
         super(orbInstance, acceptor, oaInterface);
 
         logger.fine("GIOPServer thread started " + this + " using acceptor " + acceptor); 

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/ORBInstance.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/ORBInstance.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/ORBInstance.java
index a7493ef..8e6c0e3 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/ORBInstance.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/ORBInstance.java
@@ -17,28 +17,27 @@
 
 package org.apache.yoko.orb.OB;
 
-import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Phaser;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.apache.yoko.orb.OB.BootManager;
-import org.apache.yoko.orb.OB.DispatchStrategyFactory;
-import org.apache.yoko.orb.OB.Logger;
-import org.apache.yoko.orb.OB.URLRegistry;
-import org.apache.yoko.orb.OB.UnknownExceptionStrategy;
+
+import org.apache.yoko.orb.OCI.ConnectorInfo;
+import org.apache.yoko.util.Cache;
+import org.apache.yoko.util.concurrent.ReferenceCountedCache;
+import org.apache.yoko.util.concurrent.WeakCountedCache;
 
 public final class ORBInstance {
     private boolean destroy_; // True if destroy() was called
 
-    //
-    // Reference to ORB is needed in Java
-    //
+    private static final Cache.Cleaner<GIOPConnection> CLEANER = new Cache.Cleaner<GIOPConnection>() {
+        @Override
+        public void clean(GIOPConnection conn) {
+            conn.destroy();
+        }
+    };
+
+    private final Cache<ConnectorInfo, GIOPConnection> outboundConnectionCache = new WeakCountedCache<>(CLEANER, 0, 100);
+
     private org.omg.CORBA.ORB orb_;
 
     //
@@ -485,4 +484,5 @@ public final class ORBInstance {
         return asyncHandler_;
     }
 
+    public Cache<org.apache.yoko.orb.OCI.ConnectorInfo,GIOPConnection> getOutboundConnectionCache() {return outboundConnectionCache;}
 }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/PluginManager.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/PluginManager.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/PluginManager.java
index b7ca0bf..28e0d8f 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/PluginManager.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/PluginManager.java
@@ -17,7 +17,7 @@
 
 package org.apache.yoko.orb.OB;
 
-import org.apache.yoko.util.osgi.ProviderLocator;
+import org.apache.yoko.osgi.ProviderLocator;
 
 public final class PluginManager {
     //

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/Util.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/Util.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/Util.java
index 49aa61f..19bbdd5 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/Util.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/Util.java
@@ -17,7 +17,7 @@
 
 package org.apache.yoko.orb.OB;
 
-import org.apache.yoko.util.osgi.ProviderLocator;
+import org.apache.yoko.osgi.ProviderLocator;
 import org.omg.IOP.ServiceContext;
 import org.omg.SendingContext.CodeBase;
 

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java b/yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java
index f9ee9f6..bc9a6b5 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OB/ValueWriter.java
@@ -21,9 +21,8 @@ import java.io.Serializable;
 
 import javax.rmi.CORBA.ValueHandler;
 
-import org.apache.yoko.orb.CORBA.ORB;
 import org.apache.yoko.util.cmsf.RepIds;
-import org.apache.yoko.util.osgi.ProviderLocator;
+import org.apache.yoko.osgi.ProviderLocator;
 import org.omg.CORBA.WStringValueHelper;
 import org.omg.CORBA.portable.BoxedValueHelper;
 import org.omg.CORBA.portable.IDLEntity;

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java b/yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
index 3376368..36e0044 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
@@ -19,8 +19,6 @@ package org.apache.yoko.orb.OBCORBA;
 
 import java.security.AccessController;
 import java.util.Properties;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.yoko.orb.cmsf.CmsfClientInterceptor;
 import org.apache.yoko.orb.cmsf.CmsfIORInterceptor;
@@ -31,7 +29,7 @@ import org.apache.yoko.orb.util.GetSystemPropertyAction;
 import org.apache.yoko.orb.yasf.YasfClientInterceptor;
 import org.apache.yoko.orb.yasf.YasfIORInterceptor;
 import org.apache.yoko.orb.yasf.YasfServerInterceptor;
-import org.apache.yoko.util.osgi.ProviderLocator;
+import org.apache.yoko.osgi.ProviderLocator;
 import org.omg.CORBA.OBJECT_NOT_EXIST;
 
 // This class must be public and not final

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OBMessaging/ExceptionHolder_impl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OBMessaging/ExceptionHolder_impl.java b/yoko-core/src/main/java/org/apache/yoko/orb/OBMessaging/ExceptionHolder_impl.java
index 982725f..b9461a6 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OBMessaging/ExceptionHolder_impl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OBMessaging/ExceptionHolder_impl.java
@@ -18,9 +18,7 @@
 package org.apache.yoko.orb.OBMessaging;
 import static org.apache.yoko.orb.OCI.GiopVersion.GIOP1_2;
 
-import org.apache.yoko.orb.OCI.GiopVersion;
-import org.apache.yoko.util.osgi.ProviderLocator;
-import org.omg.CORBA.Any;
+import org.apache.yoko.osgi.ProviderLocator;
 
 public class ExceptionHolder_impl extends org.omg.Messaging._ExceptionHolder {
     //

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OBMessaging/UserExceptionRaiseProxy.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OBMessaging/UserExceptionRaiseProxy.java b/yoko-core/src/main/java/org/apache/yoko/orb/OBMessaging/UserExceptionRaiseProxy.java
index b08ceb7..dd9667b 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OBMessaging/UserExceptionRaiseProxy.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OBMessaging/UserExceptionRaiseProxy.java
@@ -17,7 +17,7 @@
 
 package org.apache.yoko.orb.OBMessaging;
 
-import org.apache.yoko.util.osgi.ProviderLocator;
+import org.apache.yoko.osgi.ProviderLocator;
 
 public class UserExceptionRaiseProxy {
     public void raise(org.omg.Messaging._ExceptionHolder execptHolder)

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OCI/AcceptorInfoOperations.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/AcceptorInfoOperations.java b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/AcceptorInfoOperations.java
index 64b390e..3931b51 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/AcceptorInfoOperations.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/AcceptorInfoOperations.java
@@ -66,31 +66,8 @@ public interface AcceptorInfoOperations
     //
     // IDL:orb.yoko.apache.org/OCI/AcceptorInfo/add_accept_cb:1.0
     //
-    /**
-     *
-     * Add a callback that is called whenever a new connection is
-     * accepted. If the callback has already been registered, this
-     * method has no effect.
-     *
-     * @param cb The callback to add.
-     *
-     **/
-
-    void
-    add_accept_cb(AcceptCB cb);
 
     //
     // IDL:orb.yoko.apache.org/OCI/AcceptorInfo/remove_accept_cb:1.0
     //
-    /**
-     *
-     * Remove an accept callback. If the callback was not registered,
-     * this method has no effect.
-     *
-     * @param cb The callback to remove.
-     *
-     **/
-
-    void
-    remove_accept_cb(AcceptCB cb);
 }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OCI/Buffer.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/Buffer.java b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/Buffer.java
index 77f1827..6cdee79 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/Buffer.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/Buffer.java
@@ -17,6 +17,8 @@
 
 package org.apache.yoko.orb.OCI;
 
+import org.apache.yoko.orb.OB.IORUtil;
+
 public final class Buffer {
     private int max_; // The maximum size of the buffer
 
@@ -155,4 +157,14 @@ public final class Buffer {
     public Buffer(int len) {
         alloc(len);
     }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        int pos = pos_, len = len_;
+        IORUtil.dump_octets(data_, 0, pos, sb);
+        sb.append(String.format("------------------ pos = 0x%08X -------------------%n", pos));
+        IORUtil.dump_octets(data_, pos, len_ - pos, sb);
+        return sb.toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OCI/ConnectorInfoOperations.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/ConnectorInfoOperations.java b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/ConnectorInfoOperations.java
index 5841a3f..7edb247 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/ConnectorInfoOperations.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/ConnectorInfoOperations.java
@@ -62,35 +62,4 @@ public interface ConnectorInfoOperations
 
     String
     describe();
-
-    //
-    // IDL:orb.yoko.apache.org/OCI/ConnectorInfo/add_connect_cb:1.0
-    //
-    /**
-     *
-     * Add a callback that is called whenever a new connection is
-     * established. If the callback has already been registered, this
-     * method has no effect.
-     *
-     * @param cb The callback to add.
-     *
-     **/
-
-    void
-    add_connect_cb(ConnectCB cb);
-
-    //
-    // IDL:orb.yoko.apache.org/OCI/ConnectorInfo/remove_connect_cb:1.0
-    //
-    /**
-     *
-     * Remove a connect callback. If the callback was not registered,
-     * this method has no effect.
-     *
-     * @param cb The callback to remove.
-     *
-     **/
-
-    void
-    remove_connect_cb(ConnectCB cb);
 }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OCI/CurrentOperations.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/CurrentOperations.java b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/CurrentOperations.java
index 580d592..a0d51be 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/CurrentOperations.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/CurrentOperations.java
@@ -47,16 +47,4 @@ public interface CurrentOperations extends org.omg.CORBA.CurrentOperations
     //
     // IDL:orb.yoko.apache.org/OCI/Current/get_oci_acceptor_info:1.0
     //
-    /**
-     *
-     * This method returns the Acceptor information object for the
-     * Acceptor which created the Transport used to invoke the current
-     * request.
-     *
-     * @returns The Acceptor information object.
-     *
-     **/
-
-    AcceptorInfo
-    get_oci_acceptor_info();
 }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OCI/Current_impl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/Current_impl.java b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/Current_impl.java
index c013f11..c19db57 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/Current_impl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/Current_impl.java
@@ -68,14 +68,6 @@ final public class Current_impl extends org.omg.CORBA.LocalObject implements
                 .firstElement();
     }
 
-    public org.apache.yoko.orb.OCI.AcceptorInfo get_oci_acceptor_info() {
-        org.apache.yoko.orb.OCI.TransportInfo info = get_oci_transport_info();
-        if (info != null)
-            return info.acceptor_info();
-        else
-            return null;
-    }
-
     // ------------------------------------------------------------------
     // Yoko internal functions
     // Application programs must not use these functions directly

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/AcceptorInfo_impl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/AcceptorInfo_impl.java b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/AcceptorInfo_impl.java
index bd46fc7..48c2411 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/AcceptorInfo_impl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/AcceptorInfo_impl.java
@@ -19,16 +19,11 @@ package org.apache.yoko.orb.OCI.IIOP;
 
 import org.apache.yoko.orb.OCI.IIOP.AcceptorInfo;
 import org.apache.yoko.orb.OCI.IIOP.PLUGIN_ID;
+import org.omg.CORBA.LocalObject;
 
-public final class AcceptorInfo_impl extends org.omg.CORBA.LocalObject
-        implements AcceptorInfo {
+public final class AcceptorInfo_impl extends LocalObject implements AcceptorInfo {
     private Acceptor_impl acceptor_; // The associated acceptor
 
-    //
-    // All accept callback objects
-    //
-    private java.util.Vector acceptCBVec_ = new java.util.Vector();
-
     // ------------------------------------------------------------------
     // Standard IDL to Java Mapping
     // ------------------------------------------------------------------
@@ -62,24 +57,6 @@ public final class AcceptorInfo_impl extends org.omg.CORBA.LocalObject
         return desc;
     }
 
-    public synchronized void add_accept_cb(org.apache.yoko.orb.OCI.AcceptCB cb) {
-        int length = acceptCBVec_.size();
-        for (int i = 0; i < length; i++)
-            if (acceptCBVec_.elementAt(i) == cb)
-                return; // Already registered
-        acceptCBVec_.addElement(cb);
-    }
-
-    public synchronized void remove_accept_cb(
-            org.apache.yoko.orb.OCI.AcceptCB cb) {
-        int length = acceptCBVec_.size();
-        for (int i = 0; i < length; i++)
-            if (acceptCBVec_.elementAt(i) == cb) {
-                acceptCBVec_.removeElementAt(i);
-                return;
-            }
-    }
-
     public synchronized String[] hosts() {
         if (acceptor_ == null)
             throw new org.omg.CORBA.NO_RESOURCES();
@@ -115,16 +92,6 @@ public final class AcceptorInfo_impl extends org.omg.CORBA.LocalObject
         acceptor_ = acceptor;
     }
 
-    synchronized void _OB_callAcceptCB(
-            org.apache.yoko.orb.OCI.TransportInfo info) {
-        int length = acceptCBVec_.size();
-        for (int i = 0; i < length; i++) {
-            org.apache.yoko.orb.OCI.AcceptCB cb = (org.apache.yoko.orb.OCI.AcceptCB) acceptCBVec_
-                    .elementAt(i);
-            cb.accept_cb(info);
-        }
-    }
-
     synchronized void _OB_destroy() {
         acceptor_ = null;
     }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/Acceptor_impl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/Acceptor_impl.java b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/Acceptor_impl.java
index 1793988..0cc863a 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/Acceptor_impl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/Acceptor_impl.java
@@ -17,13 +17,20 @@
 
 package org.apache.yoko.orb.OCI.IIOP;
 
+import static org.apache.yoko.orb.OCI.IIOP.Exceptions.*;
+import static org.apache.yoko.orb.OB.MinorCodes.*;
+
+import java.io.InterruptedIOException;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.apache.yoko.orb.CORBA.OutputStream;
 import org.apache.yoko.orb.OB.Assert;
-import org.apache.yoko.orb.OCI.IIOP.PLUGIN_ID;
+import org.apache.yoko.orb.OB.MinorCodes;
+import org.apache.yoko.orb.OCI.Transport;
+import org.omg.CORBA.COMM_FAILURE;
 import org.omg.IOP.Codec;
+import org.omg.IOP.TAG_INTERNET_IOP;
 
 final class Acceptor_impl extends org.omg.CORBA.LocalObject implements
         org.apache.yoko.orb.OCI.Acceptor {
@@ -63,7 +70,7 @@ final class Acceptor_impl extends org.omg.CORBA.LocalObject implements
     }
 
     public int tag() {
-        return org.omg.IOP.TAG_INTERNET_IOP.value;
+        return TAG_INTERNET_IOP.value;
     }
 
     public int handle() {
@@ -123,22 +130,11 @@ final class Acceptor_impl extends org.omg.CORBA.LocalObject implements
                 return null; // Timeout
             else {
                 logger.log(Level.FINE, "Failure accepting connection for host=" + localAddress_ + ", port=" + port_, ex);
-
-                throw (org.omg.CORBA.COMM_FAILURE)new org.omg.CORBA.COMM_FAILURE(
-                        org.apache.yoko.orb.OB.MinorCodes
-                                .describeCommFailure(org.apache.yoko.orb.OB.MinorCodes.MinorAccept)
-                                + ": " + ex.getMessage(),
-                        org.apache.yoko.orb.OB.MinorCodes.MinorAccept,
-                        org.omg.CORBA.CompletionStatus.COMPLETED_NO).initCause(ex);
+                throw asCommFailure(ex, MinorAccept);
             }
         } catch (java.io.IOException ex) {
             logger.log(Level.FINE, "Failure accepting connection for host=" + localAddress_ + ", port=" + port_, ex);
-            throw (org.omg.CORBA.COMM_FAILURE)new org.omg.CORBA.COMM_FAILURE(
-                    org.apache.yoko.orb.OB.MinorCodes
-                            .describeCommFailure(org.apache.yoko.orb.OB.MinorCodes.MinorAccept)
-                            + ": " + ex.getMessage(),
-                    org.apache.yoko.orb.OB.MinorCodes.MinorAccept,
-                    org.omg.CORBA.CompletionStatus.COMPLETED_NO).initCause(ex);
+            throw asCommFailure(ex, MinorAccept);
         }
 
         //
@@ -150,18 +146,13 @@ final class Acceptor_impl extends org.omg.CORBA.LocalObject implements
                 socket.setKeepAlive(true);
         } catch (java.net.SocketException ex) {
             logger.log(Level.FINE, "Failure configuring server connection for host=" + localAddress_ + ", port=" + port_, ex);
-            throw (org.omg.CORBA.COMM_FAILURE)new org.omg.CORBA.COMM_FAILURE(
-                    org.apache.yoko.orb.OB.MinorCodes
-                            .describeCommFailure(org.apache.yoko.orb.OB.MinorCodes.MinorSetsockopt)
-                            + ": " + ex.getMessage(),
-                    org.apache.yoko.orb.OB.MinorCodes.MinorSetsockopt,
-                    org.omg.CORBA.CompletionStatus.COMPLETED_NO).initCause(ex);
+            throw asCommFailure(ex, MinorSetsockopt);
         }
 
         //
         // Create new transport
         //
-        org.apache.yoko.orb.OCI.Transport tr = null;
+        Transport tr = null;
         try {
             tr = new Transport_impl(this, socket, listenMap_);
             logger.fine("Inbound connection received from " + socket.getInetAddress()); 
@@ -175,24 +166,12 @@ final class Acceptor_impl extends org.omg.CORBA.LocalObject implements
         }
 
         //
-        // Call callbacks
-        //
-        org.apache.yoko.orb.OCI.TransportInfo trInfo = tr.get_info();
-        try {
-            info_._OB_callAcceptCB(trInfo);
-        } catch (org.omg.CORBA.SystemException ex) {
-            tr.close();
-            logger.log(Level.FINE, "error calling connection callbacks", ex); 
-            throw ex;
-        }
-
-        //
         // Return new transport
         //
         return tr;
     }
 
-    public org.apache.yoko.orb.OCI.Transport connect_self() {
+    public Transport connect_self() {
         //
         // Create socket and connect to local address
         //
@@ -205,20 +184,10 @@ final class Acceptor_impl extends org.omg.CORBA.LocalObject implements
             }
         } catch (java.net.ConnectException ex) {
             logger.log(Level.FINE, "Failure making self connection for host=" + localAddress_ + ", port=" + port_, ex);
-            throw new org.omg.CORBA.TRANSIENT(
-                    org.apache.yoko.orb.OB.MinorCodes
-                            .describeTransient(org.apache.yoko.orb.OB.MinorCodes.MinorConnectFailed)
-                            + ": " + ex.getMessage(),
-                    org.apache.yoko.orb.OB.MinorCodes.MinorConnectFailed,
-                    org.omg.CORBA.CompletionStatus.COMPLETED_NO);
+            throw asTransient(ex, MinorConnectFailed);
         } catch (java.io.IOException ex) {
             logger.log(Level.FINE, "Failure making self connection for host=" + localAddress_ + ", port=" + port_, ex);
-            throw (org.omg.CORBA.COMM_FAILURE)new org.omg.CORBA.COMM_FAILURE(
-                    org.apache.yoko.orb.OB.MinorCodes
-                            .describeCommFailure(org.apache.yoko.orb.OB.MinorCodes.MinorSocket)
-                            + ": " + ex.getMessage(),
-                    org.apache.yoko.orb.OB.MinorCodes.MinorSocket,
-                    org.omg.CORBA.CompletionStatus.COMPLETED_NO).initCause(ex);
+            throw asCommFailure(ex, MinorSocket);
         }
 
         //
@@ -232,20 +201,14 @@ final class Acceptor_impl extends org.omg.CORBA.LocalObject implements
                 socket.close();
             } catch (java.io.IOException e) {
             }
-            throw (org.omg.CORBA.COMM_FAILURE)new org.omg.CORBA.COMM_FAILURE(
-                    org.apache.yoko.orb.OB.MinorCodes
-                            .describeCommFailure(org.apache.yoko.orb.OB.MinorCodes.MinorSetsockopt)
-                            + ": " + ex.getMessage(),
-                    org.apache.yoko.orb.OB.MinorCodes.MinorSetsockopt,
-                    org.omg.CORBA.CompletionStatus.COMPLETED_NO).initCause(ex);
+            throw asCommFailure(ex);
         }
 
         //
         // Create and return new transport
         //
-        org.apache.yoko.orb.OCI.Transport tr = null;
         try {
-            tr = new Transport_impl(this, socket, listenMap_);
+            return new Transport_impl(this, socket, listenMap_);
         } catch (org.omg.CORBA.SystemException ex) {
             try {
                 socket.close();
@@ -253,7 +216,6 @@ final class Acceptor_impl extends org.omg.CORBA.LocalObject implements
             }
             throw ex;
         }
-        return tr;
     }
 
     public void add_profiles(org.apache.yoko.orb.OCI.ProfileInfo profileInfo,
@@ -471,12 +433,7 @@ final class Acceptor_impl extends org.omg.CORBA.LocalObject implements
             }
         } catch (java.net.UnknownHostException ex) {
             logger.log(Level.FINE, "Host resolution failure", ex); 
-            throw (org.omg.CORBA.COMM_FAILURE)new org.omg.CORBA.COMM_FAILURE(
-                    org.apache.yoko.orb.OB.MinorCodes
-                            .describeCommFailure(org.apache.yoko.orb.OB.MinorCodes.MinorGethostbyname)
-                            + ": " + ex.getMessage(),
-                    org.apache.yoko.orb.OB.MinorCodes.MinorGethostbyname,
-                    org.omg.CORBA.CompletionStatus.COMPLETED_NO).initCause(ex);
+            throw asCommFailure(ex);
         }
 
         //
@@ -513,12 +470,7 @@ final class Acceptor_impl extends org.omg.CORBA.LocalObject implements
                     org.omg.CORBA.CompletionStatus.COMPLETED_NO).initCause(ex);
         } catch (java.io.IOException ex) {
             logger.log(Level.FINE, "Failure creating server socket for host=" + localAddress_ + ", port=" + port, ex);
-            throw (org.omg.CORBA.COMM_FAILURE)new org.omg.CORBA.COMM_FAILURE(
-                    org.apache.yoko.orb.OB.MinorCodes
-                            .describeCommFailure(org.apache.yoko.orb.OB.MinorCodes.MinorSocket)
-                            + ": " + ex.getMessage(),
-                    org.apache.yoko.orb.OB.MinorCodes.MinorSocket,
-                    org.omg.CORBA.CompletionStatus.COMPLETED_NO).initCause(ex);
+            throw asCommFailure(ex, MinorSocket);
         }
 
         //

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/ConnectorInfoOperations.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/ConnectorInfoOperations.java b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/ConnectorInfoOperations.java
index c222f8b..f6eeea5 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/ConnectorInfoOperations.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/ConnectorInfoOperations.java
@@ -20,6 +20,9 @@ package org.apache.yoko.orb.OCI.IIOP;
 //
 // IDL:orb.yoko.apache.org/OCI/IIOP/ConnectorInfo:1.0
 //
+
+import org.apache.yoko.orb.OCI.Connector;
+
 /**
  *
  * Information on an IIOP OCI Connector object.

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/f580371d/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/ConnectorInfo_impl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/ConnectorInfo_impl.java b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/ConnectorInfo_impl.java
index a076a8d..21411a8 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/ConnectorInfo_impl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OCI/IIOP/ConnectorInfo_impl.java
@@ -17,114 +17,88 @@
 
 package org.apache.yoko.orb.OCI.IIOP;
 
-import org.apache.yoko.orb.OCI.IIOP.ConnectorInfo;
-import org.apache.yoko.orb.OCI.IIOP.PLUGIN_ID;
+import static org.apache.yoko.orb.OCI.IIOP.Exceptions.*;
 
-public final class ConnectorInfo_impl extends org.omg.CORBA.LocalObject
-        implements ConnectorInfo {
-    private Connector_impl connector_; // The associated connector
+import org.apache.yoko.orb.OCI.ConnectCB;
+import org.omg.CORBA.LocalObject;
+import org.omg.IOP.TAG_INTERNET_IOP;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.*;
+
+/**
+ * Immutable memo of the endpoint details for a connection. The InetAddress
+ * is looked up when first needed but never changed again. It is used in
+ * hashcode() and equals().
+ */
+public final class ConnectorInfo_impl extends LocalObject implements ConnectorInfo {
+    private final String host;
+    private final short port;
+    private volatile InetAddress addr; // initialised lazily
 
     //
     // All connect callback objects
     //
-    private java.util.Vector connectCBVec_ = new java.util.Vector();
+    private final List<ConnectCB> callbacks;
 
     // ------------------------------------------------------------------
     // Standard IDL to Java Mapping
     // ------------------------------------------------------------------
 
-    public String id() {
-        return PLUGIN_ID.value;
-    }
+    public String id() {return PLUGIN_ID.value;}
 
-    public int tag() {
-        return org.omg.IOP.TAG_INTERNET_IOP.value;
-    }
-
-    public synchronized String describe() {
-        short remotePort = remote_port();
+    public int tag() {return TAG_INTERNET_IOP.value;}
 
-        String desc = "id: " + PLUGIN_ID.value;
-        desc += "\nremote address: ";
-        desc += remote_addr();
-        desc += ":";
-        desc += (remotePort < 0 ? 0xffff + (int) remotePort + 1 : remotePort);
+    public String describe() {return String.format("id: %s%nremote address: %s:%d", PLUGIN_ID.value, remote_addr(), port);}
 
-        return desc;
-    }
+    public String remote_addr() {return getInetAddress().getHostAddress();}
 
-    public synchronized void add_connect_cb(org.apache.yoko.orb.OCI.ConnectCB cb) {
-        int length = connectCBVec_.size();
-        for (int i = 0; i < length; i++)
-            if (connectCBVec_.elementAt(i) == cb)
-                return; // Already registered
-        connectCBVec_.addElement(cb);
-    }
+    public short remote_port() {return port;}
 
-    public synchronized void remove_connect_cb(
-            org.apache.yoko.orb.OCI.ConnectCB cb) {
-        int length = connectCBVec_.size();
-        for (int i = 0; i < length; i++)
-            if (connectCBVec_.elementAt(i) == cb) {
-                connectCBVec_.removeElementAt(i);
-                return;
-            }
-    }
+    // ------------------------------------------------------------------
+    // Yoko internal functions
+    // Application programs must not use these functions directly
+    // ------------------------------------------------------------------
 
-    public synchronized String remote_addr() {
-        if (connector_ == null)
-            throw new org.omg.CORBA.NO_RESOURCES("No connector");
-
-        try {
-            java.net.InetAddress address = java.net.InetAddress
-                    .getByName(connector_.host_);
-            return address.getHostAddress();
-        } catch (java.net.UnknownHostException ex) {
-            throw new org.omg.CORBA.COMM_FAILURE(
-                    org.apache.yoko.orb.OB.MinorCodes
-                            .describeCommFailure(org.apache.yoko.orb.OB.MinorCodes.MinorGethostbyname)
-                            + ": " + ex.getMessage(),
-                    org.apache.yoko.orb.OB.MinorCodes.MinorGethostbyname,
-                    org.omg.CORBA.CompletionStatus.COMPLETED_NO);
-        }
+    ConnectorInfo_impl(String host, int port, ConnectCB...cb) {
+        this.host = host;
+        this.port = (short)port;
+        if (cb == null || cb.length == 0)
+            callbacks = Collections.emptyList();
+        else
+            callbacks = Collections.unmodifiableList(new ArrayList<ConnectCB>(Arrays.asList(cb)));
     }
 
-    public synchronized short remote_port() {
-        if (connector_ == null)
-            throw new org.omg.CORBA.NO_RESOURCES("No connector");
+    String getHost() { return host; }
 
-        int port = connector_.port_;
+    int getPort() { return (char)port; }
 
-        if (port >= 0x8000)
-            return (short) (port - 0xffff - 1);
-        else
-            return (short) port;
+    private InetAddress getInetAddress() {
+        if (addr == null) synchronized (this) {
+            if (addr == null) try {
+                addr = InetAddress.getByName(host);
+            } catch (UnknownHostException ex) {
+                throw asCommFailure(ex);
+            }
+        }
+        return addr;
     }
 
-    // ------------------------------------------------------------------
-    // Yoko internal functions
-    // Application programs must not use these functions directly
-    // ------------------------------------------------------------------
+    synchronized void _OB_callConnectCB(org.apache.yoko.orb.OCI.TransportInfo info) {
+        for (ConnectCB cb : callbacks) cb.connect_cb(info);
+    }
 
-    ConnectorInfo_impl(Connector_impl connector,
-            org.apache.yoko.orb.OCI.ConnectCB[] cb) {
-        connector_ = connector;
+    @Override
+    public boolean equals(Object other) {
+        if (this == other) return true;
+        if (!!! (other instanceof ConnectorInfo_impl)) return false;
 
-        for (int i = 0; i < cb.length; i++)
-            connectCBVec_.addElement(cb[i]);
-    }
+        ConnectorInfo_impl that = (ConnectorInfo_impl) other;
 
-    synchronized void _OB_callConnectCB(
-            org.apache.yoko.orb.OCI.TransportInfo info) {
-        int length = connectCBVec_.size();
-        for (int i = 0; i < length; i++) {
-            org.apache.yoko.orb.OCI.ConnectCB cb = (org.apache.yoko.orb.OCI.ConnectCB) connectCBVec_
-                    .elementAt(i);
-            cb.connect_cb(info);
-        }
+        return (this.port == that.port) && this.getInetAddress().equals(that.getInetAddress());
     }
 
-    synchronized void _OB_destroy() {
-        connector_ = null;
-    }
+    @Override
+    public int hashCode() {return 31*port + getInetAddress().hashCode();}
 }


Mime
View raw message