in a webapp i want to run an async thread for a long process and let the client knows the progress status. For this i thought to use this abstract class:
public abstract class ThreadProvider implements Runnable{
protected Thread thread;
public boolean create() throws SystemException{
if(thread!=null && thread.isAlive()) throw new SystemException("Il processo è già in esecuzione");
thread = new Thread(this);
thread.start();
return true;
}
}
And this is my impl:
@Service @Transactional
public class ChiusuraProvider extends ThreadProvider {
private static Logger gdf = Logger.getLogger("gdf");
private static Logger log = Logger.getLogger(ChiusuraProvider.class);
protected Dao dao;
protected CinetelProvider cinetelProvider;
@Override
public void run() {...}
}
Everything works: the thread starts and seems that the autowire works... however Hibernat did not find any session (maybe because i change thread)... how to solve this?
Thanks