Announcement Announcement Module
No announcement yet.
EndPointInterceptor and Transaction Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • EndPointInterceptor and Transaction

    Hello everybody.

    I'm currently working on a spring WS and my main mission was to add some security before the call of the webservice.
    To do that, i used an EndPointInterceptor.

    Everything is working right.
    User sends a request, interceptor checks some data before the endpoint is called and accepts or rejects it.

    In my interceptor, i use some data services that should be transactionnal : all those services are called from the webservice endpoint and from a separate web application. When beeing called from the webapplication or from the EndPoint, the transaction is correctly called.
    But not when called from my interceptor : the systems opens a brand new JDBC connection...

    With a little debugging, I realized that the SpringTransactionAnnotationParser was not called for the services inside the interceptor, but was called when the endpoint was called. (yes, i'm using the @Transactional annotation on service methods that needs it)

    Does this description rings a bell to anyone, or a I doing it wrong (maybe the point)

    Here is my endpoint mapping

    <bean class="">
                Detects @PayloadRoot annotations on @Endpoint bean methods. It uses two interceptors: one that logs the message payload, and the other validates
                it accoring to the 'yyy.xsd' schema file.
            <property name="interceptors">
                                   <bean class="">
                        <property name="schema" value="classpath:/com/xxx/yyy/ws/xxx.xsd"/>
                        <property name="validateRequest" value="true"/>
                        <property name="validateResponse" value="true"/>
                    <bean id="endPointSecurity" class=""/>
            <property name="order" value="1"/>
    The implementation of my EndPointSecurity bean is simple and only implements EndpointInterceptor.

    Here is the aspect mapping for transaction
    <tx:annotation-driven transaction-manager="txManager" order="-1" />
    <context:annotation-config />
     <context:component-scan base-package="all my packages"/>
    <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory"/>
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource" ref="myDataSource"/>
            <property name="configLocation" value="classpath:/hibernate.cfg.xml"/>
    <!-- # Informer Advice # -->
        <!-- ################### -->
        <bean id="informer" class="">
            <!-- execute after the transactional advice (hence the upper order number) -->
            <!-- Lower values have higher priority -->
            <property name="order" value="0"/>
            <property name="dataSource" ref="myDataSource" />
            <property name="procName"
                value="system.connectionpool.set_user_login" />
            <property name="securityContext" ref="securityContext"/>
        <!-- security context -->
        <bean name="securityContext" class="" />
            <aop:aspect id="informerAdvice" ref="informer">
                <!-- on service transactional methods -->
                <aop:pointcut id="transationalServiceMethod"
                    expression="execution(**.*Service.*(..)) &amp;&amp;
                <aop:before method="callInformer" pointcut-ref="transationalServiceMethod"/>
    Thanks a lot if you got a clue somewhere !