Package org.forgerock.openig.filter
Class SqlAttributesFilter
- java.lang.Object
-
- org.forgerock.openig.filter.SqlAttributesFilter
-
- All Implemented Interfaces:
org.forgerock.http.Filter
public class SqlAttributesFilter extends Object implements org.forgerock.http.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 aMapobject, whose location is specified by thetargetexpression. 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
parametersexpressions will not be evaluated until the map is first accessed.- See Also:
PreparedStatement
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSqlAttributesFilter.HeapletCreates and initializes a static attribute provider in a heap environment.
-
Constructor Summary
Constructors Constructor Description 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 aMapin the specified target.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.forgerock.util.promise.Promise<org.forgerock.http.protocol.Response,org.forgerock.util.promise.NeverThrowsException>filter(org.forgerock.services.context.Context context, org.forgerock.http.protocol.Request request, org.forgerock.http.Handler next)List<Expression<?>>getParameters()Returns the list of parameters to evaluate and include in the execution of the prepared statement.
-
-
-
Constructor Detail
-
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 aMapin 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 Detail
-
getParameters
public List<Expression<?>> 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 org.forgerock.util.promise.Promise<org.forgerock.http.protocol.Response,org.forgerock.util.promise.NeverThrowsException> filter(org.forgerock.services.context.Context context, org.forgerock.http.protocol.Request request, org.forgerock.http.Handler next)- Specified by:
filterin interfaceorg.forgerock.http.Filter
-
-