Announcement Announcement Module
Collapse
No announcement yet.
Calling of an Advice Method for a class not defined as a bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling of an Advice Method for a class not defined as a bean

    Good Morning everybody,

    This is my first post on this forum and as the majority of you could imagine, i am pretty new with Spring, Spring AOP and Spring Security.
    I am facing with a problem that i know could be solved with the Pure AOP programming but i would like to know if it is possible to find a way to make it in Spring AOP/Spring Security too:

    I am implementing a Security System for some apps i wrote. From what i read on manuals and from what i saw on some tutorial i found on Youtube i realized that every-time an Advice Method is called is because the pointcut matches with a method inside a class defined as a bean.

    Can i write a pointcut in a certain way that is going to intercepts the method inside a class instantiated in the 'normal' way (new MyClass())?

    Thank you very much for you helping hand.

    Daniele

  • #2
    Can i write a pointcut in a certain way that is going to intercepts the method inside a class instantiated in the 'normal' way (new MyClass())?
    It depends.

    If you use normal Spring AOP then the answer is NO spring can only intercept calls to beans it controls those instances you create yourself aren't under spring control and as such aren't intercepted (there is no proxy for them, I suggest a read of the Spring AOP chapter especially the proxy part).

    If you use loadtime weaving and an (@)Aspect then yes but that basically is a full blown aop solution.

    Comment


    • #3
      Thank you very much for your kind reply.

      I would like to explain you the architecture i have in my mind, hoping you could give me precious advices about how to proceed:

      I had several Java-based applications. Every of them had a different Security System and most of them were using Spring as basis framework (Not all of them). I decided to centralize the Security adding a CAS Server and implement the Authorization writing a Jar Library to add to every project, that was collecting all the advice methods that are called during the check of application's flow.

      I would like to manage the Authorization aspects like something outside the applications code, I know that every annotation could be translated in a XML element in Spring AOP and i am not using them in my application's code: it let me configure the Security changing just the XML, without to deploy the project again.

      What do you think is the best way to have a Security Component that checks what is happening within the application without to touch the original application's code and being enough general to be used inside general Java-based applications?

      Could Spring be adapted to my situation?


      Best Regards

      Daniele

      Comment

      Working...
      X