Rob - thanks! I'm most of the way there now.

Here's what I ended up with:

        <!--  Bean to catch successful login event and make user and originating
location info available. -->
        <bean id="auditInfoListenerBean"
class="org.appfuse.model.hibernate.AuditInfoListener">
        </bean>

        <!--  Entity Interceptor bean - sets audit fields for each persistent
object -->
        <bean id="entityInterceptor"
class="org.appfuse.model.hibernate.AuditInterceptor">
                <property name="auditInfoListener" ref="auditInfoListenerBean"/>
        </bean>

    <!-- Hibernate SessionFactory -->
    <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="entityInterceptor" ref="entityInterceptor"/>
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation"
value="classpath:hibernate.cfg.xml"/>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=${hibernate.dialect}
                hibernate.query.substitutions=true 'Y', false 'N'
                hibernate.cache.use_second_level_cache=true
               
hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
            </value>
            <!-- Turn batching off for better error messages under
PostgreSQL -->
            <!-- hibernate.jdbc.batch_size=0 -->
        </property>
    </bean>

My AuditInfoListener class implements the ServletContextAware and
ApplicationEvent interfaces and they are catching the successful login event
and grabbing the ServletContext just fine. I kept this separate from the
AuditInterceptor. For testing and non-webapp stuff, I'm hoping to just
switch in a different bean that will provide the user and IP address (or
equivalent) to the AuditInterceptor.

Question:
But I'm not sure how to get either the session or request from the
ServletContext object - it does not list those properties - unless its just
too late and I'm not looking carefully.

Thank you again - Richard
-- 
View this message in context: 
http://www.nabble.com/How-to-get-authentication-info-into-a-Spring-bean---Hibernate-interceptor-tp15247474s2369p15263231.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to