The changes look good.
I had been wondering how to do a type safe proxy factory method ever
since generics were introduced, but I didn't ever realize how until I
stumbled across some code at java.net a few months ago. I comes in
handy anytime I build or use a proxy.
Cameron
On Dec 1, 2007 4:01 AM, Trustin Lee <[EMAIL PROTECTED]> wrote:
> Hi Cameron,
>
>
> On Dec 1, 2007 4:32 AM, Cameron Taggart <[EMAIL PROTECTED]> wrote:
> > I'm been looking at the tapedeck example using the state machine. I
> > think the proxy factory could be enhanced to return the type of the
> > class passed in. This is pretty easy to do:
> >
> > // public static Object create(Class<?> iface, StateMachine sm,
> > StateContextLookup contextLookup) {
> > // return create(new Class[] { iface }, sm, contextLookup);
> > // }
> > @SuppressWarnings("unchecked")
> > public static <T> T create(Class<T> iface, StateMachine sm,
> > StateContextLookup contextLookup) {
> > return (T) create(new Class[] { iface }, sm, contextLookup);
> > }
> >
> > This removes the need to have a cast in people using the that method
> > such as the example:
> > org.apache.mina.example.tapedeck.Main creatIoHandler()
> >
> > wdyt?
>
> Thank you for the nice idea. I've just made the change you suggested.
>
> Thanks,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>