本文整理匯總了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();
}
示例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();
}
示例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();
}
}
示例4: stop
import io.netty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void stop() throws IOException, InterruptedException {
EventLoop loop = channel.eventLoop();
channel.close().sync();
loop.shutdownGracefully();
}