Push existing project to GitLab

parents
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="abs_poc_file_manipulation" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>abs_poc_file_manipulation</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>
<!-- test data -->
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-bom</artifactId>
<version>2020.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>8</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package org.abs.exercise;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
public class DefaultSubscriber implements Subscriber<Object> {
private String name = "";
public DefaultSubscriber(String name) {
this.name = name + " - ";
}
public DefaultSubscriber() {
}
@Override
public void onSubscribe(Subscription subscription) {
subscription.request(Long.MAX_VALUE);
}
@Override
public void onNext(Object o) {
System.out.println(name + "Received : " + o);
}
@Override
public void onError(Throwable throwable) {
System.out.println(name + "ERROR : " + throwable.getMessage());
}
@Override
public void onComplete() {
System.out.println(name + "Completed");
}
}
package org.abs.exercise;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import java.time.LocalDateTime;
import java.util.concurrent.CountDownLatch;
public class StockPriceApplication {
public static void main(String[] args) throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
StockPriceFluxPublisher.getPrice()
.subscribeWith(new Subscriber<Integer>() {
private Subscription subscription;
@Override
public void onSubscribe(Subscription subscription) {
this.subscription = subscription;
subscription.request(Long.MAX_VALUE);
}
@Override
public void onNext(Integer price) {
System.out.println(LocalDateTime.now()+ ": Price :" + price);
if(price>110 || price<90){
this.subscription.cancel();
latch.countDown();
}
}
@Override
public void onError(Throwable throwable) {
latch.countDown();
}
@Override
public void onComplete() {
latch.countDown();
}
});
latch.await();
}
}
package org.abs.exercise;
import reactor.core.publisher.Flux;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicInteger;
public class StockPriceFluxPublisher {
public static Flux<Integer> getPrice(){
AtomicInteger atomicInteger = new AtomicInteger(100);
return Flux.interval(Duration.ofSeconds(1))
.map(i-> atomicInteger.
getAndAccumulate(Util.faker().random().nextInt(-5,5), Integer::sum));
}
}
package org.abs.exercise;
import com.github.javafaker.Faker;
import org.reactivestreams.Subscriber;
import java.util.function.Consumer;
public class Util {
private static final Faker FAKER = Faker.instance();
public static Consumer<Object> onNext(){
return o -> System.out.println("Received : " + o);
}
public static Consumer<Throwable> onError(){
return e -> System.out.println("ERROR : " + e.getMessage());
}
public static Runnable onComplete(){
return () -> System.out.println("Completed");
}
public static Faker faker(){
return FAKER;
}
public static void sleepSeconds(int seconds){
sleepMillis(seconds * 1000);
}
public static void sleepMillis(int millis){
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static Subscriber<Object> subscriber(){
return new DefaultSubscriber();
}
public static Subscriber<Object> subscriber(String name){
return new DefaultSubscriber(name);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment