This repository was archived by the owner on Feb 9, 2019. It is now read-only.

Description
I am able to inject the JedisPool in my controllers but not in models, daos or other classes. An example is in my UserDAO. Isn't this supported or why does the exact same code work in the Application controller?
...
import javax.inject.Inject;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
public class UserDAO extends AbstractDAO<User, User_> {
@Inject JedisPool jedisPool;
public UserDAO() {
super(User.class, User_.class);
}
/**
* @return an instance of {@link UserDAO}.
*/
public static UserDAO newInstance() {
return new UserDAO();
}
...
// -- Redis
/**
* Get the last time the user accessed the service.
*
* @param user the {@link models.User}
* @return the last time as a {@link org.joda.time.DateTime}
*/
public DateTime getLastAccess(User user) {
if(jedisPool == null) {
Logger.error("Redis is not available");
return null;
}
Jedis j = jedisPool.getResource();
DateTime dateTime = null;
try {
String dtString = j.hget("userLastAccess", user.id.toString());
dateTime = new DateTime(Long.valueOf(dtString));
} catch(NumberFormatException ex) {
dateTime = null;
} finally {
jedisPool.returnResource(j);
}
return dateTime;
}
}