Hi Robin,

If I understood correctly, your question is: why nullifying in detach()
a transient field? The only answer I see is related to your
observation: memory footprint and serialization are 2 different
aspects. So, when one implements an IDataProvider , one should deal
with both aspects without making assumptions about the framework. Maybe
the framework decides to keep in memory the IDataProvider for a time t
and only then, to serialize it and store it. This means that for the
time t, your (possible large) object will stay in memory.



I'm not sure that my explanation is ok, but I do not have a better one. :)



About performance, some other posts suggest that the transient object should be 
cached, so, it can be retrieved fast.



Regards,

kaltman

--- On Fri, 8/7/09, Robin Sander <[email protected]> wrote:

From: Robin Sander <[email protected]>
Subject: Re: DataView/IDataProvider/Detach
To: [email protected]
Date: Friday, August 7, 2009, 11:42 AM


Hi,

correct me if I'm wrong, Igor, but I thought detach() is used to keep the model 
memory footprint low
*between requests* and Serialization is a total different story.
If I mark a field as transient I don't have to nullify it in detach().
For example using a IDataProvider for pagination:
If I set a (transient) field to null after every request I have to initialize 
it before every request too,
sounds inefficient to me. To re-initialize a transient field I would use 
readObject(ObjectInputStream in)
instead.
If I'm right the following comment in IDetachable is misleading:

    /**
     * Detaches model after use. This is generally used to null out transient 
references that can be
     * re-attached later.
     */
    void detach();

What am I missing?

Robin.



On 06.08.2009, at 21:45, Igor Vaynberg wrote:

> yep, lazy init is the way to do things. also helps to mark those
> fields as transient as an additional safeguard.
> 
> -igor
> 
> On Thu, Aug 6, 2009 at 12:22 AM, Gabi Kaltman<[email protected]> wrote:
>> Hi,
>> 
>> I'm very young on the Wicket planet, so please excuse my simple question 
>> related to DataView/IDataProvider
>> 
>> My configuration:
>> 1. I use a DataView (MyDataView)
>> 2. I added a PageNavigator to MyDataView
>> 3. I defined a IDataProvider attached to  MyDataView (MyDataProvider)
>> 4. MyDataProvider has a not-serializable field (MyField)
>> 5. MyField is used in the method MyDataProvider.size()
>> 6. I use Wicket 1.4.0
>> 
>> What I do:
>> 1.  In the method MyDataProvider.detach() , I nullify MyField (MyField = 
>> null)
>> 
>> What happens:
>> 1. When I navigate through pages, I get a NPE in MyDataProvider.size() as 
>> MyField became null
>> 
>> How I fixed it:
>> 1. I overrode in MyDataView the method getDataProvider(). Didn't work. I 
>> noticed that this method is never invoked
>> 2. I tested again null in MyDataProvider.size(). If MyField is null, I just 
>> reinitialize it. It works
>> 
>> My question is if this solution is the optimal one, or there is a better one?
>> 
>> Thanks,
>> kaltman
>> 
>> 
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




      

Reply via email to