Skip to main content

Addon spring descriptor

Addons must have an addon-applicationProperties.xml spring descriptor.

Hibernate DAOS should be declared as the next example states. They can reference any bean present at the Soffid console, including sessionFactory. It's advisable to use two global interceptors:

  • hibernateInterceptor creates and close the hibernate session when needed.
  • daoInterceptor-* is a placeholder for future DAO interceptors. 
<!-- ========================= HIBERNATE DAOs ========================= -->
<!-- SampleEntity DAO -->
<bean id="sampleEntityDao" class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="target">
        <bean class="com.soffid.iam.addons.sample.model.SampleEntityDaoImpl">
            <property name="sessionFactory"><ref bean="sessionFactory"/></property>
        </bean>
    </property>
    <property name="proxyInterfaces">
        <value>com.soffid.iam.addons.sample.model.SampleEntityDao</value>
    </property>
    <property name="interceptorNames">
        <list>
            <value>hibernateInterceptor</value>
            <value>daoInterceptor-*</value>
        </list>
    </property>
</bean>

Spring services should be declared as the next example states. They can reference any bean present at Soffid console. It's advisable to use the global interceptors:

  • transactionInterceptor: starts and finishes the user transaction when needed.
  • hibernateInterceptor creates and closes the hibernate session when needed.
  • serviceInterceptor-* is a placeholder for future service interceptors. 
<!-- sampleService Service Proxy with inner sampleService Service Implementation -->
<bean id="sampleService" class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="target">
        <bean class="com.soffid.iam.addons.sample.service.SampleServiceImpl">
        </bean>
    </property>
    <property name="proxyInterfaces">
        <value>com.soffid.iam.addons.sample.service.ReplicaBootService</value>
    </property>
    <property name="interceptorNames">
        <list>
            <value>serviceTransactionInterceptor</value>
            <value>hibernateInterceptor</value>
            <value>serviceInterceptor-*</value>
        </list>
    </property>
</bean>

Finally, the hibernate mapping resources should be listed at a special bean, just like the following example:

<!-- ========================= HIBERNATE PROPERTIES ========================= -->
<bean id="hibernate-addon-replica" class="es.caib.seycon.ng.spring.AddonHibernateBean">
    <property name="mappingResources">
    	<list>
        	<value>com/soffid/iam/addons/sample/model/SampleEntity.hbm.xml</value>
        </list>
	</property>
</bean>