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

Lincoln Baxter, III lincolnbaxter at gmail.com
Thu Sep 20 18:37:08 EDT 2012


Looks like a gap :)

Since we spoke about this on IRC, I'll try to take care of it very soon!

~Lincoln

On Sat, Sep 15, 2012 at 9:34 AM, JFlower <fiorenzino at gmail.com> wrote:

> Hi,
>
> in forge is possibile to specify a superType class with generics? How to
> do this?
>
> 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:
> *@Entity*
> *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:
> @Stateless
> @LocalBean
> *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
> generics.
>              - 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 use.
> *
> *
> But in forge, I can't do this:
>
>                 JavaClass javaClass = JavaParser.create(JavaClass.class);
>  javaClass.setName("FlowerTest");
> javaClass.setPackage("it.coopservice.test");
>  javaClass.addImport("org.jboss.forge.spec.ejb.testClasses.BaseEntity");
>
> javaClass.addImport("org.jboss.forge.spec.ejb.testClasses.BaseRepositoryMultiVar");
>  *javaClass.setSuperType("BaseRepositoryMultiVar<BaseEntity>"); *
>
>
> Some trick for this?
>
> Fiorenzo
>
> _______________________________________________
> forge-dev mailing list
> forge-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/forge-dev
>
>


-- 
Lincoln Baxter, III
http://ocpsoft.org
"Simpler is better."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-dev/attachments/20120920/3e0654b4/attachment.html 


More information about the forge-dev mailing list