Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] How to use @DeclareMixin when using generics?

Hi,

I've got the following base class that I would like to change to a Mixin aspect instead.

abstract public class BaseServiceImpl<T> implements BaseService<T> {

    abstract protected BaseRepository<T> getRepo(); 

    public void save(T entity) {

        getRepo().save(entity);

    }

    public List<T> findAll() {

        return getRepo().getAll();

    }

    public T findById(String id) {

        return getRepo().get(id);

    }

    public void deleteEntity(T entity) {

        getRepo().remove(entity);

    }

}


But given the fact that it uses a generic, I'm not quite sure how to declare my mixin.  I'm looking to do this for a general case for all classes in a particular path where each 'T'ype is different, so am not sure how to write the declaration


    @DeclareMixin("com.ia.server.*Impl")

    public BaseService baseServiceMixin(){

        return new BaseServiceImpl<???? what goes here ????>();

   }


At the moment, this is an abstract class as I need the child class to determine the BaseRepo<T>, but is there a way of getting this info from the child class itself?  Or at the very least, have it @Inject'ed?


Thanks,

Eric


Back to the top