package com.tap5.hotelbooking.dal;
import org.apache.tapestry5.beanvalidator.BeanValidatorConfigurer;
import org.apache.tapestry5.hibernate.HibernateTransactionAdvisor;
import org.apache.tapestry5.ioc.MethodAdviceReceiver;
import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Match;
/**
* This class should contain contribution to data stuff (hibernate configuration, beanvalidators...)
*/
public class HibernateModule
{
public static void bind(ServiceBinder binder)
{
binder.bind(CrudServiceDAO.class, HibernateCrudServiceDAO.class);
}
public static void contributeBeanValidatorSource(
OrderedConfiguration<BeanValidatorConfigurer> configuration)
{
configuration.add("HotelBookingConfigurer", new BeanValidatorConfigurer()
{
public void configure(javax.validation.Configuration<?> configuration)
{
configuration.ignoreXmlConfiguration();
}
});
}
@Match("*DAO")
public static void adviseTransactions(HibernateTransactionAdvisor advisor,
MethodAdviceReceiver receiver)
{
advisor.addTransactionCommitAdvice(receiver);
}
}