Results 1 to 2 of 2

Thread: Problem with geBeanNamesForType(java.lang.reflect.Proxy.class)

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Posts
    11

    Cool 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. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    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.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •