dev@grizzly.java.net

Re: Purpose of com.sun.grizzly.util.Copyable is not clear ...

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Tue, 30 Jun 2009 10:53:04 +0200

Hi Kedar,

> Thanks for your response.
>
> Is this interface not to be carried forward in Grizzly 2.0?
No, IMHO it wasn't good idea to create clones, so in Grizzly 2.0 we
are not planning to use that.

> Also, I was more interested in thinking behind providing such a
> public interface, whose correct implementation depends on the context.
It could be interesting, because I met several projects, which use own
cloning mechanism, though I'm not sure this is trivial task :)

WBR,
Alexey.

>
> Regards,
> Kedar
>
> On Mon, Jun 29, 2009 at 4:52 AM, Oleksiy Stashok <Oleksiy.Stashok_at_sun.com
> > wrote:
> Hi Kedar,
>
>
>
> In general, I am not clear on the purpose of this Java interface
> which is used all over. In all the *usages* of implementations of
> this interface, the copyTo method just typecasts the given parameter
> to an expected type and it either results in ClassCastException or
> returns abruptly if the passed parameter is not of expected type.
> Thus, the caller *has to* pass the correct type. For example,
> TCPSelectorHandler.copyTo does:
>
> TCPSelectorHandler copyHandler = (TCPSelectorHandler) copy;
>
> and happily proceeds. Now, unless caller passes in an instance of
> TCPSelectorHandler (which is what happening all the time), this
> method will fail throwing CCE.
>
> Now, my question is, if the above is true, what is the use of this
> interface? It serves the purpose of neither a classic copy
> constructor, nor is it a cloner (in traditional Java sense of
> Cloning). In general, it is not possible to copy a generic class
> unless you know its internal structure, because all the
> implementations are basically resulting in a bunch of setters.
>
> Am I missing something?
> Copyable interface together with utility class Cloner implements
> custom cloning mechanism in Grizzly 1.x. This is used just
> internally inside framework, so normally CCE should not occur.
>
> WBR,
> Alexey.
>
>
> -Kedar
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>
>