Announcement Announcement Module
Collapse
No announcement yet.
Problem with geBeanNamesForType(java.lang.reflect.Proxy.class) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with geBeanNamesForType(java.lang.reflect.Proxy.class)

    Hi, In my ApplicationContext I'm creating a client for calling a Jax-RPC web service using JaxRpcPortProxyFactoryBean. Then in a Listener called after the context gets created I want to dynamically get all the beans created to access web services, so I do this:
    ctx.getBeanNamesForType(Proxy.class)
    But the bean name I want doesn't como as a result (but another proxies like XFire ones do come as a result here)

    The weird thing is that if I do this:
    String[] ctxObjects = ctx.getBeanNamesForType(Object.class)
    I get the bean name correctly.
    Then if I do:
    Object myWebService = ctx.getBean("MyWebServiceName")
    I get the correct instance
    And this:
    myWebService instanceof Proxy
    returns true
    Also I can call a myWebService method correctly by doing:
    MyWebServiceInterface myws = (MyWebServiceInterface) myWebService
    myws.runmethod(methodParameters go here...)

    I hope somebody can help me with this as I really don't know why this is happening.

    Thanks in advanced,

    Martin G

  • #2
    Trying to filter by beans of the Proxy class is not a good idea. It's not guaranteed to work--for example, you might have CGLIB proxies. And it's too implementation dependent.

    I would consider using a naming convention. Or an AOP introduction (additional interface) implemented by your web service proxies.

    Comment

    Working...
    X