JAVA-11499 move rxjava* modules to new rxjava-modules (#12342)

* JAVA-11499 move rxjava* modules to new rxjava-modules

* JAVA-11499 addressed PR comments
This commit is contained in:
Keerthi
2022-06-19 01:51:25 +10:00
committed by GitHub
parent 467d2d5b3a
commit eb99a50559
64 changed files with 79 additions and 111 deletions

View File

@@ -0,0 +1,32 @@
package com.baeldung.rxjava;
import com.jakewharton.rxrelay2.Relay;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposables;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class RandomRelay extends Relay<Integer> {
Random random = new Random();
List<Observer<? super Integer>> observers = new ArrayList<>();
@Override
public void accept(Integer integer) {
int observerIndex = random.nextInt(observers.size()) & Integer.MAX_VALUE;
observers.get(observerIndex).onNext(integer);
}
@Override
public boolean hasObservers() {
return observers.isEmpty();
}
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observers.add(observer);
observer.onSubscribe(Disposables.fromRunnable(() -> System.out.println("Disposed")));
}
}

View File

@@ -0,0 +1,13 @@
package com.baeldung.rxjava.jdbc;
import com.github.davidmoten.rx.jdbc.ConnectionProvider;
import com.github.davidmoten.rx.jdbc.ConnectionProviderFromUrl;
class Connector {
private static final String DB_CONNECTION = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1";
private static final String DB_USER = "";
private static final String DB_PASSWORD = "";
static final ConnectionProvider connectionProvider = new ConnectionProviderFromUrl(DB_CONNECTION, DB_USER, DB_PASSWORD);
}

View File

@@ -0,0 +1,13 @@
package com.baeldung.rxjava.jdbc;
import com.github.davidmoten.rx.jdbc.annotations.Column;
public interface Employee {
@Column("id")
int id();
@Column("name")
String name();
}

View File

@@ -0,0 +1,28 @@
package com.baeldung.rxjava.jdbc;
public class Manager {
private int id;
private String name;
public Manager(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -0,0 +1,16 @@
package com.baeldung.rxjava.jdbc;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import org.apache.commons.io.IOUtils;
class Utils {
static String getStringFromInputStream(InputStream input) throws IOException {
StringWriter writer = new StringWriter();
IOUtils.copy(input, writer, "UTF-8");
return writer.toString();
}
}