[forge-dev] ejb plugin: work with generics and abstract classes

JFlower fiorenzino at gmail.com
Sat Sep 15 09:34:24 EDT 2012


in forge is possibile to specify a superType class with generics? How to do

My use case is as follows: i have an entity bean, a repository session bean
and an abstract class to extend.

1) An abstract repository with all persistence management functionality:
*public abstract class AbstractRepository<T> implements Serializable {*
public T find(Object key) {
try {
return getEm().find(getEntityType(), key);
} catch (Exception e) {return null; }

2) an entity class like:
*public class SImpleEntity implements Serializable {*
private String name;
public String getName() {return name;}
public void setName(String name) {this.name = name;}

3) i want to create a specific *SImpleEntityRepository* like:
*public class SImpleEntityRepository extends BaseRepository<SImpleEntity> {}

In ejb plugin i need to do this, to create a "add-extends" command (also
for "add-implements").
My initial reasoning is this:
- read with reflection the super class, to understand if this class use
             - If the super class is like *public abstract
class AbstractRepository<T>{}:*
                  i need to modify my current class (an ejb) specifying:
                           - or the generic class
                           - or asking to the user what's the real class to
But in forge, I can't do this:

                JavaClass javaClass = JavaParser.create(JavaClass.class);
*javaClass.setSuperType("BaseRepositoryMultiVar<BaseEntity>"); *

Some trick for this?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-dev/attachments/20120915/00e2a2a9/attachment-0001.html 

More information about the forge-dev mailing list