package com.github.davidmoten.rx.jdbc;

import java.sql.ResultSet;

import rx.Observable;
import rx.util.functions.Func1;

public class Handlers {

	private final Func1<Observable<ResultSet>, Observable<ResultSet>> selectHandler;
	private final Func1<Observable<Integer>, Observable<Integer>> updateHandler;

	public Handlers(
			Func1<Observable<ResultSet>, Observable<ResultSet>> selectHandler,
			Func1<Observable<Integer>, Observable<Integer>> updateHandler) {
		super();
		this.selectHandler = selectHandler;
		this.updateHandler = updateHandler;
	}

	public Func1<Observable<ResultSet>, Observable<ResultSet>> selectHandler() {
		return selectHandler;
	}

	public Func1<Observable<Integer>, Observable<Integer>> updateHandler() {
		return updateHandler;
	}

}

@@ -59,16 +59,48 @@
 sultSet;
+%0Aimport java.util.logging.Level;
 %0A%0Aimport
@@ -129,54 +129,256 @@
  rx.
-util.functions.Func1;%0A%0Apublic class Handlers %7B
+Observable.OnSubscribeFunc;%0Aimport rx.Observer;%0Aimport rx.Subscription;%0Aimport rx.util.functions.Func1;%0A%0Apublic class Handlers %7B%0A%0A%09private static final java.util.logging.Logger log = java.util.logging.Logger%0A%09%09%09.getLogger(Handlers.class.getName());
 %0A%0A%09p
@@ -991,10 +991,1117 @@
 er;%0A%09%7D%0A%0A
+%09public static Func1%3CObservable%3CObject%3E, Observable%3CObject%3E%3E utilLoggingOnErrorLoggerHandler() %7B%0A%09%09return new Func1%3CObservable%3CObject%3E, Observable%3CObject%3E%3E() %7B%0A%0A%09%09%09@Override%0A%09%09%09public Observable%3CObject%3E call(Observable%3CObject%3E source) %7B%0A%09%09%09%09return Observable%0A%09%09%09%09%09%09.create(createLogOnErrorOnSubscribeFunc(source));%0A%09%09%09%7D%0A%0A%09%09%7D;%0A%09%7D%0A%0A%09private static OnSubscribeFunc%3CObject%3E createLogOnErrorOnSubscribeFunc(%0A%09%09%09final Observable%3CObject%3E source) %7B%0A%09%09return new OnSubscribeFunc%3CObject%3E() %7B%0A%0A%09%09%09@Override%0A%09%09%09public Subscription onSubscribe(final Observer%3C? super Object%3E o) %7B%0A%09%09%09%09final Subscription sub = source%0A%09%09%09%09%09%09.subscribe(new Observer%3CObject%3E() %7B%0A%0A%09%09%09%09%09%09%09@Override%0A%09%09%09%09%09%09%09public void onCompleted() %7B%0A%09%09%09%09%09%09%09%09o.onCompleted();%0A%09%09%09%09%09%09%09%7D%0A%0A%09%09%09%09%09%09%09@Override%0A%09%09%09%09%09%09%09public void onError(Throwable e) %7B%0A%09%09%09%09%09%09%09%09log.log(Level.SEVERE, e.getMessage(), e);%0A%09%09%09%09%09%09%09%09o.onError(e);%0A%09%09%09%09%09%09%09%7D%0A%0A%09%09%09%09%09%09%09@Override%0A%09%09%09%09%09%09%09public void onNext(Object args) %7B%0A%09%09%09%09%09%09%09%09o.onNext(args);%0A%09%09%09%09%09%09%09%7D%0A%09%09%09%09%09%09%7D);%0A%09%09%09%09return new Subscription() %7B%0A%09%09%09%09%09@Override%0A%09%09%09%09%09public void unsubscribe() %7B%0A%09%09%09%09%09%09sub.unsubscribe();%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D;%0A%09%09%09%7D%0A%09%09%7D;%0A%09%7D%0A
 %7D%0A

add Handlers