[request] generic class name as key

7 posts / 0 new
Last post
atao
Offline
Joined: 10/15/2008
[request] generic class name as key

Vincent,

When I try to use a generic interface as service class key, e.g.:

    <property name="serviceDelegateBeanNames">
      <map>
        <entry key="org.popsuite.common.model.proxy.CalendarDateProxy&lt;org.joda.time.LocalDate&gt;"
               value="calendarDateProxyDelegate" />
      </map>
    </property>

I get this exception:

Caused by: java.lang.ClassNotFoundException: org.popsuite.common.model.proxy.CalendarDateProxy<org.joda.time.LocalDate>
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at org.jspresso.framework.model.descriptor.basic.AbstractComponentDescriptor.registerDelegateServicesIfNecessary(AbstractComponentDescriptor.java:693)
    ... 37 more

When in AbstractComponentDescriptor.registerDelegateServicesIfNecessary, the raw type is extracted and used, everything runs fine.

And then the java class generated doesn't throw a warning message about raw type (References to generic type DateIntervalProxy<B> should be parameterized).

Regards

Pierre

 

 

vvandens
Offline
Joined: 05/29/2008
[request] generic class name as key

Hi Pierre,
As I understand it, it would just be a matter of extracting the raw class name (if it has a generic form) before passing it to Class.forName(), right ?

If that's the case, It sounds reasonable. Have you seen any other place where this should apply ?

 

Best,

Vincent

atao
Offline
Joined: 10/15/2008
[request] generic class name as key

Vincent,

it would just be a matter of extracting the raw class name (if it has a generic form) before passing it to Class.forName(), right ?

Yes. Here I use:

          String rawInterfaceName = nextPair.getKey();
          int pos = rawInterfaceName.indexOf("<");
          if(pos>-1) {
              rawInterfaceName = rawInterfaceName.substring(0, pos); 
          }
          registerService(Class.forName(rawInterfaceName),
              (IComponentService) beanFactory.getBean(nextPair.getValue(),
                  IComponentService.class));

Have you seen any other place where this should apply ?

ATM, no

Regards

Pierre

 

 

vvandens
Offline
Joined: 05/29/2008
[request] generic class name as key

Fine,

The snapsot with the update is uploading now.

 

Regards,

Vincent

atao
Offline
Joined: 10/15/2008
[request] generic class name as key

Vincent

 

I just did an update (mvn package) and the code seems unchanged...

 

Regards

Pierre

vvandens
Offline
Joined: 05/29/2008
[request] generic class name as key

Oups... you are right. I've implemented the change fr serviceDelegateClassNames but not for serviceDelegateBeanNames. The new snapshot is upoading.

 

Best,

Vincent

atao
Offline
Joined: 10/15/2008
[request] generic class name as key

Thanks

 

it's ok now