将使用者作为serviceImpl中的内部类

时间:2018-02-28 09:21:31

标签: java spring events

我在使用serviceimpl.java

中的内部类扫描消费者时遇到问题

以下代码:

public class CredsServiceImpl implements CredsService {
@Service
public static class userCredsConsumer implements Consumer<Event<UserData>> {
    private final Logger log = LoggerFactory.getLogger(userCredsConsumer.class);

    @Autowired
    EntityManager entityManager;
    @Autowired
    CredsDAO credsDAO;

    public void accept(Event<UserData> notificationDataEvent) {
        UserData notificationData = notificationDataEvent.getData();
        entityManager.setEntityId(notificationData.getTenantId());
        List<CredsDTO> credsUser = credsDAO.selectByUserId(notificationData.getUserId());
        if(credsUser == null || credsUser.isEmpty()){
            log.info("No Existing Credential Watcher Record for User [{}]", notificationData.getUserName());
        }else{
            credsDAO.deleteByUserId(notificationData.getUserId());
            log.info("Creds Record for User [{}] is Deleted", notificationData.getUserName());
        }
    }  
}

}

我试图从我创建的凭据配置中访问它

@Autowired
private EventBus eventBus;

@Autowired
UserCredsConsumer userCredsConsumer;

@PostConstruct
public void postConstruct() {
    eventBus.on($("userCredsConsumer"), userCredsConsumer);
}

我现在遇到的问题是它不是我在serviceimpl中创建的userCredsConsumer类。

任何见解都会有所帮助..如果我不把它作为一个内部类,它工作正常。但是如果我把它作为一个内部类而不能正常工作......但我真的需要这个在内部类中,因为业务中的特定原因。

0 个答案:

没有答案