Skip to content

Now class aspects are included with method aspects #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2023

Conversation

SentryMan
Copy link
Collaborator

Now for this class.

@MyTimed
@Singleton
public class ExampleService {

  @MyAround
  public String other(
      String param0, int param1) { // } throws IOException, IllegalStateException {
    return "other " + param0 + " " + param1;
  }
}

Generates

@Proxy
@Generated("io.avaje.inject.generator")
public class ExampleService$Proxy extends ExampleService {

  private final MyAroundAspect myAroundAspect;
  private final MyTimedAspect myTimedAspect;

  private Method other0;
  private MethodInterceptor other0MyAround;
  private MethodInterceptor other0MyTimed;

  public ExampleService$Proxy(MyAroundAspect myAroundAspect, MyTimedAspect myTimedAspect) {
    super();
    this.myAroundAspect = myAroundAspect;
    this.myTimedAspect = myTimedAspect;
    try {
      other0 = ExampleService.class.getDeclaredMethod("other", String.class, int.class);
      other0MyAround = myAroundAspect.interceptor(other0, other0.getAnnotation(MyAround.class));
      other0MyTimed = myTimedAspect.interceptor(other0, other0.getAnnotation(MyTimed.class));

    } catch (Exception e) {
      throw new IllegalStateException(e);
    }
  }

  @Override
  public java.lang.String other(String param0, int param1) {
    var call = new Invocation.Call<>(() -> super.other(param0, param1))
      .with(this, other0, param0, param1)
      // wrapping inner nested aspects based on ordering attribute
      .wrap(other0MyAround);
    try {
      // outer-most aspect
      other0MyTimed.invoke(call);
      return call.finalResult();
    } catch (InvocationException e) {
      throw e;
    } catch (Throwable e) {
      throw new InvocationException(e);
    }
  }
}

@SentryMan SentryMan changed the title Now class aspects are included Now class aspects are included with method aspects Jan 3, 2023
@rbygrave rbygrave added the bug Something isn't working label Jan 3, 2023
@rbygrave rbygrave added this to the 8.11 milestone Jan 3, 2023
@rbygrave rbygrave merged commit a174a44 into avaje:master Jan 3, 2023
@SentryMan SentryMan deleted the aspect branch January 11, 2023 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Bug?) Class Aspect Annotations are ignored when methods have their own aspect.
2 participants