Package org.hawaiiframework.sql
Class ResourceSqlQueryResolver
- java.lang.Object
-
- org.hawaiiframework.sql.AbstractCachingSqlQueryResolver
-
- org.hawaiiframework.sql.ResourceSqlQueryResolver
-
- All Implemented Interfaces:
SqlQueryResolver
,org.springframework.core.Ordered
public class ResourceSqlQueryResolver extends AbstractCachingSqlQueryResolver implements org.springframework.core.Ordered
Simple implementation ofSqlQueryResolver
resolving sql queries using Spring's genericResourceLoader
mechanism.- Since:
- 2.0.0
- Author:
- Marcel Overdijk, Paul Klos
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.hawaiiframework.sql.AbstractCachingSqlQueryResolver
AbstractCachingSqlQueryResolver.QueryHolder
-
-
Field Summary
Fields Modifier and Type Field Description static Charset
DEFAULT_CHARSET
Default charset for retrieving sql query resources (UTF_8
).-
Fields inherited from class org.hawaiiframework.sql.AbstractCachingSqlQueryResolver
DEFAULT_CACHE_LIMIT
-
-
Constructor Summary
Constructors Constructor Description ResourceSqlQueryResolver()
ResourceSqlQueryResolver(org.springframework.core.io.ResourceLoader resourceLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doRefreshQueryHolder(String sqlQueryName, AbstractCachingSqlQueryResolver.QueryHolder queryHolder)
Subclasses may override this method to implement their own expiry mechanism.Charset
getCharset()
Return theCharset
for retrieving sql query resources.int
getOrder()
Return the order in which thisSqlQueryResolver
is evaluated.protected String
getPrefix()
Return the prefix that gets prepended to sql query names when building the resource location.protected String
getSuffix()
Return the suffix that gets appended to sql query names when building the resource location.protected String
loadSqlQuery(String sqlQueryName, AbstractCachingSqlQueryResolver.QueryHolder queryHolder)
Subclasses must implement this method to load the sql query.void
setCharset(Charset charset)
Set theCharset
for retrieving sql query resources.void
setOrder(int order)
Set the order in which thisSqlQueryResolver
is evaluated.void
setPrefix(String prefix)
Set the prefix that gets prepended to sql query names when building the resource location.void
setSuffix(String suffix)
Set the suffix that gets appended to sql query names when building the resource location.-
Methods inherited from class org.hawaiiframework.sql.AbstractCachingSqlQueryResolver
clearCache, getCacheKey, getCacheLimit, isCache, removeFromCache, resolveSqlQuery, setCache, setCacheLimit, setCacheSeconds, setCacheUnresolved
-
-
-
-
Field Detail
-
DEFAULT_CHARSET
public static final Charset DEFAULT_CHARSET
Default charset for retrieving sql query resources (UTF_8
).
-
-
Method Detail
-
getCharset
public Charset getCharset()
Return theCharset
for retrieving sql query resources.
-
setCharset
public void setCharset(Charset charset)
Set theCharset
for retrieving sql query resources.
-
getPrefix
protected String getPrefix()
Return the prefix that gets prepended to sql query names when building the resource location.
-
setPrefix
public void setPrefix(String prefix)
Set the prefix that gets prepended to sql query names when building the resource location.
-
getSuffix
protected String getSuffix()
Return the suffix that gets appended to sql query names when building the resource location.
-
setSuffix
public void setSuffix(String suffix)
Set the suffix that gets appended to sql query names when building the resource location.
-
getOrder
public int getOrder()
Return the order in which thisSqlQueryResolver
is evaluated.- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-
setOrder
public void setOrder(int order)
Set the order in which thisSqlQueryResolver
is evaluated.
-
doRefreshQueryHolder
protected void doRefreshQueryHolder(String sqlQueryName, AbstractCachingSqlQueryResolver.QueryHolder queryHolder)
Description copied from class:AbstractCachingSqlQueryResolver
Subclasses may override this method to implement their own expiry mechanism. The default implementation does nothing, i.e. once a query is cached it will never be updated.This method is only called when the current thread has a lock on the QueryHolder, so subclasses need not deal with thread-safety.
- Overrides:
doRefreshQueryHolder
in classAbstractCachingSqlQueryResolver
- Parameters:
sqlQueryName
- the name of the query to refreshqueryHolder
- the cached QueryHolder to check
-
loadSqlQuery
protected String loadSqlQuery(String sqlQueryName, AbstractCachingSqlQueryResolver.QueryHolder queryHolder) throws HawaiiException
Description copied from class:AbstractCachingSqlQueryResolver
Subclasses must implement this method to load the sql query. The returned sql queries will be cached by thisSqlQueryResolver
base class.- Specified by:
loadSqlQuery
in classAbstractCachingSqlQueryResolver
- Parameters:
sqlQueryName
- the name of the sql query to retrievequeryHolder
- the QueryHolder to enrich- Returns:
- the sql query, or
null
if not found (optional, to allow forSqlQueryResolver
chaining) - Throws:
HawaiiException
- if the sql query could not be resolved (typically in case of problems resolving the sql query)- See Also:
AbstractCachingSqlQueryResolver.resolveSqlQuery(java.lang.String)
-
-