Stuart you never answered the two questions..? 2012/1/9 nino martinez wael <[email protected]>
> How does this work when using a provider? > > And it would probably be a good idea to mention if you use an instance > binding interceptors are not applied. > > regards Nino > > 2012/1/6 Stuart McCulloch <[email protected]> > >> On 6 Jan 2012, at 13:24, nino martinez wael wrote: >> >> I know but why wont Guice instrument it, I know it's sort of unmanaged >> since I provided the instance. But I would have assumed that the second I >> bound it using guice, it would invoke the interceptors. >> >> >> You asked Guice to bind a specific instance - the only way it could apply >> AOP to that instance would be to generate a delegating wrapper using CGLIB >> and wrap that around the given instance. However the binding would then >> point to the wrapped instance rather than the original instance, which >> could confuse people who weren't expecting Guice to swap in a different >> instance under the covers. You would also not see any interception if the >> application for some reason used the instance that it passed into Guice for >> binding, rather than the wrapped proxy. The safest approach imho is the one >> used in Guice, which is to only apply AOP to instances created by Guice. >> >> How can I manually instrument it using the interceptors available to >> guice? >> >> >> The binding SPI provides enough information to find instance bindings, as >> well as any interceptor bindings. You can use this information to rewrite >> the instance bindings to point to wrapped forms of the instances, using >> whatever AOP library you prefer to delegate to the original instance and >> invoke the relevant interceptors (as discovered through the SPI). >> >> regards nino >> >> 2012/1/6 Stuart McCulloch <[email protected]> >> >>> On 6 Jan 2012, at 10:47, nino martinez wael wrote: >>> >>> > Hi >>> > >>> > I've just stumbled across something I think are strange. >>> > >>> > I have a GUICE/AOP cache module, when I bind a class using a module, >>> my interceptor pickups calls to the methods annotated as wanted. >>> > >>> > However if I bind to a instance of the same class it my interceptor >>> never gets activated. Why are there a difference, between the two? >>> >>> In the first case, Guice is in control of creating the instance so it >>> can construct it using an instrumented version of the class (using cglib). >>> >>> In the second case, you're asking Guice to use an existing instance >>> (as-is) which won't be instrumented unless you have done this yourself. >>> >>> > regards Nino >>> > >>> > -- >>> > 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. >>> >>> -- >>> 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. >>> >>> >> >> -- >> 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. >> >> >> -- >> 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. >> > > -- 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.
