本文整理匯總了Java中org.vertx.java.core.impl.DefaultVertxFactory類的典型用法代碼示例。如果您正苦於以下問題:Java DefaultVertxFactory類的具體用法?Java DefaultVertxFactory怎麽用?Java DefaultVertxFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DefaultVertxFactory類屬於org.vertx.java.core.impl包,在下文中一共展示了DefaultVertxFactory類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: executeApp
import org.vertx.java.core.impl.DefaultVertxFactory; //導入依賴的package包/類
@Override
public void executeApp() throws Exception {
int port = getAvailablePort();
HttpServer httpServer = new DefaultVertxFactory().createVertx().createHttpServer()
.requestHandler(new Handler<HttpServerRequest>() {
@Override
public void handle(HttpServerRequest req) {
req.response.end("Hello World!");
}
}).listen(port);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet("http://localhost:" + port + "/abc?xyz=123");
int statusCode = httpClient.execute(httpGet).getStatusLine().getStatusCode();
if (statusCode != 200) {
throw new IllegalStateException("Unexpected status code: " + statusCode);
}
httpServer.close();
}
示例2: executeApp
import org.vertx.java.core.impl.DefaultVertxFactory; //導入依賴的package包/類
@Override
public void executeApp() throws Exception {
int port = getAvailablePort();
HttpServer httpServer = new DefaultVertxFactory().createVertx().createHttpServer()
.requestHandler(new Handler<HttpServerRequest>() {
@Override
public void handle(HttpServerRequest req) {
req.response().end("Hello World!");
}
}).listen(port);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet("http://localhost:" + port + "/abc?xyz=123");
int statusCode = httpClient.execute(httpGet).getStatusLine().getStatusCode();
if (statusCode != 200) {
throw new IllegalStateException("Unexpected status code: " + statusCode);
}
httpServer.close();
}
示例3: TcpTransport
import org.vertx.java.core.impl.DefaultVertxFactory; //導入依賴的package包/類
/**
* Create a new instance of the transport.
*
* @param listener
* The TransportListener that will receive data from this Transport instance.
* @param remoteLocation
* The remote location where this transport should connection to.
*/
public TcpTransport(TransportListener listener, URI remoteLocation) {
this.listener = listener;
this.remoteLocation = remoteLocation;
this.vertx = new DefaultVertxFactory().createVertx();
this.client = vertx.createNetClient();
}