You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Kerekes András <ke...@ipsystems.hu> on 2011/03/11 11:42:22 UTC

how to access implementor class

Hi,

I have the following problem:

I have an interface annotated with @WebService and @WebMethod annotations, and a class that implements this interface, with some custom annotations that are unrelated to cxf/jaxws/etc.
In xml I have declared the following:

    <bean id="FOO" class="com.sample.WebServiceImpl "/>
    <jaxws:endpoint id="FooService" implementor="#FOO" address="/FooService" />

This works perfectly. What I want to do is to access the implementor class in runtime to provide informations about the service. I use org.apache.cxf.endpoint.ServerRegistry to access the servers and get metadata about them. I can get information with EndpointInfo, BindingInfo etc. I just cannot obtain the implementor class, which is needed for me, because I want to find out what annotations are placed on the methods that implements the methods of the interface.

So, is there a way to get the class that implements a given WebService annotated interface in runtime?

I use CXF 2.3.0.

Thanks for any help!

András


Re: how to access implementor class

Posted by Daniel Kulp <dk...@apache.org>.

If you have the Bus (which I assume you do since you have the 
ServiceRegistry), then you could get the Spring context directly via:

bus.getExtension(ApplicationContext.class).getBean(FOO);

If you have the Server (or Service) object, you can do something like:

FactoryInvoker  i = (FactoryInvoker)service.getInvoker()
Object o = i.getServiceObject(null);


Another option would be to do something like:


<jaxws:endpoint id="FooService" implementor="#FOO"
    address="/FooService" >
   <jaxws:properties>
       <entry key="myObject" ref="FOO"/>
    ...

And then you should be able to queary that directly from then Endpoint object.


Dan






On Friday 11 March 2011 5:42:22 AM Kerekes András wrote:
> Hi,
> 
> I have the following problem:
> 
> I have an interface annotated with @WebService and @WebMethod annotations,
> and a class that implements this interface, with some custom annotations
> that are unrelated to cxf/jaxws/etc. In xml I have declared the following:
> 
>     <bean id="FOO" class="com.sample.WebServiceImpl "/>
>     <jaxws:endpoint id="FooService" implementor="#FOO"
> address="/FooService" />
> 
> This works perfectly. What I want to do is to access the implementor class
> in runtime to provide informations about the service. I use
> org.apache.cxf.endpoint.ServerRegistry to access the servers and get
> metadata about them. I can get information with EndpointInfo, BindingInfo
> etc. I just cannot obtain the implementor class, which is needed for me,
> because I want to find out what annotations are placed on the methods that
> implements the methods of the interface.
> 
> So, is there a way to get the class that implements a given WebService
> annotated interface in runtime?
> 
> I use CXF 2.3.0.
> 
> Thanks for any help!
> 
> András

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com