|
From: <lk...@us...> - 2004-12-13 10:42:22
|
Update of /cvsroot/openorb/TransactionService/src/main/org/openorb/ots/Admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9943/src/main/org/openorb/ots/Admin Modified Files: Manager.java Log Message: fixed memory leak that was caused by implicit object activations in the RootPOA Index: Manager.java =================================================================== RCS file: /cvsroot/openorb/TransactionService/src/main/org/openorb/ots/Admin/Manager.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Manager.java 10 Feb 2004 21:26:47 -0000 1.9 +++ Manager.java 13 Dec 2004 10:42:10 -0000 1.10 @@ -8,6 +8,13 @@ package org.openorb.ots.Admin; +import java.util.List; + +import org.omg.PortableServer.POA; +import org.omg.CORBA.UserException; +import org.omg.CORBA.INTERNAL; +import org.omg.CosTransactions.ControlHelper; + /** * This class is a manager for the OpenORB OTS. * @@ -19,11 +26,13 @@ /** * The control object list */ - private static java.util.Vector s_controls = new java.util.Vector(); + private List m_controls = new java.util.Vector(); - public static java.util.Vector getControls() + private POA m_poa; + + public List getControls() { - return s_controls; + return m_controls; } /** @@ -31,6 +40,11 @@ */ private static java.util.Vector s_callbacks = new java.util.Vector(); + public Manager( POA poa ) + { + this.m_poa = poa; + } + /** * Return all the controls for current transactions. By this way, it is possible to * get access to the coordinator or the terminator to mage transacton management. @@ -39,10 +53,19 @@ org.openorb.ots.ManagerCallback callback ) { org.omg.CosTransactions.Control [] controls = - new org.omg.CosTransactions.Control[ s_controls.size() ]; - for ( int i = 0; i < s_controls.size(); i++ ) + new org.omg.CosTransactions.Control[ m_controls.size() ]; + for ( int i = 0; i < m_controls.size(); i++ ) { - controls[ i ] = ( ( org.openorb.ots.Impl.Control ) s_controls.elementAt( i ) )._this(); + final org.openorb.ots.Impl.Control servant = + ( org.openorb.ots.Impl.Control ) m_controls.get( i ); + try + { + controls[ i ] = ControlHelper.narrow( m_poa.servant_to_reference( servant ) ); + } + catch ( UserException ex ) + { + throw new INTERNAL( ex.toString() ); + } } return controls; } @@ -50,7 +73,7 @@ /** * This function is used to receive notification for a new transaction. */ - public static void notifyNewTransaction( org.openorb.ots.Impl.Control ctrl, + public void notifyNewTransaction( org.openorb.ots.Impl.Control ctrl, org.openorb.ots.Impl.XID xid ) { org.openorb.ots.XID myXid = new org.openorb.ots.XID(); @@ -59,9 +82,18 @@ myXid.bqual = xid.get_bqual(); myXid.gtrid = xid.get_gtrid(); - org.omg.CosTransactions.Control ctrl_ref = ctrl._this(); + org.omg.CosTransactions.Control ctrl_ref; - s_controls.addElement( ctrl ); + try + { + ctrl_ref = ControlHelper.narrow( m_poa.servant_to_reference( ctrl ) ); + } + catch ( UserException ex ) + { + throw new INTERNAL( ex.toString() ); + } + + m_controls.add( ctrl ); org.openorb.ots.ManagerCallback callback = null; |