SuperController.java 679 B

1234567891011121314151617181920212223242526
  1. package jnpf.base.controller;
  2. import jnpf.base.service.SuperService;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import java.lang.reflect.ParameterizedType;
  5. public abstract class SuperController<S extends SuperService<Entity>, Entity> {
  6. @Autowired
  7. protected S baseService;
  8. Class<Entity> entityClass = null;
  9. public Class<Entity> getEntityClass() {
  10. if (entityClass == null) {
  11. this.entityClass = (Class<Entity>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[1];
  12. }
  13. return this.entityClass;
  14. }
  15. public S getBaseService() {
  16. return baseService;
  17. }
  18. }