All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alexkasko.springjdbc.parallel.ExceptionHolder Maven / Gradle / Ivy

Go to download

Processes given SQL query in parallel in multiple data sources (assuming that all data source contain the same data). Combined results from multiple queries are exposed to application as java.util.Iterator. Worker thread use spring's JdbcTemplate with named parameters support.

There is a newer version: 1.2.3
Show newest version
package com.alexkasko.springjdbc.parallel;

import java.util.concurrent.atomic.AtomicReference;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Worker exception holder, holds only first setted value, ignores subsequent values.
 * Throws stored exception on demand.
 * Thread-safe.
 *
 * @author alexkasko
 * Date: 6/12/12
 */
class ExceptionHolder {
    private AtomicReference target = new AtomicReference();

    /**
     * Returns stored exception or null
     *
     * @return stored exception or null
     */
    RuntimeException get() {
        return target.get();
    }

    /**
     * @param target value to set, ignored if value was already set
     */
    void set(RuntimeException target) {
        checkNotNull(target, "Holded value must be non null");
        this.target.compareAndSet(null, target);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy