Search in sources :

Example 1 with SimpleJdbcCallOperations

use of org.springframework.jdbc.core.simple.SimpleJdbcCallOperations in project spring-integration by spring-projects.

the class StoredProcExecutor method obtainSimpleJdbcCall.

private SimpleJdbcCallOperations obtainSimpleJdbcCall(String storedProcedureName) {
    if (guavaPresent) {
        return this.guavaCacheWrapper.jdbcCallOperationsCache.getUnchecked(storedProcedureName);
    } else {
        SimpleJdbcCallOperations operations = this.jdbcCallOperationsMap.get(storedProcedureName);
        if (operations == null) {
            synchronized (this.jdbcCallOperationsMapMonitor) {
                operations = this.jdbcCallOperationsMap.get(storedProcedureName);
                if (operations == null) {
                    operations = createSimpleJdbcCall(storedProcedureName);
                    this.jdbcCallOperationsMap.put(storedProcedureName, operations);
                }
            }
        }
        return operations;
    }
}
Also used : SimpleJdbcCallOperations(org.springframework.jdbc.core.simple.SimpleJdbcCallOperations)

Example 2 with SimpleJdbcCallOperations

use of org.springframework.jdbc.core.simple.SimpleJdbcCallOperations in project spring-integration by spring-projects.

the class StoredProcExecutorTests method mockTheOperationsCache.

private void mockTheOperationsCache(final StoredProcExecutor storedProcExecutor) {
    Object cache = TestUtils.getPropertyValue(storedProcExecutor, "guavaCacheWrapper.jdbcCallOperationsCache.localCache");
    new DirectFieldAccessor(cache).setPropertyValue("defaultLoader", new CacheLoader<String, SimpleJdbcCallOperations>() {

        @Override
        public SimpleJdbcCall load(String storedProcedureName) {
            return mock(SimpleJdbcCall.class);
        }
    });
}
Also used : DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SimpleJdbcCallOperations(org.springframework.jdbc.core.simple.SimpleJdbcCallOperations) SimpleJdbcCall(org.springframework.jdbc.core.simple.SimpleJdbcCall)

Example 3 with SimpleJdbcCallOperations

use of org.springframework.jdbc.core.simple.SimpleJdbcCallOperations in project spring-integration by spring-projects.

the class StoredProcExecutor method executeStoredProcedureInternal.

/**
 * Execute the Stored Procedure using the passed in {@link Message} as a source
 * for parameters.
 *
 * @param input The message is used to extract parameters for the stored procedure.
 * @return A map containing the return values from the Stored Procedure call if any.
 */
private Map<String, Object> executeStoredProcedureInternal(Object input, String storedProcedureName) {
    Assert.notNull(this.sqlParameterSourceFactory, "Property sqlParameterSourceFactory " + "was Null. Did you call afterPropertiesSet()?");
    SimpleJdbcCallOperations localSimpleJdbcCall = obtainSimpleJdbcCall(storedProcedureName);
    SqlParameterSource storedProcedureParameterSource = this.sqlParameterSourceFactory.createParameterSource(input);
    return localSimpleJdbcCall.execute(storedProcedureParameterSource);
}
Also used : SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) SimpleJdbcCallOperations(org.springframework.jdbc.core.simple.SimpleJdbcCallOperations)

Aggregations

SimpleJdbcCallOperations (org.springframework.jdbc.core.simple.SimpleJdbcCallOperations)3 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)1 SimpleJdbcCall (org.springframework.jdbc.core.simple.SimpleJdbcCall)1