to.etc.webapp.query
Class QDefaultContextManager

java.lang.Object
  extended by to.etc.webapp.query.QDefaultContextManager
All Implemented Interfaces:
IQContextManager

public class QDefaultContextManager
extends java.lang.Object
implements IQContextManager

Default implementation of a QContextManager.

Author:
Frits Jalvingh Created on Jul 17, 2009

Constructor Summary
QDefaultContextManager()
           
 
Method Summary
 void closeSharedContext(IQContextContainer cc)
          If the specified container contains a shared context close it.
 QDataContext createUnmanagedContext()
          Create an unmanaged (manually closed) context factory.
 QDataContextFactory getDataContextFactory()
          Return the default QDataContextFactory.
 QDataContext getSharedContext(IQContextContainer cc)
          Gets a shared QDataContext from the container.
 QDataContextFactory getSharedContextFactory(IQContextContainer cc)
          Get/create a shared context factory.
 void setContextFactory(QDataContextFactory f)
          Initialize the data context factory that is to be used by default to allocate QDataContexts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QDefaultContextManager

public QDefaultContextManager()
Method Detail

setContextFactory

public void setContextFactory(QDataContextFactory f)
Initialize the data context factory that is to be used by default to allocate QDataContexts. Can be called only once.

Specified by:
setContextFactory in interface IQContextManager
See Also:
IQContextManager.setContextFactory(to.etc.webapp.query.QDataContextFactory)

getDataContextFactory

public QDataContextFactory getDataContextFactory()
Return the default QDataContextFactory. This is the root of *all* default connections allocated through DomUI.

Specified by:
getDataContextFactory in interface IQContextManager
Returns:
See Also:
IQContextManager.getDataContextFactory()

createUnmanagedContext

public QDataContext createUnmanagedContext()
                                    throws java.lang.Exception
Create an unmanaged (manually closed) context factory.

Specified by:
createUnmanagedContext in interface IQContextManager
Returns:
Throws:
java.lang.Exception
See Also:
IQContextManager.createUnmanagedContext()

getSharedContextFactory

public QDataContextFactory getSharedContextFactory(IQContextContainer cc)
Get/create a shared context factory. The context factory gets attached to the container it is shared in, and will always try to re-use any QDataContext already present in the container. In addition, all data contexts allocated thru this mechanism have a disabled close() method, preventing them from closing the shared connection.

Specified by:
getSharedContextFactory in interface IQContextManager
Returns:
See Also:
IQContextManager.getSharedContextFactory(to.etc.webapp.query.IQContextContainer)

getSharedContext

public QDataContext getSharedContext(IQContextContainer cc)
                              throws java.lang.Exception
Gets a shared QDataContext from the container. If it is not already present it will be allocated, stored in the container for later reuse and returned. The context is special in that it cannot be closed() using it's close() call - it is silently ignored.

Specified by:
getSharedContext in interface IQContextManager
Throws:
java.lang.Exception
See Also:
IQContextManager.getSharedContext(to.etc.webapp.query.IQContextContainer)

closeSharedContext

public void closeSharedContext(IQContextContainer cc)
If the specified container contains a shared context close it.

Specified by:
closeSharedContext in interface IQContextManager
See Also:
IQContextManager.closeSharedContext(to.etc.webapp.query.IQContextContainer)