Run code immediately after PersistFilter init.

42 views
Skip to first unread message

ale

unread,
Jul 17, 2011, 1:01:25 AM7/17/11
to google...@googlegroups.com
Hello.

I need to run a piece of code immediately after it has run PersistFilter.

The only way is to write my own PersistFilter? Is this a good aproach ?

@Singleton
public final class PersistFilter implements Filter {
  private final UnitOfWork unitOfWork;
  private final PersistService persistService;

  @Inject
  public PersistFilter(UnitOfWork unitOfWork, PersistService persistService) {
    this.unitOfWork = unitOfWork;
    this.persistService = persistService;
  }

  public void init(FilterConfig filterConfig) throws ServletException {
    persistService.start();
   
    service1.start();    // <--- SOMETHING LIKE THIS

    service2.start();
  }
...

Jared Bunting

unread,
Jul 17, 2011, 9:58:34 PM7/17/11
to google...@googlegroups.com

Another thought is to use guice's AOP and write a method interceptor for PersistenceService.   Or figure out a way to wrap the persistence service.

I think the real question though is why does it need to initialize RIGHT after?  The answer to this question will likely lead you towards the answer to "how".


--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-guice/-/sXTRTVEwrcgJ.
To post to this group, send email to google...@googlegroups.com.
To unsubscribe from this group, send email to google-guice...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.

ale

unread,
Jul 29, 2011, 1:28:43 AM7/29/11
to google...@googlegroups.com
I have a service that need information from the database.

...
PersistentService.start();
TemplateEngineService.start();
...

@Inject TemplateEngine(TemplateDao templateDao) {
}

Thanks. !
Reply all
Reply to author
Forward
0 new messages