Announcement Announcement Module
Collapse
No announcement yet.
Getting class implementation from a proxy Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting class implementation from a proxy

    Hi guys,
    I am attempting to get the class implementation from a proxy, but I am failing to find the right way to do it.

    This is being done in a test and the proxy is actually cusAccLocSearchService


    Code:
             /** Inject Service to test */
    	@Resource(name = "cus_service_CustAccLocSearchService")
    	protected CusAccLocSearchService cusAccLocSearchService;
    and the service implementation is annotated with @Service.


    Can anyone of you point me to a piece of code that I can reuse (copy really ), and just be able to get the implementation out of the proxy?


    Thanks
    Kris

  • #2
    If the proxy is Spring AOP proxy, try ((Advised) proxy).getTargetSource().getTarget();

    Comment


    • #3
      Thanks

      Hi Libor,

      thanks for the reply. You solution works .

      Let me know what you bank account is and I'll put some money in. Just kidding . You deserve it though.


      I got misled when debugging, as you can see in the screen shot h is of type JdkDynamicAopProxy. But you cannot use that class as it has the default access modifier and can only be used by classes within its package.
      Attachment


      Thanks again
      Kris
      Attached Files

      Comment

      Working...
      X