forked from vert-x3/vertx-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VertxVerticleHost.java
37 lines (29 loc) · 927 Bytes
/
VertxVerticleHost.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package io.vertx.example.osgi;
import io.vertx.core.Verticle;
import io.vertx.core.Vertx;
import org.apache.felix.ipojo.annotations.*;
import java.util.logging.Logger;
/**
* A component consuming all verticles exposed in the service registry and deploying them.
*/
@Component(immediate = true)
@Instantiate
public class VertxVerticleHost {
private final static Logger LOGGER = Logger.getLogger("VertxVerticleHost");
@Requires
Vertx vertx;
@Invalidate
public void stop() {
// We should unregister all deployed verticles.
}
@Bind(aggregate = true)
public void bindVerticle(Verticle verticle) {
LOGGER.info("Deploying verticle " + verticle);
vertx.deployVerticle(verticle);
}
@Unbind(aggregate = true)
public void unbindVerticle(Verticle verticle) {
LOGGER.info("Undeploying verticle " + verticle);
vertx.undeploy(verticle.getVertx().getOrCreateContext().deploymentID());
}
}