db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: db-ojb/src/jca/org/apache/ojb/otm/connector OTMJCAConnection.java
Date Wed, 02 Jul 2003 01:13:03 GMT
mattbaird    2003/07/01 18:13:03

  Modified:    src/jca/org/apache/ojb/otm/connector OTMJCAConnection.java
  Log:
  was leaking connections in the close() call.
  
  Revision  Changes    Path
  1.2       +32 -1     db-ojb/src/jca/org/apache/ojb/otm/connector/OTMJCAConnection.java
  
  Index: OTMJCAConnection.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/jca/org/apache/ojb/otm/connector/OTMJCAConnection.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OTMJCAConnection.java	1 Jul 2003 21:04:27 -0000	1.1
  +++ OTMJCAConnection.java	2 Jul 2003 01:13:02 -0000	1.2
  @@ -72,6 +72,7 @@
   public class OTMJCAConnection implements OTMConnection
   {
   	private OTMJCAManagedConnection m_managedConnection;
  +	private boolean m_closed = false;
   
   	public OTMJCAConnection(OTMJCAManagedConnection mc)
   	{
  @@ -91,71 +92,101 @@
   
   	public void makePersistent(Object o) throws LockingException
   	{
  +		checkStatus();
   		m_managedConnection.getConnection().makePersistent(o);
   	}
   
   	public void deletePersistent(Object o) throws LockingException
   	{
  +		checkStatus();
   		m_managedConnection.getConnection().deletePersistent(o);
   	}
   
   	public void lockForWrite(Object o) throws LockingException
   	{
  +		checkStatus();
   		m_managedConnection.getConnection().lockForWrite(o);
   	}
   
   	public Object getObjectByIdentity(Identity identity) throws LockingException
   	{
  +		checkStatus();
   		return m_managedConnection.getConnection().getObjectByIdentity(identity);
   	}
   
   	public Object getObjectByIdentity(Identity identity, int i) throws LockingException
   	{
  +		checkStatus();
   		return m_managedConnection.getConnection().getObjectByIdentity(identity, i);
   	}
   
   	public Iterator getIteratorByQuery(Query query)
   	{
  +		checkStatus();
   		return m_managedConnection.getConnection().getIteratorByQuery(query);
   	}
   
   	public Iterator getIteratorByQuery(Query query, int i)
   	{
  +		checkStatus();
   		return m_managedConnection.getConnection().getIteratorByQuery(query, i);
   	}
   
   	public Identity getIdentity(Object o)
   	{
  +		checkStatus();
   		return m_managedConnection.getConnection().getIdentity(o);
   	}
   
   	public ClassDescriptor getDescriptorFor(Class aClass)
   	{
  +		checkStatus();
   		return m_managedConnection.getConnection().getDescriptorFor(aClass);
   	}
   
   	public EditingContext getEditingContext()
   	{
  +		checkStatus();
   		return m_managedConnection.getConnection().getEditingContext();
   	}
   
   	public void invalidate(Identity identity) throws LockingException
   	{
  +		checkStatus();
   		m_managedConnection.getConnection().invalidate(identity);
   	}
   
   	public EnhancedOQLQuery newOQLQuery()
   	{
  +		checkStatus();
   		return m_managedConnection.getConnection().newOQLQuery();
   	}
   
   	public int getCount(Query query)
   	{
  +		checkStatus();
   		return m_managedConnection.getConnection().getCount(query);
   	}
   
   	public void close()
   	{
  -		//m_managedConnection.getConnection().close();
  +		m_closed = true;
  +		if (m_managedConnection != null)
  +		{
  +			m_managedConnection.closeHandle(this);
  +		}
  +		m_managedConnection = null;
  +	}
  +
  +	protected void checkStatus() throws OTMConnectionRuntimeException
  +	{
  +		if (m_closed)
  +		{
  +			throw new OTMConnectionRuntimeException("Connection handle has been closed and is unusable");
  +		}
  +		if (m_managedConnection == null)
  +		{
  +			throw new OTMConnectionRuntimeException("Connection handle is not currently associated
with a ManagedConnection");
  +		}
   	}
   }
  
  
  

Mime
View raw message