Thanks for your attention. The IBank there is an interface. AFAIK to create a proxy bean in Spring requires an interface instead of the direct class implementation. The target property of this proxy bean requires the IBank implementation....if i am correct.
during the invocation of this code:
it spit-out an error saying java.lang.ClassCastException
When i change my code to like this:
the error change to: Bean name "Bank" must be of type [arnel.nicolas.Bank], but was actually of type [$Proxy0].
I have a doubt if Spring created a bean name "Bank" of arnel.nicolas.Bank type.
Anyway thanks for your reply. I will just check their forum.
ok guys, i just refactored my code. It seems that there is a problem during the creation of my ProxyFactoryBean Bank. My target class TargetBank has a constructor. So values can be set thru constructor-injection via my bean config file. I removed the constructor and provide a method for it and set the values via method-injection. The code works find and it fires all my advice methods as i expected.
Now, is there a way to get the instance of a ProxyFactoryBean with constructor in the source code? like
Originally posted by Ryan Breidenbach: From your original code example, try this instead:
Spring's bean factory will not return an instance of a Bank, but rather a dynamically created object that implements the IBank interface that proxies method invocations to your a Bank object.
Hmm...but my concrete class Bank has a constructor that takes Object of Customer type as a parameter . I am assuming that Spring's bean factory will do create a proxy object with parameter as i have in my Target class (referring to Bank). I tried to change the code basing from your suggestion but the compiler is complaining about error. I have a doubt that the bean factory did not create a proxy bean that takes a constructor of customer type thats why i am having that error.