0 Replies Latest reply on Jul 15, 2008 2:35 PM by Arisson Leal

    EJB-DI + Generics !!

    Arisson Leal Newbie

      I have the following code:


      public abstract class CrudGenericBean<K extends Serializable, Entity> {
          @In
          private CrudFacade<K, Entity> crudFacade;
      }
      




      @Name("userBean")
      public class UserBean extends CrudGenericBean<Long,User> {
      }
      




      @Local
      public interface CrudFacade<K, E> {   
          void create(E e);
      }
      




      @Stateless
      @Name("crudFacade")
      public class CrudFacadeImpl<K, E> implements CrudFacade<K, E> {
          @Override
          public void create(E e){
              //save
          }
      }
      



      How can I inject the crudFacade, setting the generics types ?
      It's possible do this using DI ?


      @In
      private CrudFacade<K, Entity> pmfCrudFacade;
      



      If not, there's another way to do this ?
      For example using Component.getInstance(...) ??


      Something that work like this:



      private CrudFacade<K, Entity> myCrudFacade = new CrudFacade()<K, Entity>;