Here is my code:
# entity/BullyUser: @Getter @Setter @ToString @EzyCollection public class BullyUser { @EzyId int id; String username; String password; } # repo/BullyUserRepo: @EzyRepository("userRepo") public interface BullyUserRepo extends EzyMongoRepository<Long, BullyUser> { } # service/BullyUserService: public interface BullyUserService { void saveUser(BullyUser user); BullyUser createUser(String username, String password); BullyUser getUser(String username); } # service/impl/BullyUserServiceImpl: @Setter @EzySingleton("userService") public class BullyUserServiceImpl implements BullyUserService { @EzyAutoBind private BullyUserRepo BullyUserRepo; @Override public void saveUser(BullyUser user) { BullyUserRepo.save(user); } @Override public BullyUser createUser(String username, String password) { BullyUser user = new BullyUser(); user.setUsername(username); user.setPassword(password); BullyUserRepo.save(user); return user; } @Override public BullyUser getUser(String username) { return BullyUserRepo.findByField("username", username); } } // [PLUGIN]/controller/UserLoginController @EzySingleton @EzyEventHandler(USER_LOGIN) public class UserLoginController extends EzyAbstractPluginEventController { @EzyAutoBind private WelcomeService welcomeService; @EzyAutoBind private BullyUserService userService; @Override public void handle(EzyPluginContext ctx, EzyUserLoginEvent event) { logger.info("{} login in", welcomeService.welcome(event.getUsername())); String username = event.getUsername(); String password = event.getPassword(); BullyUser user = userService.getUser(username); if (user == null) { logger.info("User {} does not exist, creating new user", username); user = userService.createUser(username, password); userService.saveUser(user); } } }