Sitebrick Service interception ?

37 views
Skip to first unread message

Adio Gemon

unread,
Jun 10, 2013, 7:13:44 AM6/10/13
to google-s...@googlegroups.com
Hi guys , I am working with Sitebricks for quite a time and I like it. I wander what best approach for services intercepting, for cross-cutting tasks, are ? Logging, Validation, Exception Handling, are all tasks to be put in an interceptors like components.
Currently I am doing it with AOP on the services like so :   


 bindInterceptor(annotatedWith(Service.class), returns(only(Reply.class)), new HttpRequestFailureReportInterceptor(new MessageAcceptor() {
          @Override
          public void accept(String message) {
            Logger logger = LoggerFactory.getLogger(this.getClass());
            logger.debug(message);
          }
        }));

Is this a good way to accomplish tasks like that ? If no, why ? What are advantages and drawback for this approach ? 

Dhanji R. Prasanna

unread,
Jul 8, 2013, 5:06:30 PM7/8/13
to google-s...@googlegroups.com
Hi, sorry about the late reply. Yes we generally recommend using method interceptors, but I would probably use an annotation as the binding target.

You could easily replace returnsOnly(Reply) with annotatedWith(Post).or(annotatedWith(Get)) etc..

I think it's a bit cleaner and not dependent on the return type as web pages are allowed to return other things than Reply.


--
You received this message because you are subscribed to the Google Groups "Google Sitebricks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-sitebri...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages