Spring Bean Injection for Endpoint

View: New views
4 Messages — Rating Filter:   Alert me  

Spring Bean Injection for Endpoint

by Grygorii Lobach :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,
I'm using CXF with JBoss app. server and it's necessary to inject a few
spring beans into endpoint object.
I tried the following solution, but it wasn't working for me:
<beans
 xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:beans="http://www.springframework.org/schema/beans"
 xmlns:jaxws="http://cxf.apache.org/jaxws"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans.xsd
 http://cxf.apache.org/jaxws
 http://cxf.apache.org/schemas/jaxws.xsd">

 <bean id="mailSenderPortType"
class="pl.com.agora.mailsender.ws.MailSenderPortTypeImpl">
  <property name="mailSenderFacade" ref="mailSenderFacade"/>
 </bean>

 <jaxws:endpoint
  id="mailSender"
  address="http://localhost:8080/mailSender"
implementor="#mailSenderPortType">
  <jaxws:invoker>
  <bean class="org.jboss.wsf.stack.cxf.InvokerJSE"/>
  </jaxws:invoker>
 </jaxws:endpoint>

</beans>

mailSenderFacade property is always null at runtime.
Thanks in advance for any advise!

RE: Spring Bean Injection for Endpoint

by Eamonn Dwyer-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Should your ref value not be
mailSender rather than
mailSenderFacade
to match up with your bean's id?

> Date: Wed, 4 Nov 2009 10:54:42 +0200
> Subject: Spring Bean Injection for Endpoint
> From: scellerato@...
> To: users@...
>
> Hi All,
> I'm using CXF with JBoss app. server and it's necessary to inject a few
> spring beans into endpoint object.
> I tried the following solution, but it wasn't working for me:
> <beans
>  xmlns="http://www.springframework.org/schema/beans"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xmlns:beans="http://www.springframework.org/schema/beans"
>  xmlns:jaxws="http://cxf.apache.org/jaxws"
>  xsi:schemaLocation="http://www.springframework.org/schema/beans
>  http://www.springframework.org/schema/beans/spring-beans.xsd
>  http://cxf.apache.org/jaxws
>  http://cxf.apache.org/schemas/jaxws.xsd">
>
>  <bean id="mailSenderPortType"
> class="pl.com.agora.mailsender.ws.MailSenderPortTypeImpl">
>   <property name="mailSenderFacade" ref="mailSenderFacade"/>
>  </bean>
>
>  <jaxws:endpoint
>   id="mailSender"
>   address="http://localhost:8080/mailSender"
> implementor="#mailSenderPortType">
>   <jaxws:invoker>
>   <bean class="org.jboss.wsf.stack.cxf.InvokerJSE"/>
>   </jaxws:invoker>
>  </jaxws:endpoint>
>
> </beans>
>
> mailSenderFacade property is always null at runtime.
> Thanks in advance for any advise!
     
_________________________________________________________________
New Windows 7: Find the right PC for you. Learn more.
http://windows.microsoft.com/shop

RE: Spring Bean Injection for Endpoint

by Grygorii Lobach :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No, I have mailSenderFacade bean which is defined in the separate ApplicationContext.xml file. I'm using ContextLoaderListener for both of them ApplicationContext.xml and jbossws-cxf.xml (which is shown in my previous post) so this bean should be "visible". Besides, when I add some test value to mailSenderPortType instead of mailSenderFacade  like here:

<bean id="mailSenderPortType"
 class="pl.com.agora.mailsender.ws.MailSenderPortTypeImpl">
   <property name="test" value="testString"/>
</bean>

it doesn't initialize the "test" property. I believe this is some endpoint object specific. Or, maybe, using of
org.jboss.wsf.stack.cxf.InvokerJSE invoker has some influence on context.

Eamonn Dwyer-2 wrote:
Should your ref value not be
mailSender rather than
mailSenderFacade
to match up with your bean's id?

> Date: Wed, 4 Nov 2009 10:54:42 +0200
> Subject: Spring Bean Injection for Endpoint
> From: scellerato@gmail.com
> To: users@cxf.apache.org
>
> Hi All,
> I'm using CXF with JBoss app. server and it's necessary to inject a few
> spring beans into endpoint object.
> I tried the following solution, but it wasn't working for me:
> <beans
>  xmlns="http://www.springframework.org/schema/beans"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xmlns:beans="http://www.springframework.org/schema/beans"
>  xmlns:jaxws="http://cxf.apache.org/jaxws"
>  xsi:schemaLocation="http://www.springframework.org/schema/beans
>  http://www.springframework.org/schema/beans/spring-beans.xsd
>  http://cxf.apache.org/jaxws
>  http://cxf.apache.org/schemas/jaxws.xsd">
>
>  <bean id="mailSenderPortType"
> class="pl.com.agora.mailsender.ws.MailSenderPortTypeImpl">
>   <property name="mailSenderFacade" ref="mailSenderFacade"/>
>  </bean>
>
>  <jaxws:endpoint
>   id="mailSender"
>   address="http://localhost:8080/mailSender"
> implementor="#mailSenderPortType">
>   <jaxws:invoker>
>   <bean class="org.jboss.wsf.stack.cxf.InvokerJSE"/>
>   </jaxws:invoker>
>  </jaxws:endpoint>
>
> </beans>
>
> mailSenderFacade property is always null at runtime.
> Thanks in advance for any advise!
     
_________________________________________________________________
New Windows 7: Find the right PC for you. Learn more.
http://windows.microsoft.com/shop

RE: Spring Bean Injection for Endpoint

by Grygorii Lobach :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Googling brought me to the following thread - http://markmail.org/message/cxfrg5agf7boswl3 .
So I changed my jbossws-cxf.xml file as described there and it's working now:

.....................
<jaxws:server id="mailSender"  
                serviceClass="pl.com.agora.mailsender.ws.MailSenderPortType" address="http://localhost:8080/mailSender">
                <jaxws:serviceBean>
                        <bean id="mailSenderPortType" class="pl.com.agora.mailsender.ws.MailSenderPortTypeImpl">
                                <property name="mailSenderFacade" ref="mailSenderFacade"/>
                        </bean>
                </jaxws:serviceBean>
                <jaxws:invoker>
                        <bean class="org.jboss.wsf.stack.cxf.InvokerJSE"/>
                </jaxws:invoker>
</jaxws:server>
......................

But this solution is still not clear for me. Probably, deeper diving into Apache CXF documentation will help.


No, I have mailSenderFacade bean which is defined in the separate ApplicationContext.xml file. I'm using ContextLoaderListener for both of them ApplicationContext.xml and jbossws-cxf.xml (which is shown in my previous post) so this bean should be "visible". Besides, when I add some test value to mailSenderPortType instead of mailSenderFacade  like here:

<bean id="mailSenderPortType"
 class="pl.com.agora.mailsender.ws.MailSenderPortTypeImpl">
   <property name="test" value="testString"/>
</bean>

it doesn't initialize the "test" property. I believe this is some endpoint object specific. Or, maybe, using of
org.jboss.wsf.stack.cxf.InvokerJSE invoker has some influence on context.

Eamonn Dwyer-2 wrote:
Should your ref value not be
mailSender rather than
mailSenderFacade
to match up with your bean's id?

> Date: Wed, 4 Nov 2009 10:54:42 +0200
> Subject: Spring Bean Injection for Endpoint
> From: scellerato@gmail.com
> To: users@cxf.apache.org
>
> Hi All,
> I'm using CXF with JBoss app. server and it's necessary to inject a few
> spring beans into endpoint object.
> I tried the following solution, but it wasn't working for me:
> <beans
>  xmlns="http://www.springframework.org/schema/beans"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xmlns:beans="http://www.springframework.org/schema/beans"
>  xmlns:jaxws="http://cxf.apache.org/jaxws"
>  xsi:schemaLocation="http://www.springframework.org/schema/beans
>  http://www.springframework.org/schema/beans/spring-beans.xsd
>  http://cxf.apache.org/jaxws
>  http://cxf.apache.org/schemas/jaxws.xsd">
>
>  <bean id="mailSenderPortType"
> class="pl.com.agora.mailsender.ws.MailSenderPortTypeImpl">
>   <property name="mailSenderFacade" ref="mailSenderFacade"/>
>  </bean>
>
>  <jaxws:endpoint
>   id="mailSender"
>   address="http://localhost:8080/mailSender"
> implementor="#mailSenderPortType">
>   <jaxws:invoker>
>   <bean class="org.jboss.wsf.stack.cxf.InvokerJSE"/>
>   </jaxws:invoker>
>  </jaxws:endpoint>
>
> </beans>
>
> mailSenderFacade property is always null at runtime.
> Thanks in advance for any advise!
     
_________________________________________________________________
New Windows 7: Find the right PC for you. Learn more.
http://windows.microsoft.com/shop