[ 
http://jira.codehaus.org/browse/QDOX-205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=213176#action_213176
 ] 

Lukasz Dywicki edited comment on QDOX-205 at 3/9/10 7:40 AM:
-------------------------------------------------------------

Robert thank you for helping me,
Snapshot version works well. I can get information about parameters. 

Class are declared as below:
{code:lang=java}
class GenericControllerImpl<T, K, D extends GenericDAO<T, K>>
    implements GenericController<T, K>
        
class GroupControllerImpl extends
    GenericControllerImpl<Group, Long, GroupDAO>
        
interface GenericController<T, K> 
{code}

And following code prints
{code:lang=java}
source = builder.addSource(new File(path + "GenericControllerImpl.java"));
Type type = source.getClasses()[0].asType();
// prints 'org.code_house.web.GenericControllerImpl' 
System.out.println(type.toGenericString());

type = source.getClasses()[0].getImplements()[0];
// prints 'GenericController<T,K>'
System.out.println(type.toGenericString());
{code}

I can't get declared parameters in class. The actual parameters are resolved 
correctly but we don't have access to type parameters - in that case I can't 
determine with parameters where should be bound.

I can get following information:
Class GenericControllerImpl implements interface GenericController with 
parameters T, K.
but I also need information:
Class GenericControllerImpl are declared with parameters T, K, D.
If I'll get this information I can do something more:
Class GroupControllerImpl provides following parameters: Group (T), Long (L), 
GroupDAO (D). The parameters Group (T), Long (K) are passed to 
GenericController mapped to T, K.

It is possible to obtain this information using current code base?

      was (Author: splatch):
    Robert thank you for helping me,
Snapshot version works well. I can get information about parameters. 

Class are declared as below:
{code:lang=java}
class GenericControllerImpl<T, K, D extends GenericDAO<T, K>>
    implements GenericController<T, K>
        
class GroupControllerImpl extends
    GenericControllerImpl<Group, Long, GroupDAO>
        
interface GenericController<T, K> 
{code}

And following code prints
{code:lang=java}
source = builder.addSource(new File(path + "GenericControllerImpl.java"));
Type type = source.getClasses()[0].asType();
// prints 'org.code_house.web.GenericControllerImpl' 
System.out.println(type.toGenericString());

type = source.getClasses()[0].getImplements()[0];
// prints 'GenericController<T,K>'
System.out.println(type.toGenericString());
{code}

I can't get declared parameters in class. The actual parameters are resolved 
correctly but we don't have access to type parameters - in that case I can't 
determine with parameters where should be bound. If I would get list of 
class/interface-level parameters.

I can get following information:
Class GenericControllerImpl implements interface GenericController with 
parameters T, K.
but I also need information:
Class GenericControllerImpl are declared with parameters T, K, D.
If I'll get this information I can do something more:
Class GroupControllerImpl provides following parameters: Group (T), Long (L), 
GroupDAO (D). The parameters Group (T), Long (K) are passed to 
GenericController mapped to T, K.

It is possible to obtain this information using current code base?
  
> Broken inheritance hierarchy when using generic parent class
> ------------------------------------------------------------
>
>                 Key: QDOX-205
>                 URL: http://jira.codehaus.org/browse/QDOX-205
>             Project: QDox
>          Issue Type: Bug
>    Affects Versions: 1.10.1
>            Reporter: Lukasz Dywicki
>
> I have two classes where first (GenericControllerImpl) is some generic 
> purpose controller with common CRUD methods. Second class 
> (GroupControllerImpl) extends parent to add some REST methods. 
> With QDox I can't resolve type variables from GenericControllerImpl. 
> JavaClass returned after parsing GroupControllerImpl also has no parent class.
> Code
> {code:lang=java|title=Test code}
>         JavaDocBuilder builder = new JavaDocBuilder();
>         JavaSource source = builder.addSource(new 
> File("GroupControllerImpl.java"));
>         System.out.println(source.getClasses()[0].getParentClass());
>         source = builder.addSource(new File("GenericControllerImpl.java"));
>         
> System.out.println(source.getClasses()[0].getImplementedInterfaces()[0].asType());
> {code}
> Classes looks next:
> {code:lang=java|title=GroupControllerImpl}
> package org.code_house.web;
> import org.code_house.dataaccess.GroupDAO;
> import org.code_house.domain.Group;
> import org.springframework.beans.factory.annotation.Autowired;
> import org.springframework.web.bind.annotation.ModelAttribute;
> import org.springframework.web.bind.annotation.RequestMapping;
> public class GroupControllerImpl extends
>     GenericControllerImpl<Group, Long, GroupDAO> {
>     @Autowired
>     public void setUserDao(GroupDAO dao) {
>         this.dao = dao;
>     }
>     @RequestMapping("/x")
>     @ModelAttribute("test")
>     public Boolean doSomething() {
>         return null;
>     }
> }
> {code}
> {code:lang=java|title=GenericControllerImpl.java}
> package org.code_house.web;
> import java.util.List;
> import org.code_house.dataaccess.GenericDAO;
> import org.springframework.beans.factory.InitializingBean;
> import org.springframework.util.Assert;
> import org.springframework.web.bind.annotation.PathVariable;
> import org.springframework.web.bind.annotation.RequestBody;
> import org.springframework.web.bind.annotation.RequestMapping;
> public abstract class GenericControllerImpl<T, K, D extends GenericDAO<T, K>>
>     implements GenericController<T, K>, InitializingBean {
>     protected D dao;
>     @RequestMapping
>     public T create(@RequestBody T object) {
>         dao.create(object);
>         return object;
>     }
>     @RequestMapping
>     public Boolean update(@PathVariable K id, @RequestBody T object) {
>         dao.update(object);
>         return true;
>     }
>     @RequestMapping
>     public T read(@PathVariable K id) {
>         return dao.readById(id);
>     }
>     @RequestMapping
>     public Boolean remove(@PathVariable K id) {
>         return dao.deleteById(id);
>     }
>     @RequestMapping
>     public List<T> getAllRecords() {
>         return dao.getAll();
>     }
>     public void afterPropertiesSet() {
>         Assert.notNull(dao);
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to