当前位置: 首页>>代码示例>>Java>>正文


Java VertxFactory类代码示例

本文整理汇总了Java中org.vertx.java.core.VertxFactory的典型用法代码示例。如果您正苦于以下问题:Java VertxFactory类的具体用法?Java VertxFactory怎么用?Java VertxFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VertxFactory类属于org.vertx.java.core包,在下文中一共展示了VertxFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
public static void main(String[] args) {
	// Configure the client.
	String adCode3rd = "/?advideo/3.0/78.109/5798044/0//cc=2;vidAS=pre_roll;vidRT=VAST;vidRTV=2.0.1";
	HttpClient httpClient = VertxFactory.newVertx().createHttpClient();
	httpClient.setHost("adserver.adtech.de");
	httpClient.get(adCode3rd, new Handler<HttpClientResponse>() {

	    @Override
	    public void handle(HttpClientResponse httpClientResponse) {
	    	httpClientResponse.bodyHandler(new Handler<Buffer>() {
	            @Override
	            public void handle(Buffer buffer) {
	                System.out.println("Response (" + buffer.length() + "): ");
	                System.out.println(buffer.getString(0, buffer.length()));
	            }
	        });
	    }
	});
	Utils.sleep(10000);
}
 
开发者ID:rfxlab,项目名称:analytics-with-rfx,代码行数:21,代码来源:NettyHttpClient.java

示例2: EmulatorLaunchpad

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param httpPort The HTTP port on which the emulator should run.
 */
public EmulatorLaunchpad(int httpPort) {

    vertx = VertxFactory.newVertx();

    // Static files
    HttpServer httpServer = vertx.createHttpServer();
    httpServer.requestHandler(new WebResourceHandler());

    // Eventbus bridge
    JsonObject bridgeConfig = new JsonObject().putString("prefix", EVENTBUS_ADDRESS);
    JsonArray credentialsPermitAll = new JsonArray().add(new JsonObject());
    vertx.createSockJSServer(httpServer).bridge(bridgeConfig, credentialsPermitAll, credentialsPermitAll);
    vertx.eventBus().registerLocalHandler(EVENTBUS_SERVER_HANDLER_ID, eventBusHandler);

    System.out.println("Launchpad emulator is ready on http://localhost:" + httpPort + "/");
    httpServer.listen(httpPort);
}
 
开发者ID:OlivierCroisier,项目名称:LP4J,代码行数:23,代码来源:EmulatorLaunchpad.java

示例3: checkAndCreateHttpServer

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
private HttpServer checkAndCreateHttpServer(String host, int port) {
	if (isAddressAlreadyInUse(host, port)) {
		System.err.println(host + ":" + port + " isAddressAlreadyInUse!");
		System.exit(1);
		return null;
	}
	try {
		this.host = host;
		this.port = port;
		Vertx vertx = VertxFactory.newVertx();
		return vertx.createHttpServer();
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:trieu,项目名称:netty-with-gradle,代码行数:17,代码来源:SimpleHttpServer.java

示例4: connect

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
private void connect(final String ip, final String port) throws InterruptedException {
    final CountDownLatch connected = new CountDownLatch(1);
    final Vertx vertx = VertxFactory.newVertx();
    client = vertx.
            createHttpClient().
            setHost(ip).
            setPort(Integer.valueOf(port)).
            connectWebsocket("/",
                    (ws) -> {
                        connected.countDown();
                        this.webSocket = ws;
                        ws.dataHandler(this::sendPixelDataToCanvas);
                    });
    connected.await(5000, TimeUnit.MILLISECONDS);
    context.send(BaseConfig.DRAWING_PERSPECTIVE, FragmentNavigation.FINISH);
}
 
开发者ID:amoAHCP,项目名称:vertx-samples,代码行数:17,代码来源:WebSocketComponent.java

示例5: startVertx

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Before
public void startVertx() {
    if( vertx == null ) {
        vertx = VertxFactory.newVertx();
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:7,代码来源:DetectingGatewayTest.java

示例6: VertxSink

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
/**
 * Protected constructor.
 *
 * @param builder Instance of <code>Builder</code>.
 */
protected VertxSink(final Builder<?, ?> builder) {
    super(builder);
    _serverAddress = builder._serverAddress;
    _hostnameResolver = builder._hostnameResolver;
    _serverPort = builder._serverPort;
    _vertx = VertxFactory.newVertx();
    //Calling this just so the context gets created
    if (_vertx instanceof DefaultVertx) {
        final DefaultVertx vertx = (DefaultVertx) _vertx;
        final DefaultContext context = vertx.getOrCreateContext();
        vertx.setContext(context);
        _context = context;
    } else {
        _context = null;
        LOGGER.warn()
                .setMessage("Vertx instance not a DefaultVertx as expected. Threading may be incorrect.")
                .addData("sink", getName())
                .log();
    }

    _client = _vertx.createNetClient()
            .setReconnectAttempts(0)
            .setConnectTimeout(5000)
            .setTCPNoDelay(true)
            .setTCPKeepAlive(true);
    _socket = new AtomicReference<>();
    _pendingData = EvictingQueue.create(builder._maxQueueSize);
    _exponentialBackoffBase = builder._exponentialBackoffBase;

    connectToServer();
    consumeLoop();
}
 
开发者ID:ArpNetworking,项目名称:metrics-aggregator-daemon,代码行数:38,代码来源:VertxSink.java

示例7: startServer

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Override
protected void startServer(int port, Action<ServerWebSocket> websocketAction) {
  server = VertxFactory.newVertx().createHttpServer();
  final AsityWebSocketHandler websocketHandler = new AsityWebSocketHandler().onwebsocket
    (websocketAction);
  server.websocketHandler(new Handler<org.vertx.java.core.http.ServerWebSocket>() {
    @Override
    public void handle(org.vertx.java.core.http.ServerWebSocket socket) {
      if (socket.path().equals(TEST_URI)) {
        websocketHandler.handle(socket);
      }
    }
  });
  server.listen(port);
}
 
开发者ID:cettia,项目名称:asity,代码行数:16,代码来源:VertxServerWebSocketTest.java

示例8: startServer

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Override
protected void startServer(int port, Action<ServerHttpExchange> requestAction) throws Exception {
  server = VertxFactory.newVertx().createHttpServer();
  RouteMatcher matcher = new RouteMatcher();
  matcher.all(TEST_URI, new AsityRequestHandler().onhttp(requestAction));
  server.requestHandler(matcher);
  server.listen(port);
}
 
开发者ID:cettia,项目名称:asity,代码行数:9,代码来源:VertxServerHttpExchangeTest.java

示例9: start

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
public void start(int port) {

        vertx = VertxFactory.newVertx();

        httpServer = vertx.createHttpServer();
        httpServer.websocketHandler(new Handler<ServerWebSocket>() {
            public void handle(final ServerWebSocket ws) {

                if (ws.path().equals("/echo")) {

                    ws.frameHandler(new Handler<WebSocketFrame>() {
                        @Override
                        public void handle(WebSocketFrame webSocketFrame) {
                            if (webSocketFrame.isBinary()) {
                                Buffer buff = new Buffer(((WebSocketFrameInternal) webSocketFrame).getBinaryData());
                                ws.writeBinaryFrame(buff);
                            } else if (webSocketFrame.isText()) {
                                ws.writeTextFrame(webSocketFrame.textData());
                            }
                        }
                    });

                } else {
                    ws.reject();
                }
            }
        }).listen(port);
    }
 
开发者ID:matzew,项目名称:simple-websocket-client,代码行数:29,代码来源:WebSocketServer.java

示例10: vertx

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Bean
public Vertx vertx() {
    final String hostname = "127.0.0.1";
    //final Integer port = 5454;
    //try {
        // This line will typically be return VertxFactory.newVertx(port, hostname)
        return VertxFactory.newVertx(hostname);
    //} catch (Exception e) {
    //    return VertxFactory.newVertx(hostname);
    //}
}
 
开发者ID:bytor99999,项目名称:SpringInAVertxWorld,代码行数:12,代码来源:VertxConfiguration.java

示例11: startServer

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Override
protected void startServer() {
    server = VertxFactory.newVertx().createHttpServer();
    final VibeWebSocketHandler websocketHandler = new VibeWebSocketHandler().onwebsocket(performer.serverAction());
    server.websocketHandler(new Handler<org.vertx.java.core.http.ServerWebSocket>() {
        @Override
        public void handle(org.vertx.java.core.http.ServerWebSocket socket) {
            if (socket.path().equals("/test")) {
                websocketHandler.handle(socket);
            }
        }
    });
    server.listen(port);
}
 
开发者ID:vibe-project,项目名称:vibe-java-platform,代码行数:15,代码来源:VertxServerWebSocketTest.java

示例12: startServer

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
@Override
protected void startServer() {
    server = VertxFactory.newVertx().createHttpServer();
    RouteMatcher matcher = new RouteMatcher();
    matcher.all("/test", new VibeRequestHandler().onhttp(performer.serverAction()));
    server.requestHandler(matcher);
    server.listen(port);
}
 
开发者ID:vibe-project,项目名称:vibe-java-platform,代码行数:9,代码来源:VertxServerHttpExchangeTest.java

示例13: getClient

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
private HttpClient getClient() throws MalformedURLException, InterruptedException {

        Vertx vertx = VertxFactory.newVertx();
        HttpClient client = vertx.
                createHttpClient().
                setHost("localhost").
                setPort(8080);

        return client;
    }
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:11,代码来源:RestEntryVerticleTest.java

示例14: getClient

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
private HttpClient getClient(final Handler<WebSocket> handler, final String path) {

        Vertx vertx = VertxFactory.newVertx();
        HttpClient client = vertx.
                createHttpClient().
                setHost("localhost").
                setPort(8080).
                connectWebsocket(path, handler);

        return client;
    }
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:12,代码来源:WSEntryVerticleTest.java

示例15: getClient

import org.vertx.java.core.VertxFactory; //导入依赖的package包/类
private HttpClient getClient() {

        Vertx vertx = VertxFactory.newVertx();
        HttpClient client = vertx.
                createHttpClient().
                setHost("localhost").
                setPort(8080);

        return client;
    }
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:11,代码来源:RestGetTest.java


注:本文中的org.vertx.java.core.VertxFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。