Hi Alen,
thanks for your help.

> yeah, if Guice doesn't create the instance than there is no way to get
> in the interceptors.
This is a big disadvantage - is it going to solved in 2.0?

> One way I can think of without using any hacks is to put in some
> delegates like in your case you'd have:
> ...
> and then use the delegate instead of the original. It is a bit more
> visual noise. Most IDEs know how to make delegates automatically.
I'm using the free version of eclipse. It supports this feature under
the source menu. The initial effort to create these delegates is not
that much but in case of changes to the service interface you always
have to regenrate the delegates. Thats not very AOP. Having 20 service
classes this will cause my boss to hire a student apprentice to do
this job every day. :-)

> It should be possible to make the delegates automatically behind the
> curtains with some CG magic.
Thats what I was trying to do. AFAIK this is not possible without
providers cause proxies are created @ runtime and binding an interface
type is checked @ compile time. :-(
> Your solution is independent of bindInterceptor;)
Thats why it's dirty :)

> HTH,
> Alen
>
> On Mar 20, 9:24 pm, Richard Hauswald <[email protected]>
> wrote:
>
> > I did a dirty hack... it enables me to somehow, in a very dirty way,
> > apply java proxies to instances created by guice and providers. I
> > attached the solutions classes. Here is how it works:
> > bind(MyService.class).annotatedWith(Names.named("intercept")).to(MyServiceImpl.class);
> > bind(MyService.class).toProvider(new
> > ProxyBindingProvider<MyService>(Key.get(MyService.class,
> > Names.named("intercept")),CallTimeProxy.class));
>
> > I'd be glad if somebody would be so kind to give it short look and
> > maybe write his/her thoughts.
> > Thanks,
> > Richard
>
> > 2009/3/20 Richard <[email protected]>:
>
> > > Hello,
> > > this way i have to create my webservice client:
> > > private static class ReportingServiceProvider implements
> > > Provider<IReportingService> {
> > >               �...@inject
> > >               �...@named("webservices.properties.ReportingService")
> > >                private String url;
>
> > >                public IReportingService get() {
> > >                        HessianProxyFactory factory = new 
> > > HessianProxyFactory();
> > >                        factory.setHessian2Reply(true);
> > >                        factory.setHessian2Request(true);
> > >                        try {
> > >                                return (IReportingService) 
> > > factory.create(IReportingService.class,
> > > url);
> > >                        } catch (MalformedURLException e) {
> > >                                throw new RuntimeException(
> > >                                                e);
> > >                        }
> > >                }
> > >        }
>
> > > Now I want to bind anInterceptorto it:
> > > bindInterceptor(Matchers.subclassesOf(IReportingService.class),
> > > Matchers.any(), new CallTimeInterceptor());
>
> > > But this is not working. I remember a new group entry saying that
> > > guice only installs interceptors toobjectsit creates. Any ideas how
> > > to work around this problem?
>
> >  RawTypeExtractor.java
> > < 1KViewDownload
>
> >  ProxyBindingProvider.java
> > 2KViewDownload
>
> >  ProxyBindingProviderTest.java
> > 3KViewDownload
--~--~---------~--~----~------------~-------~--~----~
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