You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Adriano dos Santos Fernandes <ad...@gmail.com> on 2011/07/06 15:13:19 UTC

Wicket 1.5 + Guice + ClassLoaders

Hi!

I'm trying to modularize an application using classloaders.

I override the filter getClassLoader method and return an 
URLClassLoader. Seams working well, except that @Inject's are not working.

I found this in Injector.java:
     protected void inject(final Object object, final IFieldValueFactory 
factory)
     {
         final Class<?> clazz = object.getClass();

         Field[] fields = null;

         // try cache
         fields = cache.get(clazz);

And in ClassMetaCache.java:
     public T get(final Class<?> key)
     {
         ConcurrentHashMap<String, T> container = 
getClassLoaderCache(key.getClassLoader(), false);
         if (container == null)
         {
             return null;
         }
         else
         {
             return container.get(key(key));
         }
     }

     private ConcurrentHashMap<String, T> getClassLoaderCache(final 
ClassLoader classLoader,
         final boolean create)
     {

So it's passing false for the parameter create of getClassLoaderCache, 
then not working correctly.

I don't know about ClassMetaCache, but shouldn't the Guice Injector make 
a call that in the end calls getClassLoaderCache with create=true?

Should I file a Jira for this?


Adriano


Re: Wicket 1.5 + Guice + ClassLoaders

Posted by Adriano dos Santos Fernandes <ad...@gmail.com>.
Please forget this, my problem was another: javax.inject.Injector x 
com.google.inject.Injector.

But then I'd like to introduce this question. Since Guice 3 is out, and 
now there is these two annotations, shouldn't Wicket Guice module take 
both in account?

-------
GuiceFieldValueFactory.java:

     public boolean supportsField(final Field field)
     {
         return field.isAnnotationPresent(Inject.class);    // 
com.google.inject.Inject
     }
-------


Adriano


On 06/07/2011 10:13, Adriano dos Santos Fernandes wrote:
> Hi!
>
> I'm trying to modularize an application using classloaders.
>
> I override the filter getClassLoader method and return an 
> URLClassLoader. Seams working well, except that @Inject's are not 
> working.