--- AOM.java.orig 2007-08-23 10:46:46.044339500 +0200 +++ AOM.java 2007-08-29 11:12:41.868090200 +0200 @@ -36,6 +36,10 @@ import org.apache.avalon.framework.logger.Logger; +import edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue; +import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue; + + /** * This class maps object id's to servants and vice versa. * A oid/servant pair can be added/removed using add(),remove(). @@ -72,6 +76,30 @@ private final byte[] deactivationListLock = new byte[0]; + private BlockingQueue removalQueue = new LinkedBlockingQueue(); + + class RemovalStruct + { + byte[] oid_; + RequestController requestController_ ; + ServantActivator servantActivator_; + POA poa_; + boolean cleanupInProgress_; + + public RemovalStruct(byte[] oid_, RequestController requestController_, + ServantActivator servantActivator_, POA poa_, boolean cleanupInProgress_) + { + super(); + this.oid_ = oid_; + this.requestController_ = requestController_; + this.servantActivator_ = servantActivator_; + this.poa_ = poa_; + this.cleanupInProgress_ = cleanupInProgress_; + } + }; + + + protected AOM (boolean _unique, Logger _logger) { unique = _unique; @@ -81,6 +109,36 @@ { servantMap = new Hashtable(); } + + Thread thread = new Thread("AOM_RemovalThread") + { + + public void run() + { + while (true) + { + try + { + RemovalStruct rs = (RemovalStruct)removalQueue.take(); + _remove( + rs.oid_, + rs.requestController_, + rs.servantActivator_, + rs.poa_, + rs.cleanupInProgress_ + ); + + } + catch (InterruptedException e) + { + throw new RuntimeException(e); + } + + } + } + }; + thread.start(); + } @@ -366,21 +424,23 @@ final POA poa_ = poa; final boolean cleanupInProgress_ = cleanupInProgress; - Thread thread = new Thread("AOM_RemovalThread") - { - public void run() - { - _remove( - oid_, - requestController_, - servantActivator_, - poa_, - cleanupInProgress_ - ); - } - }; - thread.start(); + RemovalStruct rs = new RemovalStruct(oid_, + requestController_, + servantActivator_, + poa_, + cleanupInProgress_ + ); + + try + { + removalQueue.put(rs); + } + catch (InterruptedException e) + { + throw new RuntimeException(e); + } + }