Results 1 to 5 of 5

Thread: @Configurable and Aspect Precedence

  1. #1
    Join Date
    Jul 2006
    Location
    Kolkata, India
    Posts
    217

    Default @Configurable and Aspect Precedence

    @Configurable is based on initialization joinpoints. If in addition to using @Configurable, I need to have additional advices based on initialization joinpoints through custom aspects on the same domain object, what will be the order of execution of the advices ? Do I need to set the precedence using declare precedence ? Is there any recommended best practice in this scenario ?

    Cheers.
    - Debasish

  2. #2
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    Debasish,

    Yes, providing explicit 'declare precedence' will be a best practice here. My recommendation is to use a separate aspect that contains 'declare precedence' statement(s).

    -Ramnivas
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

  3. #3
    Join Date
    Jul 2006
    Location
    Kolkata, India
    Posts
    217

    Default

    Ramnivas -

    Thanks for the suggestion. My only concern with this behavior is that any person working with @Configurable needs to be aware of its implementation. This is not what we find in Spring usually.

    I have one more question regarding Initialization JoinPoints and @Configurable. Suppose I have a domain object as the implementation of an interface (or an extension of an existing class) ..

    @Configurable
    public class Implementation implements Interface {
    // ...
    }

    In this case, based on the current implementation of @Configurable, I get 2 initialization joinpoints - one for the interface and the other for the implementation. This means that the after-returning advice corresponding to the aspect defined for AnnotationBeanConfigurerAspect (or its base aspect) will also be executed twice. Hence the configureBean() will be executed *twice* as well.

    Is this what is desired ? Or I am making some fundamental mistake ?

    Cheers.
    - Debasish

  4. #4
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    Quote Originally Posted by debasishg View Post
    Ramnivas -
    Thanks for the suggestion. My only concern with this behavior is that any person working with @Configurable needs to be aware of its implementation. This is not what we find in Spring usually.
    Well. Generally, many a times ordering or aspects doesn't matter. It is only when ordering matters, explicit steps need to be taken.

    In this case, based on the current implementation of @Configurable, I get 2 initialization joinpoints - one for the interface and the other for the implementation. This means that the after-returning advice corresponding to the aspect defined for AnnotationBeanConfigurerAspect (or its base aspect) will also be executed twice. Hence the configureBean() will be executed *twice* as well.
    I guess, while inefficient, given idempotent nature of configureBean(), end result should be the same.

    That said, I think this can be fixed by the aspect. Can you raise a JIRA issue?
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

  5. #5
    Join Date
    Jul 2006
    Location
    Kolkata, India
    Posts
    217

    Default

    Quote Originally Posted by ramnivas View Post
    I guess, while inefficient, given idempotent nature of configureBean(), end result should be the same.

    That said, I think this can be fixed by the aspect. Can you raise a JIRA issue?
    Just browsed through the JIRA issues. Looks like this has already been logged here.

    Cheers.
    - Debasish

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •