You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stefan Fußenegger <st...@gmx.at> on 2007/10/25 10:28:30 UTC

LoadableDetachableModel and anonymous inner classes - unwanted serialization overhead?

Hi folks,

I am quite new to wicket but I already figured out that it deserved its name
;) Currently, I am playing around with IDataProvider in conjunction with
LoadableDetachableModels. As far as I understand, the main purpose of
LoadableDetachableModels is to tune serialization performance. At the
beginning I looked at the API doc, which suggested using anonymous inner
classes for detachable models:


public IModel model(Object object) {
    return new LoadableDetachableModel() {
        protected Object load() {
            /* snip - (re)load the object */
        }
    };
}


However, this might not be suited for serialization, as inner classes have
an implicit reference on their enclosing object - which was the
IDataProvider implementation in my case. As a consequence the IDataProvider
object  (and all its possible fileds!) would be serialized together with
every serialized LoadableDetachableModel - which would lead to an unwanted
serialization overhead.

Am I missing something here? Like some Wicket serialization voodoo that
takes care of it? If not, it would be worth mentioning in the API doc and
probably in the wiki as well (I would take care of the wiki if I get green
lights).

Regards, Stefan
-- 
View this message in context: http://www.nabble.com/LoadableDetachableModel-and-anonymous-inner-classes---unwanted-serialization-overhead--tf4689309.html#a13402266
Sent from the Wicket - User mailing list archive at Nabble.com.

Re: LoadableDetachableModel and anonymous inner classes - unwanted serialization overhead?

Posted by Eelco Hillenius <ee...@gmail.com>.
> Thanks for your reply. In deed, I declared the LoadableDetachableModel
> inside the IDataProvider. So the bottom line of your post is, that it is
> serialized anyway altogether?

That data provider will be stored as component state of your repeater.
Anything on your page will be serialized. We provide things like
detachable models to minimize that at the end of a request, right
before it might be serialized. Also note that whether there is any
serialization done depends on the session store you use, and any
serialization is only done either for back button support or to
synchronize across a cluster if you use that.

> Are there some docs for wicket serialization around? As I figured out,
> wicket likes serialization. But so far I wasn't able to find some docs
> explaining what is serialized and when. If you - or somebody else - would
> give me the right pointers, I'd start a new page in the wiki, that
> especially talks about what is serialized and when, what should be
> transient, how to troubleshoot/debug/optimize serialization, and so forth.

Not really, because it depends largely on your configuration. The
default one - SecondLevelCacheSessionStore - stores n older page
instances/ versions to 'second level cache' (by default a file per
session in your temp dir) using serialization for back button support.
And that's pretty much it.

You can trace the calls to Objects.objectToByteArray
/byteArrayToObject/ cloneObject/ cloneModel to get an idea of where
Wicket uses serialization.

Eelco

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: LoadableDetachableModel and anonymous inner classes - unwanted serialization overhead?

Posted by Stefan Fußenegger <st...@gmx.at>.
Hi Matej

Thanks for your reply. In deed, I declared the LoadableDetachableModel
inside the IDataProvider. So the bottom line of your post is, that it is
serialized anyway altogether?

Are there some docs for wicket serialization around? As I figured out,
wicket likes serialization. But so far I wasn't able to find some docs
explaining what is serialized and when. If you - or somebody else - would
give me the right pointers, I'd start a new page in the wiki, that
especially talks about what is serialized and when, what should be
transient, how to troubleshoot/debug/optimize serialization, and so forth.

I am very interested in the inner workings of wicket and this might be a
good starting point to getting into it, so at least for me its worth the
effort ;)


Matej Knopp-2 wrote:
> 
> Where do you have your LoadableDetachableModel declared? And what kind
> of IDataProvider are you talking about? If it is wicket's
> IDataProvider than it has to be serializable, because DataView/Table
> keep it's reference.
> 
> LoadableDetachableModel is usually declared as anonymous class inside
> component/page, which is serialized anyway, so the implicit reference
> makes no difference.
> 
> -Matej
> 
> On 10/25/07, Stefan Fußenegger <st...@gmx.at> wrote:
>>
>> Hi folks,
>>
>> I am quite new to wicket but I already figured out that it deserved its
>> name
>> ;) Currently, I am playing around with IDataProvider in conjunction with
>> LoadableDetachableModels. As far as I understand, the main purpose of
>> LoadableDetachableModels is to tune serialization performance. At the
>> beginning I looked at the API doc, which suggested using anonymous inner
>> classes for detachable models:
>>
>>
>> public IModel model(Object object) {
>>     return new LoadableDetachableModel() {
>>         protected Object load() {
>>             /* snip - (re)load the object */
>>         }
>>     };
>> }
>>
>>
>> However, this might not be suited for serialization, as inner classes
>> have
>> an implicit reference on their enclosing object - which was the
>> IDataProvider implementation in my case. As a consequence the
>> IDataProvider
>> object  (and all its possible fileds!) would be serialized together with
>> every serialized LoadableDetachableModel - which would lead to an
>> unwanted
>> serialization overhead.
>>
>> Am I missing something here? Like some Wicket serialization voodoo that
>> takes care of it? If not, it would be worth mentioning in the API doc and
>> probably in the wiki as well (I would take care of the wiki if I get
>> green
>> lights).
>>
>> Regards, Stefan
>> --
>> View this message in context:
>> http://www.nabble.com/LoadableDetachableModel-and-anonymous-inner-classes---unwanted-serialization-overhead--tf4689309.html#a13402266
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/LoadableDetachableModel-and-anonymous-inner-classes---unwanted-serialization-overhead--tf4689309.html#a13403458
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: LoadableDetachableModel and anonymous inner classes - unwanted serialization overhead?

Posted by Matej Knopp <ma...@gmail.com>.
Where do you have your LoadableDetachableModel declared? And what kind
of IDataProvider are you talking about? If it is wicket's
IDataProvider than it has to be serializable, because DataView/Table
keep it's reference.

LoadableDetachableModel is usually declared as anonymous class inside
component/page, which is serialized anyway, so the implicit reference
makes no difference.

-Matej

On 10/25/07, Stefan Fußenegger <st...@gmx.at> wrote:
>
> Hi folks,
>
> I am quite new to wicket but I already figured out that it deserved its name
> ;) Currently, I am playing around with IDataProvider in conjunction with
> LoadableDetachableModels. As far as I understand, the main purpose of
> LoadableDetachableModels is to tune serialization performance. At the
> beginning I looked at the API doc, which suggested using anonymous inner
> classes for detachable models:
>
>
> public IModel model(Object object) {
>     return new LoadableDetachableModel() {
>         protected Object load() {
>             /* snip - (re)load the object */
>         }
>     };
> }
>
>
> However, this might not be suited for serialization, as inner classes have
> an implicit reference on their enclosing object - which was the
> IDataProvider implementation in my case. As a consequence the IDataProvider
> object  (and all its possible fileds!) would be serialized together with
> every serialized LoadableDetachableModel - which would lead to an unwanted
> serialization overhead.
>
> Am I missing something here? Like some Wicket serialization voodoo that
> takes care of it? If not, it would be worth mentioning in the API doc and
> probably in the wiki as well (I would take care of the wiki if I get green
> lights).
>
> Regards, Stefan
> --
> View this message in context: http://www.nabble.com/LoadableDetachableModel-and-anonymous-inner-classes---unwanted-serialization-overhead--tf4689309.html#a13402266
> Sent from the Wicket - User mailing list archive at Nabble.com.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org