com.trendmicro.grid.acl.ds.jpa.util
Class FileQueryConfigurator<T>

java.lang.Object
  extended by com.trendmicro.grid.acl.ds.jpa.util.FileQueryConfigurator<T>
Type Parameters:
T - The type of the expected result.

public class FileQueryConfigurator<T>
extends Object

Is a helper class that configures and caches queries that fetch results by FileIdentifier.

Note: Instanes of this class are meant to be short lived for the time of a single transaction.


Constructor Summary
FileQueryConfigurator(javax.persistence.EntityManager em, Class<T> resultType, String queryBaseName)
          Creates a new configurator.
FileQueryConfigurator(javax.persistence.EntityManager em, Class<T> resultType, String md5QueryName, String sha1QueryName, String fullQueryName)
          Creates a new configurator.
 
Method Summary
 javax.persistence.TypedQuery<T> getQuery(com.trendmicro.grid.acl.l0.datatypes.FileIdentifier file)
          Returns the configured query.
 javax.persistence.Query getUntypedQuery(com.trendmicro.grid.acl.l0.datatypes.FileIdentifier file)
          Returns the configured query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileQueryConfigurator

public FileQueryConfigurator(javax.persistence.EntityManager em,
                             Class<T> resultType,
                             String queryBaseName)
Creates a new configurator.

Parameters:
em - the entitymanager to use for retrieving the queries.
resultType - the result type of the queries.
queryBaseName - the common base name for both queries.

FileQueryConfigurator

public FileQueryConfigurator(javax.persistence.EntityManager em,
                             Class<T> resultType,
                             String md5QueryName,
                             String sha1QueryName,
                             String fullQueryName)
Creates a new configurator.

Parameters:
em - the entitymanager to use for retrieving the queries.
resultType - the result type of the queries.
sha1QueryName - the name of the named sha1-only query
fullQueryName - the name of the named sha1+md5 query.
Method Detail

getQuery

public javax.persistence.TypedQuery<T> getQuery(com.trendmicro.grid.acl.l0.datatypes.FileIdentifier file)
Returns the configured query.

Parameters:
file - the identifier specifying the file to ask for.
Returns:
the configured query.

getUntypedQuery

public javax.persistence.Query getUntypedQuery(com.trendmicro.grid.acl.l0.datatypes.FileIdentifier file)
Returns the configured query.

Parameters:
file - the identifier specifying the file to ask for.
Returns:
the configured query.