You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by alex shubert <al...@gmail.com> on 2010/11/18 20:44:55 UTC

WeakReference

Hello!

I got a question about that often WeakReference usage in Wicket code.

For example, private WeakReference<Class<? extends Page>>
accessDeniedPage; in Settings.
So my question is: why did author used WeakReference here? Isn't it
somehow unsafe as that reference to accessDeniedPage may be just GC-ed
somewhere during container work?

And second part. I found a caution about not using strong reference to
injected Spring beans for the danger of serialization of a whole
Spring container. Ok, but what about @SpringBean? Is that works
somehow different and uses some sort of Detachable model already?

P.S.: forgive my strange English pls, it is not my native language.
P.S.S. I would highly appreciate if someone with strong English
correct my mistakes in private letter :)

Thank you for reading all of this!

-- 
best regards
Alex

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


Re: WeakReference

Posted by Igor Vaynberg <ig...@gmail.com>.
in objects that are stored in servletcontext scope it is not a good
idea to keep references to class objects directly as it may lead to
the container not being able to release the classloaders and shutdown
cleanly when the context is shutdown. we usually keep a weak reference
and a name, so when weakreference is unavailable we look up the class
by name, weakref is just a cache.

as far as @springbean, those create special proxies just so you do not
serialize the entire container.

-igor



On Thu, Nov 18, 2010 at 11:44 AM, alex shubert <al...@gmail.com> wrote:
> Hello!
>
> I got a question about that often WeakReference usage in Wicket code.
>
> For example, private WeakReference<Class<? extends Page>>
> accessDeniedPage; in Settings.
> So my question is: why did author used WeakReference here? Isn't it
> somehow unsafe as that reference to accessDeniedPage may be just GC-ed
> somewhere during container work?
>
> And second part. I found a caution about not using strong reference to
> injected Spring beans for the danger of serialization of a whole
> Spring container. Ok, but what about @SpringBean? Is that works
> somehow different and uses some sort of Detachable model already?
>
> P.S.: forgive my strange English pls, it is not my native language.
> P.S.S. I would highly appreciate if someone with strong English
> correct my mistakes in private letter :)
>
> Thank you for reading all of this!
>
> --
> best regards
> Alex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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