I found what I was looking for - a brief example of ChannelLocal is found in the ChannelHandler documentation (ps: it might be worth repeating in the ChannelLocal docs..) But now I'm wondering:<div><br></div><div>The example shows a DataServerState class - where would that class be instantiated such that all handlers have access to it? I thought I might instantiate it in my server startup code, pass it to the ChannelPipelineFactory where I could pass it on to the constructor of each ChannelHandler. Is there another way?</div>
<div><br></div><div>Also, at some point before the Channel closes would I have to be sure to remove any ChannelLocal variable references? That is, ChannelLocals map values to Channels, so would I have to be sure to remove each reference so values to closed Channels don't pile up, creating a memory leak? If so, how/where could I attach an event handler to a Channel to do this? Would I have to do this in a ChannelHandler (I don't like that idea, because which ChannelHandler do I put it in?) or create some kind of custom ChannelFactory?</div>
<div><br></div><div>Thanks.</div><div><br></div><div>MD</div><div><br></div><div><div><br><div class="gmail_quote">On Fri, Oct 21, 2011 at 3:36 AM, Norman Maurer <span dir="ltr"><<a href="mailto:norman.maurer@googlemail.com">norman.maurer@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I was using it before in a project but remoted it in favor of<br>
ChannelHandlerContext.setAttachment(..).<br>
<br>
But it worked quited fine for me. You can see the old code here:<br>
<br>
<a href="http://svn.apache.org/viewvc/james/protocols/tags/protocols-1.5/impl/src/main/java/org/apache/james/protocols/impl/AbstractChannelUpstreamHandler.java?view=markup" target="_blank">http://svn.apache.org/viewvc/james/protocols/tags/protocols-1.5/impl/src/main/java/org/apache/james/protocols/impl/AbstractChannelUpstreamHandler.java?view=markup</a><br>
<br>
Bye,<br>
<font color="#888888">Norman<br>
</font><br>
Ps: What does not work for you ?<br>
<br>
2011/10/21 Matt DeLuco <<a href="mailto:list_usr@spacebox.net">list_usr@spacebox.net</a>>:<br>
<div><div></div><div class="h5">> Where can I find some examples of ChannelLocal in use?<br>
> I'm not getting the results I expect, but I don't think I'm using it<br>
> correctly either.<br>
> MD<br>
><br>
> On Sun, Oct 16, 2011 at 7:14 AM, Norman Maurer<br>
> <<a href="mailto:norman.maurer@googlemail.com">norman.maurer@googlemail.com</a>> wrote:<br>
>><br>
>> You can set anything you want as attachment. But it's only visible in<br>
>> the same handler....<br>
>><br>
>> If you want to share stuff between handler you should checkout<br>
>> ChannelLocal<br>
>><br>
>> Bye<br>
>> Norman<br>
>> 2011/10/16, Matt DeLuco <<a href="mailto:list_usr@spacebox.net">list_usr@spacebox.net</a>>:<br>
>> > Before composing this message I had noticed<br>
>> > ChannelHandlerContext.setAttachment(Object) and getAttachment(). But<br>
>> > for some reason I came to the conclusion that it wasn't intended for<br>
>> > what I want to do.<br>
>> ><br>
>> > I came to that conclusion in part because I found it strange that it's<br>
>> > only possible to set one attachment, rather than being able to attach<br>
>> > a set (or map) of objects. Could I just attach a map to the context<br>
>> > and store whatever I want in that map, to pass objects between<br>
>> > ChannelHandlers?<br>
>> ><br>
>> > MD<br>
>> ><br>
>> ><br>
>> > On Sat, Oct 15, 2011 at 9:42 PM, Matt DeLuco <<a href="mailto:list_usr@spacebox.net">list_usr@spacebox.net</a>><br>
>> > wrote:<br>
>> >> Is it possible to pass data between ChannelHandlers, or store data<br>
>> >> somewhere that the handlers in a specific pipeline/channel can access<br>
>> >> throughout the lifetime of the request?<br>
>> >><br>
>> >> For example, I have my own class for dealing with http cookies,<br>
>> >> "CookieMap". I'd like to have a SimpleChannelHandler that creates a<br>
>> >> CookieMap to be used by handlers further upstream, and then sets the<br>
>> >> cookies in the CookieMap on the response on their way back downstream.<br>
>> >><br>
>> >> MD<br>
>> >><br>
>> ><br>
>> > _______________________________________________<br>
>> > netty-users mailing list<br>
>> > <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
>> > <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
>> ><br>
>> _______________________________________________<br>
>> netty-users mailing list<br>
>> <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
><br>
><br>
> _______________________________________________<br>
> netty-users mailing list<br>
> <a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
><br>
<br>
_______________________________________________<br>
netty-users mailing list<br>
<a href="mailto:netty-users@lists.jboss.org">netty-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/netty-users" target="_blank">https://lists.jboss.org/mailman/listinfo/netty-users</a><br>
</div></div></blockquote></div><br></div></div>