• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DefaultVertx类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setup

import org.vertx.java.core.impl.DefaultVertx; //导入依赖的package包/类
@Before
public void setup()
{
    parser = new RoutingCriteriaParser();
    vertx = new DefaultVertx();

    final int port = PortFinder.findOpenPort();
    final String host = "127.0.0.1";
    server = vertx.createHttpServer()
                  .requestHandler( parser )
                  .listen( port, host );

    client = vertx.createHttpClient()
                  .setHost( host )
                  .setPort( port );

    clientHandler = new WaitHandler();
}
 
开发者ID:jdcasey,项目名称:vabr,代码行数:19,代码来源:RoutingCriteriaTest.java


示例2: VertxSink

import org.vertx.java.core.impl.DefaultVertx; //导入依赖的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


示例3: run

import org.vertx.java.core.impl.DefaultVertx; //导入依赖的package包/类
private void run() throws Exception {
    Vertx vertx = new DefaultVertx();
    HttpServer server = vertx.createHttpServer();

    RouteMatcher routeMatcher = new RouteMatcher();

    routeMatcher.allWithRegEx("/jimix(.*)", new JimixVertxHandler());

    server.requestHandler(routeMatcher).listen(8080, "localhost");
    while (true) {
        Thread.sleep(10000);
    }
}
 
开发者ID:manuel-woelker,项目名称:jimix,代码行数:14,代码来源:JimixSampleVertxMain.java


示例4: setup

import org.vertx.java.core.impl.DefaultVertx; //导入依赖的package包/类
@Before
public void setup()
{
    access = new ParamAccess();
    vertx = new DefaultVertx();

    port = PortFinder.findOpenPort();
    host = "127.0.0.1";

    client = vertx.createHttpClient()
                  .setHost( host )
                  .setPort( port );

    clientHandler = new WaitHandler();
}
 
开发者ID:jdcasey,项目名称:vabr,代码行数:16,代码来源:ApplicationRouterTest.java


示例5: closeFileBeforeReadingAll

import org.vertx.java.core.impl.DefaultVertx; //导入依赖的package包/类
@Test
public void closeFileBeforeReadingAll()
    throws IOException
{
    final FileHandler fh = new FileHandler();

    final DefaultVertx v = new DefaultVertx();
    v.setContext( v.createEventLoopContext() );
    v.fileSystem()
     .open( getResource( BASE, "test-early-close.txt" ), fh );

    synchronized ( fh )
    {
        try
        {
            fh.wait();
        }
        catch ( final InterruptedException e )
        {
            return;
        }
    }

    InputStream stream = null;
    try
    {
        stream = new VertXInputStream( fh.af );

        final byte[] buf = new byte[15];
        stream.read( buf );

        assertThat( new String( buf ), equalTo( "This is a test!" ) );
    }
    finally
    {
        IOUtils.closeQuietly( stream );
    }
}
 
开发者ID:jdcasey,项目名称:vabr,代码行数:39,代码来源:VertXInputStreamTest.java


示例6: closeFileBeforeReadingAny

import org.vertx.java.core.impl.DefaultVertx; //导入依赖的package包/类
@Test
public void closeFileBeforeReadingAny()
    throws IOException
{
    final FileHandler fh = new FileHandler();

    final DefaultVertx v = new DefaultVertx();
    v.setContext( v.createEventLoopContext() );
    v.fileSystem()
     .open( getResource( BASE, "test-early-close.txt" ), fh );

    synchronized ( fh )
    {
        try
        {
            fh.wait();
        }
        catch ( final InterruptedException e )
        {
            return;
        }
    }

    InputStream stream = null;
    try
    {
        stream = new VertXInputStream( fh.af );
        //
        //            final byte[] buf = new byte[15];
        //            stream.read( buf );
        //
        //            assertThat( new String( buf ), equalTo( "This is a test!" ) );
    }
    finally
    {
        IOUtils.closeQuietly( stream );
    }
}
 
开发者ID:jdcasey,项目名称:vabr,代码行数:39,代码来源:VertXInputStreamTest.java


示例7: writeSimpleFileViaAsyncFile

import org.vertx.java.core.impl.DefaultVertx; //导入依赖的package包/类
@Test
public void writeSimpleFileViaAsyncFile()
    throws IOException
{
    final FileHandler fh = new FileHandler();

    final File f = getTempResource( BASE, "test-write.txt" );

    final DefaultVertx v = new DefaultVertx();
    v.setContext( v.createEventLoopContext() );
    v.fileSystem()
     .open( f.getAbsolutePath(), fh );

    synchronized ( fh )
    {
        try
        {
            fh.wait();
        }
        catch ( final InterruptedException e )
        {
            return;
        }
    }

    final ByteArrayInputStream bain = new ByteArrayInputStream( "This is a test!".getBytes() );
    VertXOutputStream stream = null;
    try
    {
        stream = new VertXOutputStream( fh.af );
        IOUtils.copy( bain, stream );
    }
    finally
    {
        IOUtils.closeQuietly( stream );
    }

    final String result = FileUtils.readFileToString( f );
    assertThat( result, equalTo( "This is a test!" ) );
}
 
开发者ID:jdcasey,项目名称:vabr,代码行数:41,代码来源:VertXOutputStreamTest.java


示例8: readSimpleFileViaAsyncFile

import org.vertx.java.core.impl.DefaultVertx; //导入依赖的package包/类
@Test
public void readSimpleFileViaAsyncFile()
    throws IOException
{
    final String path = getResource( BASE, "test-read.txt" );

    final String check = FileUtils.readFileToString( new File( path ) );

    final FileHandler fh = new FileHandler();

    final DefaultVertx v = new DefaultVertx();
    v.setContext( v.createEventLoopContext() );
    v.fileSystem()
     .open( path, fh );

    synchronized ( fh )
    {
        try
        {
            fh.wait();
        }
        catch ( final InterruptedException e )
        {
            return;
        }
    }

    InputStream stream = null;
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try
    {
        stream = new VertXInputStream( fh.af );
        IOUtils.copy( stream, baos );
    }
    finally
    {
        IOUtils.closeQuietly( stream );
    }

    assertThat( new String( baos.toByteArray() ), equalTo( check ) );
}
 
开发者ID:jdcasey,项目名称:vabr,代码行数:42,代码来源:VertXInputStreamTest.java


示例9: start

import org.vertx.java.core.impl.DefaultVertx; //导入依赖的package包/类
public void start()
{
    if ( handler != null )
    {
        this.vertx = new DefaultVertx();
        final HttpServer httpserver = vertx.createHttpServer()
                                           .requestHandler( new TestWrapperHandler( handler ) );

        logger.debug( "Starting vertx http server using: " + vertx + " with handler: " + handler + " on: "
            + port + " (test-server: " + this + ")" );

        final Handler<AsyncResult<HttpServer>> listener = new Handler<AsyncResult<HttpServer>>()
        {
            @Override
            public void handle( final AsyncResult<HttpServer> event )
            {
                if ( event.succeeded() )
                {
                    final HttpServer server = event.result();
                    logger.debug( "Server: " + server + " ready." );
                    synchronized ( this )
                    {
                        notifyAll();
                    }
                }
            }
        };

        new Thread( new Runnable()
        {
            @Override
            public void run()
            {
                httpserver.listen( port, "localhost", listener );
            }

        } ).start();

        synchronized ( listener )
        {
            try
            {
                listener.wait();
            }
            catch ( final InterruptedException e )
            {
                e.printStackTrace();
                Thread.currentThread()
                      .interrupt();
            }
        }

        logger.info( "Listening on: " + port );

        this.started = true;
    }
}
 
开发者ID:jdcasey,项目名称:vabr,代码行数:58,代码来源:TestHttpServer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Menu类代码示例发布时间:2022-05-22
下一篇:
Java StrongCachingModuleScriptProvider类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap