Just noticed this chunk of code in PersistenceBuilder:
public static EntityManagerFactory createEmf(ClassLoader classLoader,
Callable<EntityManagerFactory> callable) throws ExecutionException,
TimeoutException, InterruptedException {
final ExecutorService executor = Executors.newSingleThreadExecutor(new
EntityManagerFactoryThreadFactory(classLoader));
final Future<EntityManagerFactory> future = executor.submit(callable);
return future.get(10, TimeUnit.MINUTES);
}
Not sure what the benefit is of making a new executor and turning this into a
two threaded operation. The timeout is the only benefit I can see. Note
though that it won't stop the thread doing the work. It's also not a daemon
thread so its existence will prevent shutdown.
We should probably make this a real executor with a daemon thread or just keep
it simple and directly create the EntityManager in the caller's thread.
Thoughts?
-David