Skip to content

Commit

Permalink
Details.
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Jun 13, 2024
1 parent 06c5571 commit 384dab2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;

import nl.vpro.esper.EsperEvent;

@Slf4j
public class AsyncEventServiceProviderImpl extends EventServiceProviderImpl implements AsyncEventServiceProvider {

Expand All @@ -36,7 +38,7 @@ private AsyncEventServiceProviderImpl(
Set<Class<? extends Annotation>> eventAnnotations,
int queueCapacity) {
super(name, eventPackages, eventAnnotations);
queue = new ArrayBlockingQueue<>(queueCapacity);
queue = new ArrayBlockingQueue<>(queueCapacity <=0 ? 1000 : queueCapacity);
}


Expand Down Expand Up @@ -102,4 +104,16 @@ public void run() {
}
}
}

public static class Builder {

public AsyncEventServiceProviderImpl.Builder packages(String... eventPackages) {
return eventPackages(Set.of(eventPackages));
}

public AsyncEventServiceProviderImpl.Builder esperEventAnnotation() {
return eventAnnotations(Set.of(EsperEvent.class));
}
}

}
13 changes: 13 additions & 0 deletions src/main/java/nl/vpro/esper/service/EventServiceProviderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.espertech.esper.runtime.client.*;
import com.google.common.reflect.ClassPath;

import nl.vpro.esper.EsperEvent;

@Slf4j
public class EventServiceProviderImpl implements EventServiceProvider {

Expand Down Expand Up @@ -111,4 +113,15 @@ private void initStatement(Statement statement) throws EPCompileException, EPDep
statement.setEPStatement(deployment.getStatements()[0]);
}

public static class Builder {
public Builder packages(String... eventPackages) {
return eventPackages(Set.of(eventPackages));
}

public Builder esperEventAnnotation() {
return eventAnnotations(Set.of(EsperEvent.class));
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package nl.vpro.esper.service;

import java.time.Duration;
import java.util.Set;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -24,7 +23,7 @@ public class AsyncEventServiceProviderTest {
public void setup() {
Statement testStatement = new Statement("select count(*) from TestEvent where name like '%6'");
provider = AsyncEventServiceProviderImpl.asyncBuilder().name("200")
.eventPackages(Set.of("nl.vpro.esper.event"))
.packages("nl.vpro.esper.event")
.build();
provider.init();
provider.addStatement(testStatement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
*/
package nl.vpro.esper.service;

import java.util.Set;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import nl.vpro.esper.EsperEvent;
import nl.vpro.esper.event.TestEvent;
import nl.vpro.esper.listener.Counter;

Expand All @@ -25,7 +22,7 @@ public class EventServiceProviderTest {
public void setup() {
Statement testStatement = new Statement("select count(*) from TestEvent where name like '%6'");
provider = EventServiceProviderImpl.builder()
.eventAnnotations(Set.of(EsperEvent.class))
.esperEventAnnotation()
.build();
provider.addStatement(testStatement);
listener = new Counter();
Expand Down

0 comments on commit 384dab2

Please sign in to comment.