Created
October 27, 2013 07:11
-
-
Save hussachai/7178721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SkipInjectionError | |
public class BugzookyBootstrap implements StarsBootstrap { | |
@PersistenceContext | |
private EntityManager em; | |
@Resource | |
private UserTransaction userTx; | |
@Override | |
public void execute(ServletContext servletContext) throws Exception { | |
if(ServiceProvider.isEjb(servletContext)){ | |
userTx.begin(); | |
}else{ | |
if(!em.getTransaction().isActive()) | |
em.getTransaction().begin(); | |
} | |
try{ | |
generateTestData(servletContext); | |
if(ServiceProvider.isEjb(servletContext)){ | |
userTx.commit(); | |
}else{ | |
em.getTransaction().commit(); | |
} | |
}catch(Exception e){ | |
if(ServiceProvider.isEjb(servletContext)){ | |
userTx.rollback(); | |
}else{ | |
em.getTransaction().rollback(); | |
} | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment