Announcement Announcement Module
Collapse
No announcement yet.
@Configurable and Aspect Precedence Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @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
    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

    Comment


    • #3
      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

      Comment


      • #4
        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?

        Comment


        • #5
          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

          Comment

          Working...
          X