On 9/30/07, Trustin Lee <[EMAIL PROTECTED]> wrote:
> Hi Maarten,
>
> On 9/30/07, Maarten Bosteels <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > We should add a method for remving a property from the context:
> >
> >     public static void removeProperty(IoSession session, String key) {
> >       if (key == null) {
> >         throw new NullPointerException("key should not be null");
> >       }
> >       Context context = getContext(session);
> >       context.remove(key);
> >     }
>
> Good idea.
>
> > And maybe the option to immediately set the property in the MDC, since
> > in the current implementation, the property does not show up for log
> > statements generated during the handling of the current event.
> > Therefor I suggest adding this method:
> >
> >     public static void setProperty (IoSession session, String key,
> > String value, boolean immediate) {
> >       if (key == null) {
> >         throw new NullPointerException("key should not be null");
> >       }
> >       if (value == null) {
> >         removeProperty(session, key);
> >       }
> >       Context context = getContext(session);
> >       context.put(key, value);
> >       if (immediate) {
> >         MDC.put(key, value);
> >       }
> >     }
> >
> > And a default value of true:
> >
> >     public static void setProperty (IoSession session, String key,
> > String value) {
> >       setProperty(session, key, value, true);
> >     }
>
> Is there any case that a user need to call with false?

I think it will be rare indeed. Suppose some user thread (not related
to a mina event) is looping over a set of IoSessions and sets a
property in the context of each session.
Maybe it's too rare to take into account ?
You think the extra parameter is cluttering the API ?

>
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>

Reply via email to