Announcement Announcement Module
Collapse
No announcement yet.
jax-ws WebService not getting proxied Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • jax-ws WebService not getting proxied

    Hi !

    I've created a log aspect to log enter and exit for all public methods in my web service project, as well as handling exceptions. It works fine for the classes managed directly by spring.
    My web service class, however, is managed by the websphere jax-ws runtime and cannot be added to the spring config file. To be able to inject dependencies on it, I 've made it extend SpringBeanAutowiringSupport.
    The autowiring of dependencies works fine, but the class doesn't get proxied.

    Is this expected behaviour? If so, is it possible to proxy a websphere-managed bean so that my logging functionality will apply to it?

    Thanks in advance!

    Package name for web service class: no.klp.webservice.aspects
    Aspect configuration:
    Code:
    <aop:config>
    <aop:pointcut id="allPublicOperations"
    	expression="execution(* no.klp.ecm..*.*(..))" />								  
    <aop:aspect id="logCorrelationId" ref="logCorrelationIdBean">
    	<aop:around pointcut-ref="allPublicOperations" method="logCorrelationId" />
    </aop:aspect>
    <aop:aspect id="afterThrowing" ref="logCorrelationIdBean">
    
    	<aop:after-throwing pointcut-ref="allPublicOperations" throwing="exception"
    		method="logCorrelationIdAfterThrowing" />
    </aop:aspect>
    </aop:config>

  • #2
    Beans need to be spring managed.

    -Hetal

    Comment


    • #3
      Spring can and will only proxy beans it knows about, ie beans which are configured in the application context. Your jax-ws based service isn't part of that.

      If you want more power use something like AspectJ and apply load or compile time weaving to achieve what you want.

      Comment


      • #4
        Thanks for the replies!
        Your answers seems reasonable, however another question arises. As mentioned, my services has @Autowired annotations on them, and my config file contains the annotation-config instruction. I guess this means they are implicitly added to the application context. Isn't this "good enough" for the <aop:config> to find it?

        Comment


        • #5
          Your jax-ws webservice still remains outside of the scope of spring. The fact that @Autowired works doesn't make it a spring managed bean, the SpringBeanAutowiringSupport makes that work with a little trickery, but it remains a unmanaged bean.

          Comment


          • #6
            Ok. Thanks!
            I had a look at the SpringBeanAutowiringSupport actually only processes injections, it doesn't seem to register anything in the application context.

            Then the workaround is just to keep the service class ultra thin, and make spring managed delegates do the actual work.

            Comment


            • #7
              Then the workaround is just to keep the service class ultra thin, and make spring managed delegates do the actual work.
              IMHO that is always the recommended way, your logic should be in the services/domain layer. Your web/web service/other connections should be as thin as possible just do mapping and call the appropriate methods.

              Comment

              Working...
              X