[ 
https://issues.apache.org/jira/browse/IGNITE-3422?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15869692#comment-15869692
 ] 

Vladimir Ozerov commented on IGNITE-3422:
-----------------------------------------

IMO the only proper approach to handle this case is to allow to call specific 
custom constructor with {{BinaryReader}} as argument:
{code}
class MyClass {
    public MyClass(BinaryReader reader) {
        // Initialize here.
    }
}
{code}

Key differences from proposed fix:
1) We pass {{BinaryReader}} to user, so that he can read fields and raw data 
from the stream.
2) Object reference is already available from within ctor, so that we can 
handle nested and cyclic references properly.

This idea is borrowed from .NET {{ISerizliable}} interface [1].

[1] 
https://msdn.microsoft.com/en-us/library/system.runtime.serialization.iserializable(v=vs.110).aspx

> No way to control object initialization during deserialization/unmarshalling 
> -----------------------------------------------------------------------------
>
>                 Key: IGNITE-3422
>                 URL: https://issues.apache.org/jira/browse/IGNITE-3422
>             Project: Ignite
>          Issue Type: Improvement
>          Components: binary, general
>    Affects Versions: 1.6
>            Reporter: Denis Magda
>            Assignee: Vyacheslav Daradur
>
> Presently there is no way to control instantiation of a {{BinaryObject}} that 
> is being deserialized. The object is created using 
> {{BinaryClassDescriptor#newInstance}} all the time.
> It makes sense to add {{BinaryConfiguration.setInitializationFactory()}} 
> method that will provide with such support.
> Use case and details are provided in this discussion
> http://apache-ignite-users.70518.x6.nabble.com/Properly-Immutable-Keys-values-with-Binary-objects-tp6082.html



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to