com.h3c.util.persistence.cassandra

## Class DataStoreContext

- java.lang.Object
- - com.h3c.util.persistence.cassandra.DataStoreContext

-     public class DataStoreContext
      extends Object

  `DataStoreContext` provides the context for a given query operation. Each query needs to have an `EntityManager` object and a lock manager object to complete the operation.

  This class acts as a container for these objects and are used in the DAO methods.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataStoreContext(EntityManager em)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `EntityManager` | `getContext()` This method is used extensively in the DAO to retrieve the EntityManager object for a given query.
    `com.h3c.util.persistence.cassandra.lockmgr.impl.AbstractLockMgr` | `getTransactionContext()` This method is used extensively in the DAO to retrieve the LockManager object for a given query.
    `void` | `setTransactionContext(com.h3c.util.persistence.cassandra.lockmgr.impl.AbstractLockMgr lockMgr)` This method sets the Transaction context.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DataStoreContext

          public DataStoreContext(EntityManager em)

      Constructor. Called from the UnitOfWork. The EntityManager object is created in the UnitOfWork using the EntityManagerFactory and passed in as an argument. The LockManager defaults to a fake lock manager making the query non-transactional.
      Parameters:
        `em` - The EntityManager object instance.

  - ### Method Detail

    - #### getContext

          public EntityManager getContext()

      This method is used extensively in the DAO to retrieve the EntityManager object for a given query.
      Returns:
        The EntityManager object

    - #### setTransactionContext

          public void setTransactionContext(com.h3c.util.persistence.cassandra.lockmgr.impl.AbstractLockMgr lockMgr)

      This method sets the Transaction context. If the query is transactional, then an appropriate implementation of the lock manager interface is used to provide locking mechanism. This method sets the object of the selected implementation in the context.
      Parameters:
        `lockMgr` - The LockManager implementation for a given query.

    - #### getTransactionContext

          public com.h3c.util.persistence.cassandra.lockmgr.impl.AbstractLockMgr getTransactionContext()

      This method is used extensively in the DAO to retrieve the LockManager object for a given query.
      Returns:
        The LockManager object

Copyright © 2014. All Rights Reserved.