I need my setup method to run when this class is instantiated but log is null so mailDAO will also be null.
John public class EmailReceiverUtil { public static final int SHOW_MESSAGES = 1; public static final int CLEAR_MESSAGES = 2; public static final int SHOW_AND_CLEAR = SHOW_MESSAGES + CLEAR_MESSAGES; /** * The log. */ @Inject private Logger log; @Inject private MailDAO mailDAO; /** * Mail properties */ Properties props = new Properties(); /** * Timer for background task; */ Timer timer = new Timer(); public EmailReceiverUtil() { System.out.println("EmailReceiverUtil instantiated"); } @EagerLoad public void setup() { // configure properties props.put("mail.user", "John"); props.put("mail.host", "diskstation"); props.put("mail.debug", "false"); props.put("mail.store.protocol", "pop3"); timer.schedule(new MailReceiverThread(), 1000, 60000); log.info("Email Receiver running"); } private void checkInbox(int mode) ... } private boolean processPlainTextMessage(final String from, final String to, final String subject, final String message) { try { String messageText = message; return mailDAO.processIncomingMail(from, to, messageText); } catch (DAOException ex) { ex.printStackTrace(); } return false; } class MailReceiverThread extends TimerTask { public void run() { try { checkInbox(CLEAR_MESSAGES); } catch (Exception ex) { ex.printStackTrace(); } } } } ----- Original Message ----- From: Thiago H de Paula Figueiredo To: Tapestry users Sent: Friday, November 22, 2013 5:26 PM Subject: Re: Tapetsry IoC starting a class with background task that uses an injected service On Fri, 22 Nov 2013 14:03:10 -0200, John <j...@quivinco.com> wrote: > How do I get this class to load when I start my app and make sure the > injected services are set? With EagerLoad the class gets instantiated > but of course the services are null. This statement is not correct as far as I know. Tapestry-IoC injects service proxies (when the service is defined by an interface), so the dependencies may not even be initialized yet, but, when you first call them, they will be initialized. -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org