0

I have a problem with @autowired.

interface IRole

public interface IRole {

   public abstract String getRoleName();

}

abstract class

public abstract class ARole implements IRole {

   @Autowired
   private StatusService statusService;

   public StatusEntity getStatus(String statusCode){
       return statusService.get(statusCode);
   }
}

Class roleUser

@Component
public class RoleUser extends ARole {

    public String getRoleName() {
       return "USER";
    } 

    public StatusEntity getStatus() {
        return super.getStatus("PROJET");
    }
}

statusService

public interface StatusService {

StatusEntity get(String statusCode);

}

StatusServiceImpl

@Service
@Transactional
public class StatusServiceImpl implements StatusService {

@Autowired
IStatusDao dao;

@Override
public StatusEntity get(String codeStatus) {
    if (codeStatus == null) {
        throw new IllegalArgumentException();
    }

    StatusEntityPk pk = new StatusEntityPk();
    pk.setCode(codeStatus);
    return dao.findById(pk);
    }
}

for moment i try to add roleUser with this :

if(isUser(authority)){
        userRole = new RoleUser();
}

and function isUser return true if authority = 'USER'

But when in run my applcation my statusService is null. do you have an idea ?

thanks

max
  • 1
  • 1

0 Answers0