You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Adib Saikali <ad...@programmingmastery.com> on 2008/08/01 05:41:09 UTC

A Questions about the guts of Wicket

Hello Wicket Developers,

Thanks for a great framework. I am studying the source code for Wicket and
have some questions about some parts of the code that are not obvious to me.
I have spent many hours stepping through the code and have not found a good
answer/reason.

1) in the WicketFilter init() and doGet() method wicket is getting the
current class loader twice and checking if the previousClassLoader is the
same as the current class loader. Why is this code needed and what does it
really do? Are you fixing some bug in some app server with this code? 


final ClassLoader previousClassLoader =
Thread.currentThread().getContextClassLoader();
final ClassLoader newClassLoader = getClassLoader();
try
{
	if (previousClassLoader != newClassLoader)
	{
	
Thread.currentThread().setContextClassLoader(newClassLoader);
}

protected ClassLoader getClassLoader()
{
	return Thread.currentThread().getContextClassLoader();
}


Thanks
Adib


Re: A Questions about the guts of Wicket

Posted by Martin Grigorov <mc...@e-card.bg>.
On Thu, 2008-07-31 at 20:41 -0700, Adib Saikali wrote:
> Hello Wicket Developers,
> 
> Thanks for a great framework. I am studying the source code for Wicket and
> have some questions about some parts of the code that are not obvious to me.
> I have spent many hours stepping through the code and have not found a good
> answer/reason.
> 
> 1) in the WicketFilter init() and doGet() method wicket is getting the
> current class loader twice and checking if the previousClassLoader is the
> same as the current class loader. Why is this code needed and what does it
> really do? Are you fixing some bug in some app server with this code? 
> 
> 
> final ClassLoader previousClassLoader =
> Thread.currentThread().getContextClassLoader();
> final ClassLoader newClassLoader = getClassLoader();
> try
> {
> 	if (previousClassLoader != newClassLoader)
> 	{
> 	
> Thread.currentThread().setContextClassLoader(newClassLoader);
> }
> 
> protected ClassLoader getClassLoader()
> {
> 	return Thread.currentThread().getContextClassLoader();
> }
> 

As you can see getClassLoader() is protected. So you (as developer)
could extend WicketFilter and provide different implementation for this
method and return another class loader suitable for your needs.

> 
> Thanks
> Adib
> 
>