當前位置: 首頁>>代碼示例>>Java>>正文


Java EventLoop.shutdownGracefully方法代碼示例

本文整理匯總了Java中io.netty.channel.EventLoop.shutdownGracefully方法的典型用法代碼示例。如果您正苦於以下問題:Java EventLoop.shutdownGracefully方法的具體用法?Java EventLoop.shutdownGracefully怎麽用?Java EventLoop.shutdownGracefully使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.netty.channel.EventLoop的用法示例。


在下文中一共展示了EventLoop.shutdownGracefully方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: stop

import io.netty.channel.EventLoop; //導入方法依賴的package包/類
@PreDestroy
public void stop() throws IOException, InterruptedException {
    EventLoop loop = channel.eventLoop();
    channel.close().sync();
    channel = null;
    loop.shutdownGracefully();

    super.stop();
}
 
開發者ID:shevek,項目名稱:dhcp4j,代碼行數:10,代碼來源:DhcpServer.java

示例2: stop

import io.netty.channel.EventLoop; //導入方法依賴的package包/類
@PreDestroy
public void stop() throws IOException, InterruptedException {
    EventLoop loop = channel.eventLoop();
    channel.close().sync();
    channel = null;
    loop.shutdownGracefully();
}
 
開發者ID:shevek,項目名稱:dhcp4j,代碼行數:8,代碼來源:Dhcp6Server.java

示例3: testProjectAccessController

import io.netty.channel.EventLoop; //導入方法依賴的package包/類
@Test
public void testProjectAccessController() throws Exception {
    final EventLoop ev = new DefaultEventLoop();

    try {
        final ServiceRequestContext ctx = spy(mock(ServiceRequestContext.class));
        when(ctx.eventLoop()).thenReturn(ev);

        final DefaultAttributeMap attrs = new DefaultAttributeMap();
        attrs.attr(ROLE_MAP).set(roleMap::get);
        when(ctx.attr(CURRENT_USER_KEY)).thenReturn(attrs.attr(CURRENT_USER_KEY));
        when(ctx.attr(ROLE_MAP)).thenReturn(attrs.attr(ROLE_MAP));

        try (SafeCloseable ignore = RequestContext.push(ctx)) {

            attrs.attr(CURRENT_USER_KEY).set(User.DEFAULT);

            when(ctx.pathParam("projectName")).thenReturn("A");
            assertThat(new ProjectMembersOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);
            assertThat(new ProjectOwnersOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);

            when(ctx.pathParam("projectName")).thenReturn("B");
            assertThat(new ProjectMembersOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);
            assertThatThrownBy(() -> new ProjectOwnersOnly().serve(delegate, ctx, null))
                    .isInstanceOf(HttpStatusException.class)
                    .satisfies(cause -> {
                        assertThat(((HttpStatusException) cause).httpStatus())
                                .isEqualTo(HttpStatus.UNAUTHORIZED);
                    });

            attrs.attr(CURRENT_USER_KEY).set(User.ADMIN);

            assertThat(new AdministratorsOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);
            assertThat(new ProjectMembersOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);
            assertThat(new ProjectOwnersOnly().serve(delegate, ctx, null).aggregate().join().status())
                    .isEqualTo(HttpStatus.OK);
        }
    } finally {
        ev.shutdownGracefully();
    }
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:47,代碼來源:DecoratorTest.java

示例4: stop

import io.netty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void stop() throws IOException, InterruptedException {
    EventLoop loop = channel.eventLoop();
    channel.close().sync();
    loop.shutdownGracefully();
}
 
開發者ID:shevek,項目名稱:tftp4j,代碼行數:7,代碼來源:TftpServer.java


注:本文中的io.netty.channel.EventLoop.shutdownGracefully方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。