Skip to content

Commit eb5b63b

Browse files
committed
Clarify what the ExternallyProvidedVertxService purpose is
1 parent e24cac0 commit eb5b63b

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.hibernate.reactive.service;
2+
3+
import io.vertx.core.Vertx;
4+
5+
import java.util.Objects;
6+
7+
/**
8+
* If the framework / container / runtime already has a Vert.x instance which
9+
* it wants to reuse, use this VertxService implementation to inject it into
10+
* Hibernate Reactive registry at boot time.
11+
* When using this service, Hibernate will not reconfigure nor stop the
12+
* Vert.x instance on shutdown as this responsibility belongs to the
13+
* code managing it.
14+
*/
15+
public final class ExternallyProvidedVertxService implements VertxService {
16+
17+
private final Vertx vertx;
18+
19+
public ExternallyProvidedVertxService(Vertx vertx) {
20+
Objects.requireNonNull( vertx );
21+
this.vertx = vertx;
22+
}
23+
24+
@Override
25+
public Vertx getVertx() {
26+
return vertx;
27+
}
28+
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/service/ManagedVertxService.java

-20
This file was deleted.

hibernate-reactive-core/src/test/java/org/hibernate/reactive/testing/TestingRegistryRule.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.hibernate.reactive.testing;
22

33
import io.vertx.core.Vertx;
4-
import org.hibernate.reactive.service.ManagedVertxService;
4+
import org.hibernate.reactive.service.ExternallyProvidedVertxService;
55
import org.hibernate.reactive.service.VertxService;
66
import org.hibernate.service.Service;
77
import org.hibernate.service.ServiceRegistry;
@@ -35,10 +35,10 @@ public ServiceRegistryImplementor getServiceRegistry() {
3535
//TODO extract into its own class and evolve as necessary?
3636
private static class Registry implements ServiceRegistryImplementor {
3737

38-
private final ManagedVertxService vertxService;
38+
private final ExternallyProvidedVertxService vertxService;
3939

4040
public Registry(Vertx vertx) {
41-
this.vertxService = new ManagedVertxService( vertx );
41+
this.vertxService = new ExternallyProvidedVertxService( vertx );
4242
}
4343

4444
@Override

0 commit comments

Comments
 (0)