thanks for the reply. the problem is (I should've pointed out) that my Foo
class is already managed through dependency injection container (gin), which
means there's already a deferred binding implementation generated by
ginjector.

On Fri, Jun 11, 2010 at 5:58 PM, Olivier Monaco <[email protected]>wrote:

> Hi Kevin,
>
> You can rewrite your Foo class as:
>
> public class Foo implements MagicClass {
>  @Trace
>  @Secured
>  public void bar() {
>  }
> }
>
> Then, associate a generator for sub-types of MagicClass and use
> GWT.create to instantiate a new Foo.
>
> GWT.create(Foo.class);
>
> So your generator will be called. It can generate a FooImpl class that
> extends the Foo class and override the bar method as follow:
>
> public class FooImpl extends Foo {
>  public void bar() {
>    Log.log("begin of bar");
>    try {
>      SecurityContext.checkAuthorized();
>      super.bar();
>    }
>    finally {
>      Log.log("end of bar");
>    }
>  }
> }
>
> Where "Log.log" print some logs and "SecurityContext.checkAuthorized"
> throws an error is the user is not authorized. This could be funny and
> not really hard to do.
>
> Olivier
>
> On 11 juin, 18:09, Kevin Qiu <[email protected]> wrote:
> > Hi,
> >
> > I know GWT can generate Java source code with deferred binding. But
> > sometimes, I don't want to generate a new implementation, but based on
> some
> > annotations, I want to have the ability of injecting code at compile
> time.
> >
> > e.g., with the class below
> >
> > public class Foo {
> >   @Log
> >   public void bar() {
> >     @CheckPermission
> >     dosomething();
> >   }
> >
> > }
> >
> > At compile time, I want to have the ability to get the annotations
> available
> > on items, and inject code according to my application logic. So here, the
> > compiler should see:
> > public class Foo {
> >   public void bar() {
> >     log("begin");
> >     if (hasPermission()) {
> >       doSomething();
> >     } else {
> >       error();
> >     }
> >   }
> >
> > }
> >
> > with the extra code being injected. I'm wondering if anything in GWT
> allows
> > me to do that?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" 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-web-toolkit?hl=en.

Reply via email to