to.etc.webapp.query
Class QContextManager

java.lang.Object
  extended by to.etc.webapp.query.QContextManager

public final class QContextManager
extends java.lang.Object

Fugly singleton helper class to globally access database stuff.

Author:
Frits Jalvingh Created on Jul 15, 2009

Method Summary
static void closeSharedContext(IQContextContainer cc)
          If the specified container contains a shared context close it.
static QDataContext createUnmanagedContext()
          Create an unmanaged (manually closed) context factory.
static QDataContext getContext(IQContextContainer cc)
          Gets a shared QDataContext from the container.
static QDataContextFactory getDataContextFactory()
          Return the default QDataContextFactory.
static QDataContextFactory getDataContextFactory(IQContextContainer cc)
          Get/create a shared context factory.
static void initialize(QDataContextFactory f)
          Initialize the QContextManager with a literal QDataContextFactory.
static void setImplementation(IQContextManager cm)
          Override the default implementation of QContextManager with your own.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setImplementation

public static void setImplementation(IQContextManager cm)
Override the default implementation of QContextManager with your own. This must be called before QContextManager is ever used.

Parameters:
cm -

initialize

public static void initialize(QDataContextFactory f)
Initialize the QContextManager with a literal QDataContextFactory.

Parameters:
f -

getDataContextFactory

public static QDataContextFactory getDataContextFactory()
Return the default QDataContextFactory. This is the root of *all* default connections allocated through DomUI. This either returns the single factory, or it asks the delegate to get a factory, allowing the delegate to return a user-specific factory.

Returns:

createUnmanagedContext

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

Returns:
Throws:
java.lang.Exception

getDataContextFactory

public static QDataContextFactory getDataContextFactory(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.

Parameters:
cc -
Returns:

getContext

public static QDataContext getContext(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.

Throws:
java.lang.Exception

closeSharedContext

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

Parameters:
cc -