Package org.forgerock.openig.sql
Class SqlAttributesFilter
java.lang.Object
org.forgerock.openig.sql.SqlAttributesFilter
- All Implemented Interfaces:
Filter
Executes a SQL query through a prepared statement and exposes its first result. Parameters
in the prepared statement are derived from expressions. The query result is
exposed in a
Map
object, whose location is specified by the target
expression. If the query yields no result, then the resulting map will be empty.
The execution of the query is performed lazily; it does not occur until the first attempt
to access a value in the target. This defers the overhead of connection pool, network
and database query processing until a value is first required. This also means that the
parameters
expressions will not be evaluated until the map is first accessed.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Creates and initializes a static attribute provider in a heap environment. -
Constructor Summary
ConstructorDescriptionSqlAttributesFilter
(DataSource dataSource, LeftValueExpression<Map> target, String preparedStatement) Builds a new SqlAttributesFilter that will execute the given SQL statement on the givenDataSource
, placing the results in aMap
in the specified target. -
Method Summary
Modifier and TypeMethodDescriptionFilters the request and/or response of an exchange.List<Expression<?>>
Returns the list of parameters to evaluate and include in the execution of the prepared statement.
-
Constructor Details
-
SqlAttributesFilter
public SqlAttributesFilter(DataSource dataSource, LeftValueExpression<Map> target, String preparedStatement) Builds a new SqlAttributesFilter that will execute the given SQL statement on the givenDataSource
, placing the results in aMap
in the specified target.- Parameters:
dataSource
- JDBC data sourcetarget
- Expression that yields the target object that will contain the mapped resultspreparedStatement
- The parameterized SQL query to execute, with ? parameter placeholders
-
-
Method Details
-
getParameters
Returns the list of parameters to evaluate and include in the execution of the prepared statement.- Returns:
- the list of parameters to evaluate and include in the execution of the prepared statement.
-
filter
public Promise<Response,NeverThrowsException> filter(Context context, Request request, Handler next) Description copied from interface:Filter
Filters the request and/or response of an exchange. To pass the request to the next filter or handler in the chain, the filter callsnext.handle(context, request)
.This method may elect not to pass the request to the next filter or handler, and instead handle the request itself. It can achieve this by merely avoiding a call to
next.handle(context, request)
and creating its own response object. The filter is also at liberty to replace a response with another of its own by intercepting the response returned by the next handler.
-