Adam Ruggles 写道:
> How are you creating the interceptor?  Are you having guice create it
> or are you creating the instance?
>
> Here is an example of the way I'm binding my transaction interceptor
> and provider.
>
> // Bind the provider
> bind(new TypeLiteral<Provider<Transaction>>()
> { }).to(EntityManagerTransactionProvider.class);
> // Create the interceptor.
> MethodInterceptor interceptor = new TransactionInterceptor();
> // Inject the Transaction into the interceptor.
> requestInjection(interceptor);
> // Intercept all methods for Classes with Transactional Annotation.
> bindInterceptor(Matchers.annotatedWith(Transactional.class),
> Matchers.any(), interceptor);
> // Intercept methods with the Transactional Annotation for all
> classes.
> bindInterceptor(Matchers.any(),
> Matchers.annotatedWith(Transactional.class), interceptor);
>
> On Oct 16, 6:58 pm, "Haulyn R. Jason" <[EMAIL PROTECTED]> wrote:
>   
>> Hi,all
>> I update my guice to current subversion version, because I want a better
>> way to inject a provider to my Interceptor. But I found the follow code
>> does not work:
>>
>> @Inject
>> private SqlMapClientProvider sqlMapClientProvider ;
>>
>> Even the follow code does not work
>> private SqlMapClientProvider sqlMapClientProvider ;
>> @Inject
>> public void setSqlMapClientProvider(xxxxx){}
>>
>> So, is there a better way to do this work? I want to supply AOP
>> transaction support so I need to get a connection in my Interceptor.
>>
>> --
>>
>> Thanks!
>>
>> Mobile: +086-15864011231
>> Website:http://www.openmotel.cn
>>        http://www.vvthumb.com
>> GTalk:[EMAIL PROTECTED]
>> Skype:saharabear
>>
>> Haulyn Runner Jason
>>     
> >
>
>   
Thanks Adam:
I know what's the problem, this is my original code:
binder.bindInterceptor(Matchers.any(), 
Matchers.annotatedWith(LorenzoJDBCTransaction.class), new 
TransactionalInterceptor());

Now I change it to :
MethodInterceptor transactionalInterceptor = new TransactionalInterceptor();
binder.requestInjection(transactionalInterceptor);
binder.bindInterceptor(Matchers.any(), 
Matchers.annotatedWith(LorenzoJDBCTransaction.class), 
transactionalInterceptor);
And everything works well.

Thanks.

-- 

Thanks!

Mobile: +086-15864011231
Website:http://www.openmotel.cn
        http://www.vvthumb.com
GTalk:[EMAIL PROTECTED]
Skype:saharabear


Haulyn Runner Jason



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to