【发布时间】:2012-03-26 08:57:25
【问题描述】:
我想创建一个处理程序管道,例如:
public ChannelPipeline getPipeline() throws Exception
{
return Channels.pipeline(
new ObjectEncoder(),
new ObjectDecoder(),
new AuthenticationServerHandler(),
new BusinessLogicServerHandler());
}
这里的关键是我希望AuthenticationServerHandler 能够将登录信息传递给BusinessLogicServerHandler。
我知道您可以使用Attachment,但是它只存储该处理程序的信息,管道中的其他处理程序无法访问它。我还注意到有一个叫做ChannelLocal 的东西可能会起作用,但是我找不到任何关于如何使用它的真实信息。我所看到的只是人们为其创建了一个静态实例,但是您如何在另一个处理程序中检索和访问信息?假设这是正确的方法。
我的问题是:如何在同一管道中的处理程序之间传递信息。在上面的示例中,如何将登录凭据从AuthenticationServerHandler 传递到BusinessLogicServerHandler?
【问题讨论】:
标签: java networking nio netty