dev@grizzly.java.net

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

From: kedar mhaswade <kedar.mhaswade_at_gmail.com>
Date: Mon, 29 Jun 2009 11:32:49 -0700

Hi Alexis,

Thanks for your response.

Is this interface not to be carried forward in Grizzly 2.0? Also, I was more
interested in thinking behind providing such a public interface, whose
correct implementation depends on the context.

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
>
>