Set a breakpoint or add a log statement at the end of the WorkerBean.findAll() 
to see what this method returns and if it is differen from what you see 
returned by the methodInvocation.proceed call

Am 24. April 2017 17:56:21 MESZ schrieb pradrone dev <[email protected]>:
>Thanks it does work but now methodInvocation.proceed return [] (empty 
>object) where it should return list values.
>Any idea for such behaviour ?
>
>
>On Sunday, 23 April 2017 14:34:53 UTC+5:30, pradrone dev wrote:
>>
>> Guice module integration issue with REST I have define one AOP guice
>based 
>> module, but when I tried to integrate with REST code, 
>> methodInvocation.proceed retun null. What might be best way to solve
>this 
>> issue.
>>
>> Define AOP Guice based module as below
>>
>> @Retention <https://github.com/Retention>(RetentionPolicy.RUNTIME)
>> @Target <https://github.com/Target>(ElementType.METHOD)
>> @interface <https://github.com/interface> NotOnWeekends {}
>> public class WeekendBlocker implements MethodInterceptor {
>>
>> public Object invoke(MethodInvocation invocation) throws Throwable {
>>
>> Calendar today = new GregorianCalendar();
>>
>> if (today.getDisplayName(DAY_OF_WEEK, LONG, ENGLISH).startsWith("S"))
>{
>>
>>   throw new IllegalStateException(
>>
>>       invocation.getMethod().getName() + " not allowed on
>weekends!");
>> }
>>
>> return invocation.proceed();
>>
>> }
>>
>> }
>>
>> public class NotOnWeekendsModule extends AbstractModule {
>> protected void configure() {
>>
>> bindInterceptor(Matchers.any(),
>Matchers.annotatedWith(NotOnWeekends.class), 
>>
>>     new WeekendBlocker());
>>
>> }
>> }
>>
>> But I tried to Integrate this with my REST API
>>
>> public class WorkerBean implements Worker {
>>
>> @Autowired
>> private WorkerRepository workerRepository;
>>
>> @Override
>> @NotOnWeekends
>> public Collection<Worker> findAll() {
>>
>>     Collection<Worker> workers = workerRepository.findAll();
>>
>>     return workers;
>> }
>>
>> @RestController <https://github.com/RestController>
>> public class WorkerController {
>>
>> @RequestMapping(
>>         value = "/api/workers",
>>         method = RequestMethod.GET,
>>         produces = MediaType.APPLICATION_JSON_VALUE)
>> public ResponseEntity<Collection<Worker>> getWorkers() {
>>
>>
>>     Worker worker = Guice.createInjector(new
>NotOnWeekendsModule()).getInstance(Worker.class);
>>
>>     Collection<Worker> worker = worker.findAll(); // return null 
>>
>>     ....
>> }
>>
>>
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "google-guice" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to [email protected].
>To post to this group, send email to [email protected].
>Visit this group at https://groups.google.com/group/google-guice.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/google-guice/fb70b5e4-27e5-4296-95ef-06c84fc6c0fb%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/E13AB7A0-169D-447E-A951-F3BB32AB9182%40gmx.ch.
For more options, visit https://groups.google.com/d/optout.

Reply via email to