OK, i got it working, i assume my solution is pretty specific to my own context, but ill post it anyway to see if it helps anyone
Code:
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="hibernateSessionFactory" />
</property>
</bean>
<bean id="txProxyController" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="taggerDAO" class="com.verilogue.service.dao.TaggerHibernateDAO">
<property name="sessionFactory">
<ref bean="hibernateSessionFactory"/>
</property>
</bean>
<bean id="ModelTrainer" parent="txProxyController">
<property name="target">
<ref bean="nonTran_modelTrainer" />
</property>
</bean>
<bean id="nonTran_modelTrainer" class="com.verilogue.service.mallet.DefaultModelTrainer">
<property name="taggerDAO">
<ref bean="taggerDAO"/>
</property>
<property name="sessionFactory">
<ref bean="hibernateSessionFactory" />
</property>
</bean>
The call to set the event, passed in the current application context by a spring instanciated class that is applicationContextAware
Code:
public void scheduelTraining(ApplicationContext ctx)
{
TimerTaskExecutor tte = new TimerTaskExecutor();
tte.setDelay(10*1000);
tte.afterPropertiesSet();
(new ModelTrainerExecutor(tte)).train(this.getUID(),ctx);
}
the trainer executor, gets the trainer from spring using the context at runtime(in the future)
Code:
public class ModelTrainerExecutor {
public class RunModelTrainer implements Runnable {
private int modelUID;
private ApplicationContext ctx;
private ModelTrainer trainer;
public RunModelTrainer(int m, ApplicationContext ctx)
{
modelUID=m;
this.ctx=ctx;
}
public void run()
{
try
{
trainer=(ModelTrainer)ctx.getBean("ModelTrainer");
trainer.setModelUID(modelUID);
trainer.train();
}
catch(Exception ex)
{
System.out.println("Cause: "+ex.getCause());
ex.printStackTrace();
}
}
}
private TaskExecutor taskExecutor;
public ModelTrainerExecutor(TaskExecutor taskExecutor) {
this.taskExecutor = taskExecutor;
}
public void train(int uid, ApplicationContext ctx) {
taskExecutor.execute(new RunModelTrainer(uid,ctx));
}
}
the train method in the actual trainer
Code:
public class DefaultModelTrainer
extends HibernateTemplate
implements ModelTrainer{
private TaggerDAO taggerDAO;
private int modelUID;
@Transactional()
public void train() {
//DAO loads and saves using the object graph
}
public int getModelUID() {
return modelUID;
}
public void setModelUID(int modelUID) {
this.modelUID = modelUID;
}
public TaggerDAO getTaggerDAO() {
return taggerDAO;
}
public void setTaggerDAO(TaggerDAO taggerDAO) {
this.taggerDAO = taggerDAO;
}
i sincerely appreciate everyones help and patience, thank you
Dan